4217f7e06fbe86c01037b1dffb871a79a7122d32
[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     };
52     QString programName;
53     Mode mode;
54     QSystemTrayIcon *trayIcon;
55 #ifdef USE_DBUS
56     QDBusInterface *interface;
57
58     void notifyDBus(Class cls, const QString &title, const QString &text, const QIcon &icon, int millisTimeout);
59 #endif
60     void notifySystray(Class cls, const QString &title, const QString &text, const QIcon &icon, int millisTimeout);
61 };
62
63 #endif // NOTIFICATOR_H