[PATCH 6 of 6] Default autostart to true and change setting to bool

Wald Commits scm-commit at wald.intevation.org
Fri Apr 25 12:16:59 CEST 2014


# HG changeset patch
# User Andre Heinecke <aheinecke at intevation.de>
# Date 1398421006 0
# Node ID 077b4342d69b39fa926f9f4b74112a456e2c6f1f
# Parent  5ec7d3a36ba6f4adb18a7867eb719db6963df7f4
Default autostart to true and change setting to bool

diff -r 5ec7d3a36ba6 -r 077b4342d69b ui/main.cpp
--- a/ui/main.cpp	Fri Apr 25 10:16:18 2014 +0000
+++ b/ui/main.cpp	Fri Apr 25 10:16:46 2014 +0000
@@ -48,10 +48,10 @@
 
     QSettings settings;
     settings.beginGroup("settings");
-    int autoStart = settings.value("autostart").toInt();
+    bool autoStart = settings.value("autostart", true).toBool();
     settings.endGroup();
 
-    if (trayMode && autoStart <= 0) {
+    if (trayMode && !autoStart) {
         return 0;
     }
 
diff -r 5ec7d3a36ba6 -r 077b4342d69b ui/mainwindow.cpp
--- a/ui/mainwindow.cpp	Fri Apr 25 10:16:18 2014 +0000
+++ b/ui/mainwindow.cpp	Fri Apr 25 10:16:46 2014 +0000
@@ -392,11 +392,11 @@
     connect(mAutoStartOption, SIGNAL(stateChanged(int)),
         this, SLOT(saveAutoStart(int)));
     mSettings.beginGroup("settings");
-    int autoUpdate = mSettings.value("autoupdate").toInt();
-    int autoStart = mSettings.value("autostart").toInt();
+    bool autoUpdate = mSettings.value("autoupdate", false).toBool();
+    bool autoStart = mSettings.value("autostart", true).toBool();
     mSettings.endGroup();
-    mAutoUpdateOption->setCheckState(autoUpdate > 0 ? Qt::Checked : Qt::Unchecked);
-    mAutoStartOption->setCheckState(autoStart > 0 ? Qt::Checked : Qt::Unchecked);
+    mAutoUpdateOption->setCheckState(autoUpdate ? Qt::Checked : Qt::Unchecked);
+    mAutoStartOption->setCheckState(autoStart ? Qt::Checked : Qt::Unchecked);
 
 
     // The buttons.
@@ -732,14 +732,14 @@
 void MainWindow::saveAutoUpdate(int state)
 {
     mSettings.beginGroup("settings");
-    mSettings.setValue("autoupdate", state);
+    mSettings.setValue("autoupdate", state != Qt::Unchecked);
     mSettings.endGroup();
 }
 
 void MainWindow::saveAutoStart(int state)
 {
     mSettings.beginGroup("settings");
-    mSettings.setValue("autostart", state);
+    mSettings.setValue("autostart", state != Qt::Unchecked);
     mSettings.endGroup();
 }
 


More information about the Trustbridge-commits mailing list