1 #ifndef MISC_UTILS_NOTIFICATION_H 2 #define MISC_UTILS_NOTIFICATION_H 9 QT_FORWARD_DECLARE_CLASS(QDBusPendingCallWatcher)
11 class OrgFreedesktopNotificationsInterface;
21 Q_PROPERTY(QString title READ title WRITE setTitle)
22 Q_PROPERTY(QString message READ message WRITE setMessage)
23 Q_PROPERTY(QString icon READ icon WRITE setIcon)
24 Q_PROPERTY(
int timeout READ timeout WRITE setTimeout)
25 Q_PROPERTY(QStringList actions READ actions WRITE setActions)
26 Q_PROPERTY(
bool visible READ isVisible)
31 explicit
DBusNotification(const QString &title, const QString &icon,
int timeout = 10000, QObject *parent =
nullptr);
34 static
bool isAvailable();
35 const QString &title() const;
36 void setTitle(const QString &title);
37 const QString &message() const;
38 void setMessage(const QString &message);
39 const QString &icon() const;
40 void setIcon(const QString &icon);
43 void setTimeout(
int timeout);
44 const QStringList &actions() const;
45 void setActions(const QStringList &actions);
46 const QVariantMap &hints() const;
48 bool isVisible() const;
49 void deleteOnCloseOrError();
53 bool show(const QString &message);
54 bool update(const QString &line);
65 void actionInvoked(const QString &action);
68 void handleNotifyResult(QDBusPendingCallWatcher *);
69 static
void handleNotificationClosed(uint
id, uint reason);
70 static
void handleActionInvoked(uint
id, const QString &action);
73 static
void initInterface();
76 QDBusPendingCallWatcher *m_watcher;
81 QStringList m_actions;
83 static OrgFreedesktopNotificationsInterface *m_dbusInterface;
176 #endif // MISC_UTILS_NOTIFICATION_H void setIcon(const QString &icon)
Sets the icon name.
void setActions(const QStringList &actions)
Sets the actions for the notification.
void setMessage(const QString &message)
Sets the message to be shown.
#define QT_UTILITIES_EXPORT
Marks the symbol to be exported by the qtutilities library.
bool isVisible() const
Returns whether the notification is (still) visible.
void setTitle(const QString &title)
void setTimeout(int timeout)
Sets the number of milliseconds the notification will be visible after calling show().
const QStringList & actions() const
const QVariantMap & hints() const
The DBusNotification class emits D-Bus notifications.
const QString & icon() const
const QString & message() const