comparison ui/main.cpp @ 1058:fe2c6666b462

(issue46) Add debug option to trustbridge client application
author Andre Heinecke <andre.heinecke@intevation.de>
date Tue, 09 Sep 2014 17:58:55 +0200
parents 561cc777e0b6
children 1e429faf7c84
comparison
equal deleted inserted replaced
1057:126e5ce4d1d1 1058:fe2c6666b462
50 Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin) 50 Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin)
51 #else 51 #else
52 Q_IMPORT_PLUGIN(QXcbIntegrationPlugin) 52 Q_IMPORT_PLUGIN(QXcbIntegrationPlugin)
53 #endif 53 #endif
54 54
55 bool g_debug = false;
56 QtMessageHandler g_default_msg_handler = NULL;
57
58 void noDebugOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)
59 {
60 if (type == QtDebugMsg) {
61 return;
62 }
63
64 if (g_default_msg_handler) {
65 (*g_default_msg_handler)(type, context, msg);
66 }
67 }
68
69
55 int main(int argc, char **argv) 70 int main(int argc, char **argv)
56 { 71 {
57 #ifdef WIN32 72 #ifdef WIN32
58 /* First verify integrity even before calling QApplication. 73 /* First verify integrity even before calling QApplication.
59 * We only do this on Windows as we have a PKCS#7 embedded 74 * We only do this on Windows as we have a PKCS#7 embedded
75 QApplication::setQuitOnLastWindowClosed(false); 90 QApplication::setQuitOnLastWindowClosed(false);
76 QApplication::setOrganizationName(QString::fromLatin1(ORGANIZATION)); 91 QApplication::setOrganizationName(QString::fromLatin1(ORGANIZATION));
77 QApplication::setApplicationName(QString::fromLatin1(APPNAME)); 92 QApplication::setApplicationName(QString::fromLatin1(APPNAME));
78 QApplication::setApplicationVersion(QString::fromLatin1(VERSION)); 93 QApplication::setApplicationVersion(QString::fromLatin1(VERSION));
79 QSettings::setDefaultFormat(QSettings::IniFormat); 94 QSettings::setDefaultFormat(QSettings::IniFormat);
95 QStringList arguments = QApplication::arguments();
96
97 if (arguments.contains("--debug")) {
98 g_debug = true;
99 } else {
100 g_debug = false;
101 g_default_msg_handler = qInstallMessageHandler(noDebugOutput);
102 }
80 103
81 qDebug() << "Application style is: " << app.style()->metaObject()->className(); 104 qDebug() << "Application style is: " << app.style()->metaObject()->className();
82 qDebug() << "Available styles: " << QStyleFactory::keys().join(", "); 105 qDebug() << "Available styles: " << QStyleFactory::keys().join(", ");
83 qDebug() << "Font is: " << app.font(); 106 qDebug() << "Font is: " << app.font();
84 107
85 QStringList arguments = QApplication::arguments();
86 bool trayMode = arguments.contains("--tray"); 108 bool trayMode = arguments.contains("--tray");
87 109
88 if (arguments.contains("--version")) { 110 if (arguments.contains("--version")) {
89 printf (APPNAME " Version: %s \n", 111 printf (APPNAME " Version: %s \n",
90 QApplication::applicationVersion().toLocal8Bit().constData()); 112 QApplication::applicationVersion().toLocal8Bit().constData());

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