From 754b9bdc5afab9dd40acc3bb2acea185a29788f5 Mon Sep 17 00:00:00 2001 From: Zach H Date: Sun, 3 Mar 2019 21:57:48 -0500 Subject: [PATCH] Won't change if autoconnect enabled (#3602) * Only will auto-select RR if autoconnect is not checked off. Signed-off-by: Zach Halpern * Only will auto-select RR if autoconnect is not checked off. Signed-off-by: Zach Halpern * On disconnect, un-check autoconnect. Better naming. Signed-off-by: Zach Halpern --- cockatrice/src/dlg_connect.cpp | 14 +++++++++----- cockatrice/src/remoteclient.cpp | 1 + 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/cockatrice/src/dlg_connect.cpp b/cockatrice/src/dlg_connect.cpp index a5982689..cf01777a 100644 --- a/cockatrice/src/dlg_connect.cpp +++ b/cockatrice/src/dlg_connect.cpp @@ -190,15 +190,22 @@ void DlgConnect::rebuildComboBoxList(int failure) UserConnection_Information uci; savedHostList = uci.getServerInfo(); + bool autoConnectEnabled = static_cast(settingsCache->servers().getAutoConnect()); + QString autoConnectSaveName = settingsCache->servers().getSaveName(); + int index = 0; + for (const auto &pair : savedHostList) { auto tmp = pair.second; QString saveName = tmp.getSaveName(); if (saveName.size()) { previousHosts->addItem(saveName); - // On rebuild, set to RR - if (saveName.compare("Rooster Ranges") == 0) { + if (autoConnectEnabled) { + if (saveName.compare(autoConnectSaveName) == 0) { + previousHosts->setCurrentIndex(index); + } + } else if (saveName.compare("Rooster Ranges") == 0) { previousHosts->setCurrentIndex(index); } @@ -206,9 +213,6 @@ void DlgConnect::rebuildComboBoxList(int failure) } } - // Disable auto connect when updating - settingsCache->servers().setAutoConnect(false); - // Re-enable the refresh server button btnRefreshServers->setDisabled(false); } diff --git a/cockatrice/src/remoteclient.cpp b/cockatrice/src/remoteclient.cpp index 4f3d6af2..eee533c6 100644 --- a/cockatrice/src/remoteclient.cpp +++ b/cockatrice/src/remoteclient.cpp @@ -493,6 +493,7 @@ void RemoteClient::activateToServer(const QString &_token) void RemoteClient::disconnectFromServer() { + settingsCache->servers().setAutoConnect(false); emit sigDisconnectFromServer(); }