restore saved previous server (#4206)

fix #3617
This commit is contained in:
ebbit1q 2020-12-06 03:36:27 +01:00 committed by GitHub
parent 77be6a120c
commit 0ce813b826
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View file

@ -193,12 +193,13 @@ void DlgConnect::rebuildComboBoxList(int failure)
savedHostList = uci.getServerInfo(); savedHostList = uci.getServerInfo();
bool autoConnectEnabled = static_cast<bool>(SettingsCache::instance().servers().getAutoConnect()); bool autoConnectEnabled = static_cast<bool>(SettingsCache::instance().servers().getAutoConnect());
QString previousHostName = SettingsCache::instance().servers().getPrevioushostName();
QString autoConnectSaveName = SettingsCache::instance().servers().getSaveName(); QString autoConnectSaveName = SettingsCache::instance().servers().getSaveName();
int index = 0; int index = 0;
for (const auto &pair : savedHostList) { for (const auto &pair : savedHostList) {
auto tmp = pair.second; const auto &tmp = pair.second;
QString saveName = tmp.getSaveName(); QString saveName = tmp.getSaveName();
if (saveName.size()) { if (saveName.size()) {
previousHosts->addItem(saveName); previousHosts->addItem(saveName);
@ -207,7 +208,7 @@ void DlgConnect::rebuildComboBoxList(int failure)
if (saveName.compare(autoConnectSaveName) == 0) { if (saveName.compare(autoConnectSaveName) == 0) {
previousHosts->setCurrentIndex(index); previousHosts->setCurrentIndex(index);
} }
} else if (saveName.compare("Rooster Ranges") == 0) { } else if (saveName.compare(previousHostName) == 0) {
previousHosts->setCurrentIndex(index); previousHosts->setCurrentIndex(index);
} }

View file

@ -50,7 +50,8 @@ QString ServersSettings::getSite(QString defaultSite)
QString ServersSettings::getPrevioushostName() QString ServersSettings::getPrevioushostName()
{ {
return getValue("previoushostName", "server").toString(); QVariant value = getValue("previoushostName", "server");
return value == QVariant() ? "Rooster Ranges" : value.toString();
} }
int ServersSettings::getPrevioushostindex(const QString &saveName) int ServersSettings::getPrevioushostindex(const QString &saveName)