Changeset View
Changeset View
Standalone View
Standalone View
libnotificationmanager/server.h
Show All 34 Lines | |||||
35 | * @short A notification DBus server | 35 | * @short A notification DBus server | ||
36 | * | 36 | * | ||
37 | * @author Kai Uwe Broulik <kde@privat.broulik.de> | 37 | * @author Kai Uwe Broulik <kde@privat.broulik.de> | ||
38 | **/ | 38 | **/ | ||
39 | class NOTIFICATIONMANAGER_EXPORT Server : public QObject | 39 | class NOTIFICATIONMANAGER_EXPORT Server : public QObject | ||
40 | { | 40 | { | ||
41 | Q_OBJECT | 41 | Q_OBJECT | ||
42 | 42 | | |||
43 | /** | ||||
44 | * Whether notifications are currently inhibited. | ||||
45 | * | ||||
46 | * This is what is announced to other applicatons on the bus. | ||||
47 | * | ||||
48 | * @note This does not keep track of inhibitions on its own, | ||||
49 | * you need to calculate this yourself and update the property accordingly. | ||||
davidedmundson: Having a property which doesn't read what you last wrote leads to very confusing QML. Sure you… | |||||
50 | */ | ||||
51 | Q_PROPERTY(bool inhibited READ inhibited WRITE setInhibited NOTIFY inhibitedChanged) | ||||
52 | | ||||
43 | public: | 53 | public: | ||
44 | ~Server() override; | 54 | ~Server() override; | ||
45 | 55 | | |||
46 | /** | 56 | /** | ||
47 | * The reason a notification was closed | 57 | * The reason a notification was closed | ||
48 | */ | 58 | */ | ||
49 | enum class CloseReason { | 59 | enum class CloseReason { | ||
50 | Expired = 1, ///< The notification timed out | 60 | Expired = 1, ///< The notification timed out | ||
Show All 12 Lines | |||||
63 | bool init(); | 73 | bool init(); | ||
64 | 74 | | |||
65 | /** | 75 | /** | ||
66 | * Whether the notification service could be registered | 76 | * Whether the notification service could be registered | ||
67 | */ | 77 | */ | ||
68 | bool isValid() const; | 78 | bool isValid() const; | ||
69 | 79 | | |||
70 | /** | 80 | /** | ||
71 | * Whether an application requested to inhibit notifications. | 81 | * Whether notifications are currently inhibited. | ||
82 | * @since 5.17 | ||||
72 | */ | 83 | */ | ||
73 | bool inhibited() const; | 84 | bool inhibited() const; | ||
74 | 85 | | |||
86 | /** | ||||
87 | * Whether notifications are currently effectively inhibited. | ||||
88 | * | ||||
89 | * @note You need to keep track of inhibitions and call this | ||||
90 | * yourself when appropriate. | ||||
91 | * @since 5.17 | ||||
92 | */ | ||||
93 | void setInhibited(bool inhibited); | ||||
94 | | ||||
95 | /** | ||||
96 | * Whether an application requested to inhibit notifications. | ||||
97 | */ | ||||
98 | bool inhibitedByApplication() const; | ||||
99 | | ||||
75 | // should we return a struct or pair or something? | 100 | // should we return a struct or pair or something? | ||
76 | QStringList inhibitionApplications() const; | 101 | QStringList inhibitionApplications() const; | ||
77 | QStringList inhibitionReasons() const; | 102 | QStringList inhibitionReasons() const; | ||
78 | 103 | | |||
79 | /** | 104 | /** | ||
80 | * Remove all inhibitions. | 105 | * Remove all inhibitions. | ||
81 | * | 106 | * | ||
82 | * @note The applications are not explicitly informed about this. | 107 | * @note The applications are not explicitly informed about this. | ||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Line(s) | 136 | Q_SIGNALS: | |||
125 | /** | 150 | /** | ||
126 | * Emitted when a notification got removed (closed) | 151 | * Emitted when a notification got removed (closed) | ||
127 | * @param id The notification ID | 152 | * @param id The notification ID | ||
128 | * @param reason The reason why it was closed | 153 | * @param reason The reason why it was closed | ||
129 | */ | 154 | */ | ||
130 | void notificationRemoved(uint id, CloseReason reason); | 155 | void notificationRemoved(uint id, CloseReason reason); | ||
131 | 156 | | |||
132 | /** | 157 | /** | ||
133 | * Emitted when inhibitions have been changed. Becomes true | 158 | * Emitted when the inhbited state changed. | ||
134 | * as soon as there is one inhibition and becomes false again | | |||
135 | * when all inhibitions have been lifted. | | |||
136 | */ | 159 | */ | ||
137 | void inhibitedChanged(bool inhibited); | 160 | void inhibitedChanged(bool inhibited); | ||
138 | 161 | | |||
139 | /** | 162 | /** | ||
163 | * Emitted when inhibitions by application have been changed. | ||||
164 | * Becomes true as soon as there is one inhibition and becomes | ||||
165 | * false again when all inhibitions have been lifted. | ||||
166 | * @since 5.17 | ||||
167 | */ | ||||
168 | void inhibitedByApplicationChanged(bool inhibited); | ||||
169 | | ||||
170 | /** | ||||
140 | * Emitted when the list of applications holding a notification | 171 | * Emitted when the list of applications holding a notification | ||
141 | * inhibition changes. | 172 | * inhibition changes. | ||
142 | * Normally you would only want to listen do @c inhibitedChanged | 173 | * Normally you would only want to listen do @c inhibitedChanged | ||
143 | */ | 174 | */ | ||
144 | void inhibitionApplicationsChanged(); | 175 | void inhibitionApplicationsChanged(); | ||
145 | 176 | | |||
146 | /** | 177 | /** | ||
147 | * Emitted when the ownership of the Notification DBus Service is lost. | 178 | * Emitted when the ownership of the Notification DBus Service is lost. | ||
Show All 12 Lines |
Having a property which doesn't read what you last wrote leads to very confusing QML. Sure you can make it work, but it won't be declarative.
What Server::Private has internally with the 3 inhibtedLocally, inhibitedExternally, and then the read-only effectiveInhibited value is a really neat and tidy design.
Can't we map that directly to the public API and properties here?