Skip to content

Commit

Permalink
restore saved previous server (Cockatrice#4206)
Browse files Browse the repository at this point in the history
  • Loading branch information
ebbit1q authored and knitknit committed Jan 2, 2021
1 parent 8879ce4 commit 8226054
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions cockatrice/src/dlg_connect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,13 @@ void DlgConnect::rebuildComboBoxList(int failure)
savedHostList = uci.getServerInfo();

bool autoConnectEnabled = static_cast<bool>(SettingsCache::instance().servers().getAutoConnect());
QString previousHostName = SettingsCache::instance().servers().getPrevioushostName();
QString autoConnectSaveName = SettingsCache::instance().servers().getSaveName();

int index = 0;

for (const auto &pair : savedHostList) {
auto tmp = pair.second;
const auto &tmp = pair.second;
QString saveName = tmp.getSaveName();
if (saveName.size()) {
previousHosts->addItem(saveName);
Expand All @@ -207,7 +208,7 @@ void DlgConnect::rebuildComboBoxList(int failure)
if (saveName.compare(autoConnectSaveName) == 0) {
previousHosts->setCurrentIndex(index);
}
} else if (saveName.compare("Rooster Ranges") == 0) {
} else if (saveName.compare(previousHostName) == 0) {
previousHosts->setCurrentIndex(index);
}

Expand Down
3 changes: 2 additions & 1 deletion cockatrice/src/settings/serverssettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ QString ServersSettings::getSite(QString defaultSite)

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)
Expand Down

0 comments on commit 8226054

Please sign in to comment.