aboutsummaryrefslogtreecommitdiff
path: root/src/qt/notificator.h
diff options
context:
space:
mode:
authorGavin Andresen <gavinandresen@gmail.com>2011-09-26 06:05:11 -0700
committerGavin Andresen <gavinandresen@gmail.com>2011-09-26 06:05:11 -0700
commitf7f2a36925bb560363f691fc3ca3dec83830dd15 (patch)
treec09327d910abe4e7947c53dcbb5f15b01ab194c1 /src/qt/notificator.h
parentf8937b2d3bb545a0a6ff78031ce3cdcb3208ecbe (diff)
parent0465c41c847ddee7eeb5caefb164149400ff8395 (diff)
Merge pull request #521 from laanwj/qt
Qt GUI
Diffstat (limited to 'src/qt/notificator.h')
-rw-r--r--src/qt/notificator.h63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/qt/notificator.h b/src/qt/notificator.h
new file mode 100644
index 0000000000..13f6a908da
--- /dev/null
+++ b/src/qt/notificator.h
@@ -0,0 +1,63 @@
+#ifndef NOTIFICATOR_H
+#define NOTIFICATOR_H
+
+#include <QObject>
+#include <QIcon>
+
+QT_BEGIN_NAMESPACE
+class QSystemTrayIcon;
+#ifdef QT_DBUS
+class QDBusInterface;
+#endif
+QT_END_NAMESPACE
+
+// Cross-platform desktop notification client
+class Notificator: public QObject
+{
+ Q_OBJECT
+public:
+ // Create a new notificator
+ // Ownership of trayIcon is not transferred to this object
+ Notificator(const QString &programName=QString(), QSystemTrayIcon *trayIcon=0, QWidget *parent=0);
+ ~Notificator();
+
+ // Message class
+ enum Class
+ {
+ Information,
+ Warning,
+ Critical,
+ };
+
+public slots:
+
+ /* Show notification message.
+ *
+ * cls: general message class
+ * title: title shown with message
+ * text: message content
+ * icon: optional icon to show with message
+ * millisTimeout: notification timeout in milliseconds (default 10 seconds)
+ */
+ void notify(Class cls, const QString &title, const QString &text,
+ const QIcon &icon = QIcon(), int millisTimeout = 10000);
+
+private:
+ QWidget *parent;
+ enum Mode {
+ None,
+ Freedesktop, // Use DBus org.freedesktop.Notifications
+ QSystemTray, // Use QSystemTray::showMessage
+ };
+ QString programName;
+ Mode mode;
+ QSystemTrayIcon *trayIcon;
+#ifdef QT_DBUS
+ QDBusInterface *interface;
+
+ void notifyDBus(Class cls, const QString &title, const QString &text, const QIcon &icon, int millisTimeout);
+#endif
+ void notifySystray(Class cls, const QString &title, const QString &text, const QIcon &icon, int millisTimeout);
+};
+
+#endif // NOTIFICATOR_H