diff 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
line wrap: on
line diff
--- a/ui/main.cpp	Tue Sep 09 17:16:07 2014 +0200
+++ b/ui/main.cpp	Tue Sep 09 17:58:55 2014 +0200
@@ -52,6 +52,21 @@
  Q_IMPORT_PLUGIN(QXcbIntegrationPlugin)
 #endif
 
+bool g_debug = false;
+QtMessageHandler g_default_msg_handler = NULL;
+
+void noDebugOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)
+{
+    if (type == QtDebugMsg) {
+        return;
+    }
+
+    if (g_default_msg_handler) {
+        (*g_default_msg_handler)(type, context, msg);
+    }
+}
+
+
 int main(int argc, char **argv)
 {
 #ifdef WIN32
@@ -77,12 +92,19 @@
     QApplication::setApplicationName(QString::fromLatin1(APPNAME));
     QApplication::setApplicationVersion(QString::fromLatin1(VERSION));
     QSettings::setDefaultFormat(QSettings::IniFormat);
+    QStringList arguments = QApplication::arguments();
+
+    if (arguments.contains("--debug")) {
+        g_debug = true;
+    } else {
+        g_debug = false;
+        g_default_msg_handler = qInstallMessageHandler(noDebugOutput);
+    }
 
     qDebug() << "Application style is: " << app.style()->metaObject()->className();
     qDebug() << "Available styles: " << QStyleFactory::keys().join(", ");
     qDebug() << "Font is: " << app.font();
 
-    QStringList arguments = QApplication::arguments();
     bool trayMode = arguments.contains("--tray");
 
     if (arguments.contains("--version")) {

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