comparison ui/main.cpp @ 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 3d1e9df24803
children 77d478a34f45
comparison
equal deleted inserted replaced
481:9be337ea1e3c 482:0f4331ed4e83
35 35
36 int main(int argc, char **argv) 36 int main(int argc, char **argv)
37 { 37 {
38 QApplication app (argc, argv); 38 QApplication app (argc, argv);
39 39
40 QApplication::setQuitOnLastWindowClosed(false);
41 QApplication::setOrganizationName(QString::fromLatin1(ORGANIZATION));
42 QApplication::setApplicationName(QString::fromLatin1(APPNAME));
43 QApplication::setApplicationVersion(QString::fromLatin1(VERSION));
44 QSettings::setDefaultFormat(QSettings::IniFormat);
45
40 QStringList arguments = QApplication::arguments(); 46 QStringList arguments = QApplication::arguments();
41 bool trayMode = arguments.contains("--tray"); 47 bool trayMode = arguments.contains("--tray");
48
49 QSettings settings;
50 settings.beginGroup("settings");
51 int autoStart = settings.value("autostart").toInt();
52 settings.endGroup();
53 qDebug() << "autostart: " << autoStart;
54
55 if (trayMode && autoStart <= 0) {
56 return 0;
57 }
42 58
43 QTranslator translator; 59 QTranslator translator;
44 if (QLocale::system().name() == "C") { 60 if (QLocale::system().name() == "C") {
45 /* Useful for testing / development as the primary target is german */ 61 /* Useful for testing / development as the primary target is german */
46 translator.load(":/l10n/trustbridge_de_DE"); 62 translator.load(":/l10n/trustbridge_de_DE");
58 "on this system. This software can only " 74 "on this system. This software can only "
59 "be used in a desktop environment.")); 75 "be used in a desktop environment."));
60 return 1; 76 return 1;
61 } 77 }
62 78
63 QApplication::setQuitOnLastWindowClosed(false);
64 QApplication::setOrganizationName(QString::fromLatin1(ORGANIZATION));
65 QApplication::setApplicationName(QString::fromLatin1(APPNAME));
66 QApplication::setApplicationVersion(QString::fromLatin1(VERSION));
67 QSettings::setDefaultFormat(QSettings::IniFormat);
68
69 MainWindow mainWin(trayMode); 79 MainWindow mainWin(trayMode);
70 80
71 return app.exec(); 81 return app.exec();
72 } 82 }

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