diff ui/main.cpp @ 840:c9a31544aaab

(issue50) Write startup file with display variable
author Andre Heinecke <andre.heinecke@intevation.de>
date Tue, 29 Jul 2014 13:15:32 +0200
parents 294d76174102
children 4efd6378c001
line wrap: on
line diff
--- a/ui/main.cpp	Mon Jul 28 18:42:59 2014 +0200
+++ b/ui/main.cpp	Tue Jul 29 13:15:32 2014 +0200
@@ -14,6 +14,7 @@
 #endif
 
 #include <QApplication>
+#include <QFile>
 #include <QSystemTrayIcon>
 #include <QtPlugin>
 #include <QMessageBox>
@@ -31,6 +32,10 @@
 #define APPNAME "TrustBridge"
 #endif
 
+#ifndef STARTUP_FILE_NAME
+#define STARTUP_FILE_NAME "trustbridge-tray-starter.cfg"
+#endif
+
 #ifndef ORGANIZATION
 #define ORGANIZATION "BSI"
 #endif
@@ -118,8 +123,13 @@
         qDebug() << " task sched done: " << taskSched.createDailyTask(QCoreApplication::applicationFilePath(),
                 QString::fromLatin1("--tray"), QTime::currentTime());
     }
+#else
+    /* Save the display on start so that it might later be used by the cron startup script. */
+    QFile startup_file (settings.fileName().replace(APPNAME ".ini", STARTUP_FILE_NAME));
+    startup_file.open(QIODevice::WriteOnly);
+    startup_file.write(QString::fromLatin1("DISPLAY=%1\n").arg(qgetenv("DISPLAY").constData()).toUtf8());
+    startup_file.close();
 #endif
-
     MainWindow mainWin(trayMode);
 
     return app.exec();

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