PIVX Core  5.6.99
P2P Digital Currency
notificator.h
Go to the documentation of this file.
1 // Copyright (c) 2011-2013 The Bitcoin developers
2 // Copyright (c) 2017-2019 The PIVX Core developers
3 // Distributed under the MIT/X11 software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #ifndef PIVX_QT_NOTIFICATOR_H
7 #define PIVX_QT_NOTIFICATOR_H
8 
9 #if defined(HAVE_CONFIG_H)
10 #include "config/pivx-config.h"
11 #endif
12 
13 #include <QIcon>
14 #include <QObject>
15 
16 QT_BEGIN_NAMESPACE
17 class QSystemTrayIcon;
18 
19 #ifdef USE_DBUS
20 class QDBusInterface;
21 #endif
22 QT_END_NAMESPACE
23 
25 class Notificator : public QObject
26 {
27  Q_OBJECT
28 
29 public:
33  Notificator(const QString& programName, QSystemTrayIcon* trayIcon, QWidget* parent);
34  ~Notificator();
35 
36  // Message class
37  enum Class {
40  Critical
41  };
42 
43 public Q_SLOTS:
52  void notify(Class cls, const QString& title, const QString& text, const QIcon& icon = QIcon(), int millisTimeout = 10000);
53 
54 private:
55  QWidget* parent;
56  enum Mode {
57  None,
61  };
62  QString programName;
64  QSystemTrayIcon* trayIcon;
65 #ifdef USE_DBUS
66  QDBusInterface* interface;
67 
68  void notifyDBus(Class cls, const QString& title, const QString& text, const QIcon& icon, int millisTimeout);
69 #endif
70  void notifySystray(Class cls, const QString& title, const QString& text, const QIcon& icon, int millisTimeout);
71 #ifdef Q_OS_MAC
72  void notifyMacUserNotificationCenter(Class cls, const QString& title, const QString& text, const QIcon& icon);
73 #endif
74 };
75 
76 #endif // PIVX_QT_NOTIFICATOR_H
Cross-platform desktop notification client.
Definition: notificator.h:26
QString programName
Definition: notificator.h:62
QWidget * parent
Definition: notificator.h:55
@ Information
Informational message.
Definition: notificator.h:38
@ Critical
An error occurred.
Definition: notificator.h:40
@ Warning
Notify user of potential problem.
Definition: notificator.h:39
@ UserNotificationCenter
Use the 10.8+ User Notification Center (Mac only)
Definition: notificator.h:60
@ QSystemTray
Use QSystemTray::showMessage.
Definition: notificator.h:59
@ Freedesktop
Use DBus org.freedesktop.Notifications.
Definition: notificator.h:58
@ None
Ignore informational notifications, and show a modal pop-up dialog for Critical notifications.
Definition: notificator.h:57
void notifySystray(Class cls, const QString &title, const QString &text, const QIcon &icon, int millisTimeout)
Notificator(const QString &programName, QSystemTrayIcon *trayIcon, QWidget *parent)
Create a new notificator.
Definition: notificator.cpp:31
QSystemTrayIcon * trayIcon
Definition: notificator.h:64
void notify(Class cls, const QString &title, const QString &text, const QIcon &icon=QIcon(), int millisTimeout=10000)
Show notification message.