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);
42 const QImage image() const;
43 void setImage(const QImage &image);
44 const QString imagePath() const;
45 void setImagePath(const QString &imagePath);
47 void setTimeout(
int timeout);
48 const QStringList &actions() const;
49 void setActions(const QStringList &actions);
50 const QVariantMap &hints() const;
52 QVariant hint(const QString &name) const;
53 QVariant hint(const QString &name, const QString &fallbackNames...) const;
54 bool isVisible() const;
55 void deleteOnCloseOrError();
59 bool show(const QString &message);
60 bool update(const QString &line);
71 void actionInvoked(const QString &action);
74 void handleNotifyResult(QDBusPendingCallWatcher *);
75 static
void handleNotificationClosed(uint
id, uint reason);
76 static
void handleActionInvoked(uint
id, const QString &action);
79 static
void initInterface();
82 QDBusPendingCallWatcher *m_watcher;
87 QStringList m_actions;
89 static OrgFreedesktopNotificationsInterface *m_dbusInterface;
137 return m_hints[name];
145 const auto variant(m_hints[name]);
146 return variant.isNull() ? this->hint(fallbackNames) : variant;
155 return hint(QStringLiteral(
"image-data"), QStringLiteral(
"image_path")).toString();
165 m_hints[QStringLiteral(
"image-path")] = imagePath;
218 #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.
const QString imagePath() const
Returns the image path.
void setMessage(const QString &message)
Sets the message to be shown.
QVariant hint(const QString &name) const
Returns the hint with the specified name.
#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.
void setImagePath(const QString &imagePath)
Sets the image path.
const QString & icon() const
const QString & message() const