Proper support for Growl 1.3 notifications
[novacoin.git] / src / qt / notificator.h
1 #ifndef NOTIFICATOR_H
2 #define NOTIFICATOR_H
3
4 #include <QObject>
5 #include <QIcon>
6
7 QT_BEGIN_NAMESPACE
8 class QSystemTrayIcon;
9 #ifdef USE_DBUS
10 class QDBusInterface;
11 #endif
12 QT_END_NAMESPACE
13
14 // Cross-platform desktop notification client
15 class Notificator: public QObject
16 {
17     Q_OBJECT
18 public:
19     // Create a new notificator
20     // Ownership of trayIcon is not transferred to this object
21     Notificator(const QString &programName=QString(), QSystemTrayIcon *trayIcon=0, QWidget *parent=0);
22     ~Notificator();
23
24     // Message class
25     enum Class
26     {
27         Information,
28         Warning,
29         Critical,
30     };
31
32 public slots:
33
34     /* Show notification message.
35      *
36      *  cls: general message class
37      *  title: title shown with message
38      *  text: message content
39      *  icon: optional icon to show with message
40      *  millisTimeout: notification timeout in milliseconds (default 10 seconds)
41      */
42     void notify(Class cls, const QString &title, const QString &text,
43                 const QIcon &icon = QIcon(), int millisTimeout = 10000);
44
45 private:
46     QWidget *parent;
47     enum Mode {
48         None,
49         Freedesktop, // Use DBus org.freedesktop.Notifications
50         QSystemTray, // Use QSystemTray::showMessage
51         Growl12, // Use the Growl 1.2 notification system (Mac only)
52         Growl13 // Use the Growl 1.3 notification system (Mac only)
53     };
54     QString programName;
55     Mode mode;
56     QSystemTrayIcon *trayIcon;
57 #ifdef USE_DBUS
58     QDBusInterface *interface;
59
60     void notifyDBus(Class cls, const QString &title, const QString &text, const QIcon &icon, int millisTimeout);
61 #endif
62     void notifySystray(Class cls, const QString &title, const QString &text, const QIcon &icon, int millisTimeout);
63 #ifdef Q_WS_MAC
64     void notifyGrowl(Class cls, const QString &title, const QString &text, const QIcon &icon);
65 #endif
66 };
67
68 #endif // NOTIFICATOR_H