changeset 482:0f4331ed4e83

Close the application if started in tray mode and autstart is not set.
author Raimund Renkert <rrenkert@intevation.de>
date Thu, 24 Apr 2014 12:44:35 +0200
parents 9be337ea1e3c
children a055847decbc
files ui/main.cpp
diffstat 1 files changed, 16 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- 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();

http://wald.intevation.org/projects/trustbridge/