update to 0.4 preview
[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        @note Ownership of trayIcon is not transferred to this object.
21     */
22     Notificator(const QString &programName=QString(), QSystemTrayIcon *trayIcon=0, QWidget *parent=0);
23     ~Notificator();
24
25     // Message class
26     enum Class
27     {
28         Information,         /**< Informational message */
29         Warning,             /**< Notify user of potential problem */
30         Critical             /**< An error occurred */
31     };
32
33 public slots:
34
35     /** Show notification message.
36        @param[in] cls    general message class
37        @param[in] title  title shown with message
38        @param[in] text   message content
39        @param[in] icon   optional icon to show with message
40        @param[in] millisTimeout notification timeout in milliseconds (defaults to 10 seconds)
41        @note Platform implementations are free to ignore any of the provided fields except for \a text.
42      */
43     void notify(Class cls, const QString &title, const QString &text,
44                 const QIcon &icon = QIcon(), int millisTimeout = 10000);
45
46 private:
47     QWidget *parent;
48     enum Mode {
49         None,        /**< Ignore informational notifications, and show a modal pop-up dialog for Critical notifications. */
50         Freedesktop, /**< Use DBus org.freedesktop.Notifications */
51         QSystemTray, /**< Use QSystemTray::showMessage */
52         Growl12,        /**< Use the Growl 1.2 notification system (Mac only) */
53         Growl13        /**< Use the Growl 1.3 notification system (Mac only) */
54     };
55     QString programName;
56     Mode mode;
57     QSystemTrayIcon *trayIcon;
58 #ifdef USE_DBUS
59     QDBusInterface *interface;
60
61     void notifyDBus(Class cls, const QString &title, const QString &text, const QIcon &icon, int millisTimeout);
62 #endif
63     void notifySystray(Class cls, const QString &title, const QString &text, const QIcon &icon, int millisTimeout);
64 #ifdef Q_OS_MAC
65     void notifyGrowl(Class cls, const QString &title, const QString &text, const QIcon &icon);
66 #endif
67 };
68
69 #endif // NOTIFICATOR_H