Changeset View
Changeset View
Standalone View
Standalone View
applets/notifications/package/contents/ui/Notifications.qml
Show All 14 Lines | |||||
15 | * License along with this program; if not, write to the | 15 | * License along with this program; if not, write to the | ||
16 | * Free Software Foundation, Inc., | 16 | * Free Software Foundation, Inc., | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
18 | */ | 18 | */ | ||
19 | 19 | | |||
20 | import QtQuick 2.0 | 20 | import QtQuick 2.0 | ||
21 | import org.kde.plasma.core 2.0 as PlasmaCore | 21 | import org.kde.plasma.core 2.0 as PlasmaCore | ||
22 | import org.kde.plasma.components 2.0 as PlasmaComponents | 22 | import org.kde.plasma.components 2.0 as PlasmaComponents | ||
23 | import org.kde.plasma.extras 2.0 as PlasmaExtras | ||||
23 | 24 | | |||
24 | import org.kde.plasma.private.notifications 1.0 | 25 | import org.kde.plasma.private.notifications 1.0 | ||
25 | 26 | | |||
26 | 27 | | |||
27 | Column { | 28 | Column { | ||
28 | id: notificationsRoot | 29 | id: notificationsRoot | ||
29 | anchors { | 30 | anchors { | ||
30 | left: parent.left | 31 | left: parent.left | ||
31 | right: parent.right | 32 | right: parent.right | ||
32 | } | 33 | } | ||
33 | 34 | | |||
34 | property alias count: notificationsRepeater.count | 35 | property alias count: notificationsRepeater.count | ||
36 | property alias historyCount: notificationsHistoryRepeater.count | ||||
37 | | ||||
38 | property bool showHistory | ||||
39 | | ||||
35 | signal popupShown(var popup) | 40 | signal popupShown(var popup) | ||
36 | 41 | | |||
42 | onShowHistoryChanged: { | ||||
43 | if(!showHistory) | ||||
44 | clearHistory() | ||||
45 | } | ||||
46 | | ||||
37 | Component.onCompleted: { | 47 | Component.onCompleted: { | ||
38 | // Create the popup components and pass them to the C++ plugin | 48 | // Create the popup components and pass them to the C++ plugin | ||
39 | for (var i = 0; i < 3; i++) { | 49 | for (var i = 0; i < 3; i++) { | ||
40 | var popup = notificationPopupComponent.createObject(); | 50 | var popup = notificationPopupComponent.createObject(); | ||
41 | notificationPositioner.addNotificationPopup(popup); | 51 | notificationPositioner.addNotificationPopup(popup); | ||
42 | } | 52 | } | ||
43 | } | 53 | } | ||
44 | 54 | | |||
Show All 24 Lines | 55 | function addNotification(notification) { | |||
69 | 79 | | |||
70 | if (notification.isPersistent) { | 80 | if (notification.isPersistent) { | ||
71 | notification.created = new Date(); | 81 | notification.created = new Date(); | ||
72 | 82 | | |||
73 | notificationsModel.inserting = true; | 83 | notificationsModel.inserting = true; | ||
74 | notificationsModel.insert(0, notification); | 84 | notificationsModel.insert(0, notification); | ||
75 | notificationsModel.inserting = false; | 85 | notificationsModel.inserting = false; | ||
76 | } | 86 | } | ||
87 | else if (showHistory) { | ||||
88 | | ||||
89 | notificationsHistoryModel.inserting = true; | ||||
90 | | ||||
91 | //create a copy of the notification. | ||||
92 | //Disable actions in this copy as they will stop working once the original notification ist closed. | ||||
davidedmundson: *is | |||||
93 | notificationsHistoryModel.insert(0, { | ||||
94 | "compact" : notification.compact, | ||||
95 | "icon" : notification.icon, | ||||
96 | "image" : notification.image, | ||||
97 | "summary" : notification.summary, | ||||
98 | "body" : notification.body, | ||||
99 | "configurable" : false, | ||||
100 | "created" : new Date(), | ||||
101 | "urls" : notification.urls, | ||||
102 | "maximumTextHeight" : notification.maximumTextHeight, | ||||
103 | "actions" : null, | ||||
104 | "hasDefaultAction" : false, | ||||
105 | "hasConfigureAction" : false, | ||||
106 | }); | ||||
107 | notificationsHistoryModel.inserting = false; | ||||
108 | } | ||||
77 | 109 | | |||
78 | notificationPositioner.displayNotification(notification); | 110 | notificationPositioner.displayNotification(notification); | ||
79 | } | 111 | } | ||
80 | 112 | | |||
81 | function executeAction(source, id) { | 113 | function executeAction(source, id) { | ||
82 | //try to use the service | 114 | //try to use the service | ||
83 | if (id.indexOf("jobUrl#") === -1) { | 115 | if (id.indexOf("jobUrl#") === -1) { | ||
84 | var service = notificationsSource.serviceForSource(source) | 116 | var service = notificationsSource.serviceForSource(source) | ||
Show All 39 Lines | |||||
124 | function clearNotifications() { | 156 | function clearNotifications() { | ||
125 | for (var i = 0, length = notificationsSource.sources.length; i < length; ++i) { | 157 | for (var i = 0, length = notificationsSource.sources.length; i < length; ++i) { | ||
126 | var source = notificationsSource.sources[i]; | 158 | var source = notificationsSource.sources[i]; | ||
127 | closeNotification(source) | 159 | closeNotification(source) | ||
128 | notificationPositioner.closePopup(source); | 160 | notificationPositioner.closePopup(source); | ||
129 | } | 161 | } | ||
130 | 162 | | |||
131 | notificationsModel.clear() | 163 | notificationsModel.clear() | ||
164 | clearHistory() | ||||
165 | } | ||||
166 | | ||||
167 | function clearHistory() { | ||||
168 | notificationsHistoryModel.clear() | ||||
132 | } | 169 | } | ||
133 | 170 | | |||
134 | Component { | 171 | Component { | ||
135 | id: notificationPopupComponent | 172 | id: notificationPopupComponent | ||
136 | NotificationPopup { } | 173 | NotificationPopup { } | ||
137 | } | 174 | } | ||
138 | 175 | | |||
139 | ListModel { | 176 | ListModel { | ||
140 | id: notificationsModel | 177 | id: notificationsModel | ||
141 | property bool inserting: false | 178 | property bool inserting: false | ||
142 | } | 179 | } | ||
143 | 180 | | |||
181 | ListModel { | ||||
182 | id: notificationsHistoryModel | ||||
183 | property bool inserting: false | ||||
184 | } | ||||
185 | | ||||
144 | PlasmaCore.DataSource { | 186 | PlasmaCore.DataSource { | ||
145 | id: idleTimeSource | 187 | id: idleTimeSource | ||
146 | 188 | | |||
147 | property bool idle: data["UserActivity"]["IdleTime"] > 300000 | 189 | property bool idle: data["UserActivity"]["IdleTime"] > 300000 | ||
148 | 190 | | |||
149 | engine: "powermanagement" | 191 | engine: "powermanagement" | ||
150 | interval: 30000 | 192 | interval: 30000 | ||
151 | connectedSources: ["UserActivity"] | 193 | connectedSources: ["UserActivity"] | ||
▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Line(s) | |||||
209 | 251 | | |||
210 | NotificationsHelper { | 252 | NotificationsHelper { | ||
211 | id: notificationPositioner | 253 | id: notificationPositioner | ||
212 | popupLocation: plasmoid.nativeInterface.screenPosition | 254 | popupLocation: plasmoid.nativeInterface.screenPosition | ||
213 | 255 | | |||
214 | Component.onCompleted: { | 256 | Component.onCompleted: { | ||
215 | notificationPositioner.setPlasmoidScreenGeometry(plasmoid.nativeInterface.availableScreenRect); | 257 | notificationPositioner.setPlasmoidScreenGeometry(plasmoid.nativeInterface.availableScreenRect); | ||
216 | } | 258 | } | ||
217 | onPopupShown: notificationsRoot.popupShown(popup) | 259 | onPopupShown: notificationsRoot.popupShown(popup) | ||
davidedmundson: ? | |||||
progwolff: sorry, missed to revert this... | |||||
218 | } | 260 | } | ||
219 | 261 | | |||
220 | Repeater { | 262 | Repeater { | ||
221 | id: notificationsRepeater | 263 | id: notificationsRepeater | ||
222 | model: notificationsModel | 264 | model: notificationsModel | ||
223 | delegate: NotificationDelegate {} | 265 | delegate: NotificationDelegate { listModel: notificationsModel } | ||
266 | } | ||||
267 | | ||||
268 | PlasmaExtras.Heading { | ||||
269 | width: parent.width | ||||
270 | level: 3 | ||||
271 | opacity: 0.6 | ||||
272 | visible: historyCount > 0 | ||||
273 | text: i18n("History") | ||||
274 | } | ||||
275 | | ||||
276 | Repeater { | ||||
277 | id: notificationsHistoryRepeater | ||||
278 | model: notificationsHistoryModel | ||||
279 | delegate: NotificationDelegate { listModel: notificationsHistoryModel } | ||||
224 | } | 280 | } | ||
225 | } | 281 | } | ||
How does this differ to the persistent delegate? Can we share most of this? davidedmundson: How does this differ to the persistent delegate?
Can we share most of this? | |||||
It's almost the same. Only the models differ (NotificationsModel is used in NotificationDelegate, NotificationsHistoryModel is used in NotificationHistoryDelegate). I also thought it might be a good idea to use a seperate delegates here, so that in the future history items might have a different visual representation than persistent notifications. If this is not wanted, we could probably make the model a property of NotificationDelegate. progwolff: It's almost the same. Only the models differ (NotificationsModel is used in… | |||||
I don't think we would ever want a different visual representation for them, i would consider that a bug, as the thing looks quite busy already. they can be the same file with just a different model property assigned mart: I don't think we would ever want a different visual representation for them, i would consider… |
*is