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