Fix compile with -DQT_NO_SYSTEMTRAYICON
authorMontel Laurent <laurent.montel@kdab.com>
Thu, 6 Dec 2012 13:54:01 +0000 (14:54 +0100)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Thu, 6 Dec 2012 17:40:29 +0000 (18:40 +0100)
Change-Id: Icca0bef7efca77a841b30f40692144663e7ae913
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
examples/widgets/desktop/systray/main.cpp
examples/widgets/desktop/systray/window.cpp
examples/widgets/desktop/systray/window.h

index bb81bb7..ece0452 100644 (file)
 ****************************************************************************/
 
 #include <QApplication>
-#include <QMessageBox>
 
+#ifndef QT_NO_SYSTEMTRAYICON
+
+#include <QMessageBox>
 #include "window.h"
 
 int main(int argc, char *argv[])
@@ -61,3 +63,24 @@ int main(int argc, char *argv[])
     window.show();
     return app.exec();
 }
+
+#else
+
+#include <QLabel>
+#include <QDebug>
+
+int main(int argc, char *argv[])
+{
+    QApplication app(argc, argv);
+    QString text("QSystemTrayIcon is not supported on this platform");
+
+    QLabel *label = new QLabel(text);
+    label->setWordWrap(true);
+
+    label->show();
+    qDebug() << text;
+
+    app.exec();
+}
+
+#endif
index 8de1f58..a7ea3b4 100644 (file)
@@ -39,6 +39,9 @@
 ****************************************************************************/
 
 #include "window.h"
+
+#ifndef QT_NO_SYSTEMTRAYICON
+
 #include <QtGui>
 
 #include <QAction>
@@ -265,3 +268,5 @@ void Window::createTrayIcon()
     trayIcon = new QSystemTrayIcon(this);
     trayIcon->setContextMenu(trayIconMenu);
 }
+
+#endif
index 2c33812..08919e8 100644 (file)
@@ -42,6 +42,9 @@
 #define WINDOW_H
 
 #include <QSystemTrayIcon>
+
+#ifndef QT_NO_SYSTEMTRAYICON
+
 #include <QDialog>
 
 QT_BEGIN_NAMESPACE
@@ -109,4 +112,6 @@ private:
 };
 //! [0]
 
+#endif // QT_NO_SYSTEMTRAYICON
+
 #endif