Changeset View
Changeset View
Standalone View
Standalone View
applets/notifications/package/contents/ui/Notifications.qml
Show All 26 Lines | |||||
27 | Column { | 27 | Column { | ||
28 | id: notificationsRoot | 28 | id: notificationsRoot | ||
29 | anchors { | 29 | anchors { | ||
30 | left: parent.left | 30 | left: parent.left | ||
31 | right: parent.right | 31 | right: parent.right | ||
32 | } | 32 | } | ||
33 | 33 | | |||
34 | property alias count: notificationsRepeater.count | 34 | property alias count: notificationsRepeater.count | ||
35 | property alias historyCount: notificationsHistoryRepeater.count | ||||
36 | | ||||
37 | property bool showHistory | ||||
38 | | ||||
35 | signal popupShown(var popup) | 39 | signal popupShown(var popup) | ||
36 | 40 | | |||
41 | onShowHistoryChanged: { | ||||
42 | if(!showHistory) | ||||
43 | clearHistory() | ||||
44 | } | ||||
45 | | ||||
37 | Component.onCompleted: { | 46 | Component.onCompleted: { | ||
38 | // Create the popup components and pass them to the C++ plugin | 47 | // Create the popup components and pass them to the C++ plugin | ||
39 | for (var i = 0; i < 3; i++) { | 48 | for (var i = 0; i < 3; i++) { | ||
40 | var popup = notificationPopupComponent.createObject(); | 49 | var popup = notificationPopupComponent.createObject(); | ||
41 | notificationPositioner.addNotificationPopup(popup); | 50 | notificationPositioner.addNotificationPopup(popup); | ||
42 | } | 51 | } | ||
43 | } | 52 | } | ||
44 | 53 | | |||
Show All 24 Lines | 54 | function addNotification(notification) { | |||
69 | 78 | | |||
70 | if (notification.isPersistent) { | 79 | if (notification.isPersistent) { | ||
71 | notification.created = new Date(); | 80 | notification.created = new Date(); | ||
72 | 81 | | |||
73 | notificationsModel.inserting = true; | 82 | notificationsModel.inserting = true; | ||
74 | notificationsModel.insert(0, notification); | 83 | notificationsModel.insert(0, notification); | ||
75 | notificationsModel.inserting = false; | 84 | notificationsModel.inserting = false; | ||
76 | } | 85 | } | ||
86 | else if (showHistory) { | ||||
87 | notification.created = new Date(); | ||||
88 | | ||||
89 | notificationsHistoryModel.inserting = true; | ||||
90 | notificationsHistoryModel.insert(0, notification); | ||||
91 | notificationsHistoryModel.inserting = false; | ||||
davidedmundson: *is | |||||
92 | } | ||||
77 | 93 | | |||
78 | notificationPositioner.displayNotification(notification); | 94 | notificationPositioner.displayNotification(notification); | ||
79 | } | 95 | } | ||
80 | 96 | | |||
81 | function executeAction(source, id) { | 97 | function executeAction(source, id) { | ||
82 | //try to use the service | 98 | //try to use the service | ||
83 | if (id.indexOf("jobUrl#") === -1) { | 99 | if (id.indexOf("jobUrl#") === -1) { | ||
84 | var service = notificationsSource.serviceForSource(source) | 100 | var service = notificationsSource.serviceForSource(source) | ||
Show All 39 Lines | |||||
124 | function clearNotifications() { | 140 | function clearNotifications() { | ||
125 | for (var i = 0, length = notificationsSource.sources.length; i < length; ++i) { | 141 | for (var i = 0, length = notificationsSource.sources.length; i < length; ++i) { | ||
126 | var source = notificationsSource.sources[i]; | 142 | var source = notificationsSource.sources[i]; | ||
127 | closeNotification(source) | 143 | closeNotification(source) | ||
128 | notificationPositioner.closePopup(source); | 144 | notificationPositioner.closePopup(source); | ||
129 | } | 145 | } | ||
130 | 146 | | |||
131 | notificationsModel.clear() | 147 | notificationsModel.clear() | ||
148 | clearHistory() | ||||
149 | } | ||||
150 | | ||||
151 | function clearHistory() { | ||||
152 | notificationsHistoryModel.clear() | ||||
132 | } | 153 | } | ||
133 | 154 | | |||
134 | Component { | 155 | Component { | ||
135 | id: notificationPopupComponent | 156 | id: notificationPopupComponent | ||
136 | NotificationPopup { } | 157 | NotificationPopup { } | ||
137 | } | 158 | } | ||
138 | 159 | | |||
139 | ListModel { | 160 | ListModel { | ||
140 | id: notificationsModel | 161 | id: notificationsModel | ||
141 | property bool inserting: false | 162 | property bool inserting: false | ||
142 | } | 163 | } | ||
143 | 164 | | |||
165 | ListModel { | ||||
166 | id: notificationsHistoryModel | ||||
167 | property bool inserting: false | ||||
168 | } | ||||
169 | | ||||
144 | PlasmaCore.DataSource { | 170 | PlasmaCore.DataSource { | ||
145 | id: idleTimeSource | 171 | id: idleTimeSource | ||
146 | 172 | | |||
147 | property bool idle: data["UserActivity"]["IdleTime"] > 300000 | 173 | property bool idle: data["UserActivity"]["IdleTime"] > 300000 | ||
148 | 174 | | |||
149 | engine: "powermanagement" | 175 | engine: "powermanagement" | ||
150 | interval: 30000 | 176 | interval: 30000 | ||
151 | connectedSources: ["UserActivity"] | 177 | connectedSources: ["UserActivity"] | ||
▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Line(s) | |||||
209 | 235 | | |||
210 | NotificationsHelper { | 236 | NotificationsHelper { | ||
211 | id: notificationPositioner | 237 | id: notificationPositioner | ||
212 | popupLocation: plasmoid.nativeInterface.screenPosition | 238 | popupLocation: plasmoid.nativeInterface.screenPosition | ||
213 | 239 | | |||
214 | Component.onCompleted: { | 240 | Component.onCompleted: { | ||
215 | notificationPositioner.setPlasmoidScreenGeometry(plasmoid.nativeInterface.availableScreenRect); | 241 | notificationPositioner.setPlasmoidScreenGeometry(plasmoid.nativeInterface.availableScreenRect); | ||
216 | } | 242 | } | ||
217 | onPopupShown: notificationsRoot.popupShown(popup) | 243 | onPopupShown: notificationsRoot.popupShown(popup) | ||
davidedmundson: ? | |||||
progwolff: sorry, missed to revert this... | |||||
218 | } | 244 | } | ||
219 | 245 | | |||
220 | Repeater { | 246 | Repeater { | ||
221 | id: notificationsRepeater | 247 | id: notificationsRepeater | ||
222 | model: notificationsModel | 248 | model: notificationsModel | ||
223 | delegate: NotificationDelegate {} | 249 | delegate: NotificationDelegate {} | ||
224 | } | 250 | } | ||
251 | | ||||
252 | Repeater { | ||||
253 | anchors.top: notificationsRepeater.bottom | ||||
254 | | ||||
255 | id: notificationsHistoryRepeater | ||||
256 | model: notificationsHistoryModel | ||||
257 | delegate: NotificationHistoryDelegate {} | ||||
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… | |||||
258 | } | ||||
225 | } | 259 | } |
*is