diff --git a/src/backend.cpp b/src/backend.cpp index 65185c5..12b6b59 100644 --- a/src/backend.cpp +++ b/src/backend.cpp @@ -787,17 +787,8 @@ void BackEnd::removeRecentConnection(const QString &name) if (mLastServerHosts.contains(name)) { mLastServerHosts.removeAll(name); - QSettings settings; - settings.remove(Constants::SettingsKey::RecentConnections); - - settings.beginWriteArray(Constants::SettingsKey::RecentConnections); - for (qsizetype i = 0; i < qMin(10, mLastServerHosts.count()); ++i) { - settings.setArrayIndex(i); - settings.setValue(Constants::SettingsKey::Url, mLastServerHosts.at(i)); - } - settings.endArray(); - emit recentConnectionsChanged(); + syncRecentConnectionsToSettings(); } } @@ -831,14 +822,18 @@ void BackEnd::saveServerHost(const QString &host) mLastServerHosts.prepend(host); emit recentConnectionsChanged(); + syncRecentConnectionsToSettings(); +} +void BackEnd::syncRecentConnectionsToSettings() +{ QSettings settings; settings.remove(Constants::SettingsKey::RecentConnections); settings.beginWriteArray(Constants::SettingsKey::RecentConnections); for (qsizetype i = 0; i < qMin(10, mLastServerHosts.count()); ++i) { settings.setArrayIndex(i); - settings.setValue(Constants::SettingsKey::Url, mLastServerHosts[i]); + settings.setValue(Constants::SettingsKey::Url, mLastServerHosts.at(i)); } settings.endArray(); } diff --git a/src/backend.h b/src/backend.h index e98d87c..740d311 100644 --- a/src/backend.h +++ b/src/backend.h @@ -248,6 +248,7 @@ private slots: void saveLastDashboards(); void loadLastServerHostsFromSettings(); void saveServerHost(const QString &host); + void syncRecentConnectionsToSettings(); void findCompanionSpecObjects(); QFuture findAllSubtypes(const QString &nodeId,