2018-01-02 18:12:05 +01:00
|
|
|
// Copyright (c) 2011-2017 The Bitcoin Core developers
|
2014-12-13 05:09:33 +01:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
2013-11-04 16:20:43 +01:00
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
2014-11-03 16:16:40 +01:00
|
|
|
#ifndef BITCOIN_QT_NOTIFICATOR_H
|
|
|
|
#define BITCOIN_QT_NOTIFICATOR_H
|
2011-09-03 20:52:54 +02:00
|
|
|
|
2013-05-28 01:55:01 +02:00
|
|
|
#if defined(HAVE_CONFIG_H)
|
2017-11-10 01:57:53 +01:00
|
|
|
#include <config/bitcoin-config.h>
|
2013-05-28 01:55:01 +02:00
|
|
|
#endif
|
|
|
|
|
2011-09-03 20:52:54 +02:00
|
|
|
#include <QIcon>
|
2013-04-13 07:13:08 +02:00
|
|
|
#include <QObject>
|
2011-09-03 20:52:54 +02:00
|
|
|
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
class QSystemTrayIcon;
|
2013-04-13 07:13:08 +02:00
|
|
|
|
2011-09-24 11:56:33 +02:00
|
|
|
#ifdef USE_DBUS
|
2011-09-03 20:52:54 +02:00
|
|
|
class QDBusInterface;
|
|
|
|
#endif
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
2011-11-13 13:19:52 +01:00
|
|
|
/** Cross-platform desktop notification client. */
|
2011-09-03 20:52:54 +02:00
|
|
|
class Notificator: public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2013-01-23 21:51:02 +01:00
|
|
|
|
2011-09-03 20:52:54 +02:00
|
|
|
public:
|
2011-11-13 13:19:52 +01:00
|
|
|
/** Create a new notificator.
|
|
|
|
@note Ownership of trayIcon is not transferred to this object.
|
|
|
|
*/
|
2013-12-03 09:25:24 +01:00
|
|
|
Notificator(const QString &programName, QSystemTrayIcon *trayIcon, QWidget *parent);
|
2011-09-03 20:52:54 +02:00
|
|
|
~Notificator();
|
|
|
|
|
|
|
|
// Message class
|
|
|
|
enum Class
|
|
|
|
{
|
2013-01-23 21:51:02 +01:00
|
|
|
Information, /**< Informational message */
|
|
|
|
Warning, /**< Notify user of potential problem */
|
|
|
|
Critical /**< An error occurred */
|
2011-09-03 20:52:54 +02:00
|
|
|
};
|
|
|
|
|
2015-07-14 13:59:05 +02:00
|
|
|
public Q_SLOTS:
|
2011-11-13 13:19:52 +01:00
|
|
|
/** Show notification message.
|
|
|
|
@param[in] cls general message class
|
|
|
|
@param[in] title title shown with message
|
|
|
|
@param[in] text message content
|
|
|
|
@param[in] icon optional icon to show with message
|
|
|
|
@param[in] millisTimeout notification timeout in milliseconds (defaults to 10 seconds)
|
|
|
|
@note Platform implementations are free to ignore any of the provided fields except for \a text.
|
2011-09-03 20:52:54 +02:00
|
|
|
*/
|
|
|
|
void notify(Class cls, const QString &title, const QString &text,
|
|
|
|
const QIcon &icon = QIcon(), int millisTimeout = 10000);
|
|
|
|
|
|
|
|
private:
|
|
|
|
QWidget *parent;
|
|
|
|
enum Mode {
|
2013-05-10 22:20:51 +02:00
|
|
|
None, /**< Ignore informational notifications, and show a modal pop-up dialog for Critical notifications. */
|
|
|
|
Freedesktop, /**< Use DBus org.freedesktop.Notifications */
|
|
|
|
QSystemTray, /**< Use QSystemTray::showMessage */
|
|
|
|
UserNotificationCenter /**< Use the 10.8+ User Notification Center (Mac only) */
|
2011-09-03 20:52:54 +02:00
|
|
|
};
|
|
|
|
QString programName;
|
|
|
|
Mode mode;
|
|
|
|
QSystemTrayIcon *trayIcon;
|
2011-09-24 11:56:33 +02:00
|
|
|
#ifdef USE_DBUS
|
2011-09-03 20:52:54 +02:00
|
|
|
QDBusInterface *interface;
|
|
|
|
|
|
|
|
void notifyDBus(Class cls, const QString &title, const QString &text, const QIcon &icon, int millisTimeout);
|
|
|
|
#endif
|
|
|
|
void notifySystray(Class cls, const QString &title, const QString &text, const QIcon &icon, int millisTimeout);
|
2012-09-21 19:06:53 +02:00
|
|
|
#ifdef Q_OS_MAC
|
2013-05-10 22:20:51 +02:00
|
|
|
void notifyMacUserNotificationCenter(Class cls, const QString &title, const QString &text, const QIcon &icon);
|
2011-10-07 13:21:45 +02:00
|
|
|
#endif
|
2011-09-03 20:52:54 +02:00
|
|
|
};
|
|
|
|
|
2014-11-03 16:16:40 +01:00
|
|
|
#endif // BITCOIN_QT_NOTIFICATOR_H
|