Phosphor
Qt6 / Wayland library suite for window-management tools
Loading...
Searching...
No Matches
Notification.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 fuddlesworth
2// SPDX-License-Identifier: LGPL-2.1-or-later
3
4#pragma once
5
6#include <PhosphorServiceNotifications/phosphorservicenotifications_export.h>
7
8#include <QDateTime>
9#include <QImage>
10#include <QObject>
11#include <QString>
12#include <QStringList>
13#include <QVariantMap>
14
16
18
35class PHOSPHORSERVICENOTIFICATIONS_EXPORT Notification : public QObject
36{
37 Q_OBJECT
38 Q_PROPERTY(uint id READ id CONSTANT)
39 Q_PROPERTY(QString appName READ appName NOTIFY changed)
40 Q_PROPERTY(QString appIcon READ appIcon NOTIFY changed)
41 Q_PROPERTY(QString summary READ summary NOTIFY changed)
42 Q_PROPERTY(QString body READ body NOTIFY changed)
43 Q_PROPERTY(QStringList actions READ actions NOTIFY changed)
44 Q_PROPERTY(Urgency urgency READ urgency NOTIFY changed)
45 Q_PROPERTY(QString category READ category NOTIFY changed)
46 Q_PROPERTY(QString desktopEntry READ desktopEntry NOTIFY changed)
47 Q_PROPERTY(QImage image READ image NOTIFY changed)
48 Q_PROPERTY(bool hasImage READ hasImage NOTIFY changed)
49 Q_PROPERTY(bool resident READ resident NOTIFY changed)
50 Q_PROPERTY(bool transient READ transient NOTIFY changed)
51 Q_PROPERTY(bool suppressSound READ suppressSound NOTIFY changed)
52 Q_PROPERTY(int value READ value NOTIFY changed)
53 Q_PROPERTY(int expireTimeout READ expireTimeout NOTIFY changed)
54 Q_PROPERTY(QDateTime timestamp READ timestamp NOTIFY changed)
55 Q_PROPERTY(QVariantMap hints READ hints NOTIFY changed)
56
57public:
59 enum Urgency {
60 Low = 0,
61 Normal = 1,
63 };
64 Q_ENUM(Urgency)
65
66 [[nodiscard]] uint id() const
67 {
68 return m_id;
69 }
70 [[nodiscard]] QString appName() const
71 {
72 return m_appName;
73 }
74 [[nodiscard]] QString appIcon() const
75 {
76 return m_appIcon;
77 }
78 [[nodiscard]] QString summary() const
79 {
80 return m_summary;
81 }
82 [[nodiscard]] QString body() const
83 {
84 return m_body;
85 }
86 [[nodiscard]] QStringList actions() const
87 {
88 return m_actions;
89 }
90 [[nodiscard]] Urgency urgency() const
91 {
92 return m_urgency;
93 }
94 [[nodiscard]] QString category() const
95 {
96 return m_category;
97 }
98 [[nodiscard]] QString desktopEntry() const
99 {
100 return m_desktopEntry;
101 }
102 [[nodiscard]] QImage image() const
103 {
104 return m_image;
105 }
106 [[nodiscard]] bool hasImage() const
107 {
108 return !m_image.isNull();
109 }
110 [[nodiscard]] bool resident() const
111 {
112 return m_resident;
113 }
114 [[nodiscard]] bool transient() const
115 {
116 return m_transient;
117 }
118 [[nodiscard]] bool suppressSound() const
119 {
120 return m_suppressSound;
121 }
122
124 [[nodiscard]] int value() const
125 {
126 return m_value;
127 }
128
129 [[nodiscard]] int expireTimeout() const
130 {
131 return m_expireTimeout;
132 }
133
134 [[nodiscard]] QDateTime timestamp() const
135 {
136 return m_timestamp;
137 }
138 [[nodiscard]] QVariantMap hints() const
139 {
140 return m_hints;
141 }
142
143Q_SIGNALS:
147 void changed();
148
149private:
150 Q_DISABLE_COPY_MOVE(Notification)
151 friend class NotificationServer;
152
153 explicit Notification(uint id, QObject* parent = nullptr);
154
155 uint m_id = 0;
156 QString m_appName;
157 QString m_appIcon;
158 QString m_summary;
159 QString m_body;
160 QStringList m_actions;
161 Urgency m_urgency = Normal;
162 QString m_category;
163 QString m_desktopEntry;
164 QImage m_image;
165 bool m_resident = false;
166 bool m_transient = false;
167 bool m_suppressSound = false;
168 int m_value = -1;
169 int m_expireTimeout = -1;
170 QDateTime m_timestamp;
171 QVariantMap m_hints;
172};
173
174} // namespace PhosphorServiceNotifications
The session-bus server for org.freedesktop.Notifications (Desktop Notifications Spec 1....
Definition NotificationServer.h:42
QString desktopEntry() const
Definition Notification.h:98
QString body() const
Definition Notification.h:82
Urgency
Spec urgency levels (the urgency hint, a byte).
Definition Notification.h:59
@ Low
Definition Notification.h:60
@ Normal
Definition Notification.h:61
@ Critical
Definition Notification.h:62
void changed()
Emitted once per replaces_id update: the server re-applies the full field set in place (a replacing N...
QString appIcon() const
Definition Notification.h:74
QString appName() const
Definition Notification.h:70
uint id() const
Definition Notification.h:66
bool transient() const
Definition Notification.h:114
int value() const
The value hint (a progress percentage by convention), or -1 when absent.
Definition Notification.h:124
QImage image() const
Definition Notification.h:102
bool suppressSound() const
Definition Notification.h:118
QString summary() const
Definition Notification.h:78
QString category() const
Definition Notification.h:94
QDateTime timestamp() const
When the notification was first received (does not move on replace).
Definition Notification.h:134
bool resident() const
Definition Notification.h:110
QVariantMap hints() const
Definition Notification.h:138
int expireTimeout() const
The raw expire_timeout from Notify (-1 server-default, 0 never, >0 ms).
Definition Notification.h:129
QStringList actions() const
Definition Notification.h:86
Urgency urgency() const
Definition Notification.h:90
bool hasImage() const
Definition Notification.h:106
friend class NotificationServer
Definition Notification.h:151
Definition Notification.h:15