client: Fix Remote Cores marked unsaved on load
authorShane Synan <digitalcircuit36939@gmail.com>
Mon, 18 Jun 2018 01:02:49 +0000 (20:02 -0500)
committerManuel Nickschas <sputnick@quassel-irc.org>
Mon, 18 Jun 2018 19:27:30 +0000 (21:27 +0200)
Fix Remote Cores (CoreAccountSettingsPage) wrongly being marked as
unsaved when loading if a default core account was chosen and the
index in the QComboBox was not 0.

This likely happened due to the change of setCurrentIndex on
autoConnectAccount triggering the state as changed, due to a missing
call to setChangedState().  Possibly.

Also clean up if statement scopes while we're here.

Test case:
> Add two accounts, "A" and "B"
> Pick "B" as default account
> Save, close Settings dialog, re-open
> Select Remote Cores, note that it's treated as if changes were there

src/qtui/settingspages/coreaccountsettingspage.cpp

index 0ccf5ad..dfb7456 100644 (file)
@@ -81,6 +81,8 @@ void CoreAccountSettingsPage::load()
     ui.autoConnectAccount->setCurrentIndex(idx.isValid() ? idx.row() : 0);
     ui.autoConnectAccount->setProperty("storedValue", ui.autoConnectAccount->currentIndex());
     setWidgetStates();
+    // Mark as no changes made, we just loaded settings
+    setChangedState(false);
 }
 
 
@@ -224,8 +226,10 @@ void CoreAccountSettingsPage::widgetHasChanged()
 
 bool CoreAccountSettingsPage::testHasChanged()
 {
-    if (ui.autoConnectAccount->currentIndex() != ui.autoConnectAccount->property("storedValue").toInt())
+    if (ui.autoConnectAccount->currentIndex() !=
+            ui.autoConnectAccount->property("storedValue").toInt()) {
         return true;
+    }
     if (*model() != *Client::coreAccountModel()) {
         return true;
     }