diff --git a/GPClient/gpclient.cpp b/GPClient/gpclient.cpp index a637b8d..1a3ca02 100644 --- a/GPClient/gpclient.cpp +++ b/GPClient/gpclient.cpp @@ -446,8 +446,14 @@ bool GPClient::connected() const QList GPClient::allGateways() const { - const QString gatewaysJson = settings::get(portal() + "_gateways").toString(); - return GPGateway::fromJson(gatewaysJson); + + QList gateways; + + for (auto g :settings::get_all("_gateways$") ){ + + gateways.append(GPGateway::fromJson(settings::get(g).toString())); + } + return gateways; } void GPClient::setAllGateways(QList gateways) @@ -475,6 +481,7 @@ void GPClient::setCurrentGateway(const GPGateway gateway) LOGI << "Updating the current gateway to " << gateway.name(); settings::save(portal() + "_selectedGateway", gateway.name()); + ui->portalInput->setText(gateway.address()); populateGatewayMenu(); } diff --git a/GPClient/gphelper.cpp b/GPClient/gphelper.cpp index 08a5152..a556966 100644 --- a/GPClient/gphelper.cpp +++ b/GPClient/gphelper.cpp @@ -115,6 +115,12 @@ QVariant gpclient::helper::settings::get(const QString &key, const QVariant &def return _settings->value(key, defaultValue); } +QStringList gpclient::helper::settings::get_all(const QString &key, const QVariant &defaultValue) +{ + QRegularExpression re(key); + return _settings->allKeys().filter(re); +} + void gpclient::helper::settings::save(const QString &key, const QVariant &value) { _settings->setValue(key, value); diff --git a/GPClient/gphelper.h b/GPClient/gphelper.h index fb74899..a8a14b8 100644 --- a/GPClient/gphelper.h +++ b/GPClient/gphelper.h @@ -34,6 +34,7 @@ namespace gpclient { static const QStringList reservedKeys {"extraArgs", "clientos"}; QVariant get(const QString &key, const QVariant &defaultValue = QVariant()); + QStringList get_all(const QString &key, const QVariant &defaultValue = QVariant()); void save(const QString &key, const QVariant &value); void clear(); }