[PATCH 4 of 5] Close the application if started in tray mode and autstart is not set

Wald Commits scm-commit at wald.intevation.org
Thu Apr 24 12:45:22 CEST 2014


# HG changeset patch
# User Raimund Renkert <rrenkert at intevation.de>
# Date 1398336275 -7200
# Node ID 0f4331ed4e83702a468f388d6ec41192ec8aedc7
# Parent  9be337ea1e3c4563176dbd911c1dc02507cff95b
Close the application if started in tray mode and autstart is not set.

diff -r 9be337ea1e3c -r 0f4331ed4e83 ui/main.cpp
--- a/ui/main.cpp	Thu Apr 24 12:28:24 2014 +0200
+++ b/ui/main.cpp	Thu Apr 24 12:44:35 2014 +0200
@@ -37,9 +37,25 @@
 {
     QApplication app (argc, argv);
 
+    QApplication::setQuitOnLastWindowClosed(false);
+    QApplication::setOrganizationName(QString::fromLatin1(ORGANIZATION));
+    QApplication::setApplicationName(QString::fromLatin1(APPNAME));
+    QApplication::setApplicationVersion(QString::fromLatin1(VERSION));
+    QSettings::setDefaultFormat(QSettings::IniFormat);
+
     QStringList arguments = QApplication::arguments();
     bool trayMode = arguments.contains("--tray");
 
+    QSettings settings;
+    settings.beginGroup("settings");
+    int autoStart = settings.value("autostart").toInt();
+    settings.endGroup();
+    qDebug() << "autostart: " << autoStart;
+
+    if (trayMode && autoStart <= 0) {
+        return 0;
+    }
+
     QTranslator translator;
     if (QLocale::system().name() == "C") {
         /* Useful for testing / development as the primary target is german */
@@ -60,12 +76,6 @@
         return 1;
     }
 
-    QApplication::setQuitOnLastWindowClosed(false);
-    QApplication::setOrganizationName(QString::fromLatin1(ORGANIZATION));
-    QApplication::setApplicationName(QString::fromLatin1(APPNAME));
-    QApplication::setApplicationVersion(QString::fromLatin1(VERSION));
-    QSettings::setDefaultFormat(QSettings::IniFormat);
-
     MainWindow mainWin(trayMode);
 
     return app.exec();


More information about the Trustbridge-commits mailing list