Changeset View
Changeset View
Standalone View
Standalone View
applets/notifications/package/contents/ui/global/Globals.qml
Show All 23 Lines | |||||
24 | 24 | | |||
25 | import org.kde.plasma.plasmoid 2.0 | 25 | import org.kde.plasma.plasmoid 2.0 | ||
26 | import org.kde.plasma.core 2.0 as PlasmaCore | 26 | import org.kde.plasma.core 2.0 as PlasmaCore | ||
27 | import org.kde.plasma.components 2.0 as Components | 27 | import org.kde.plasma.components 2.0 as Components | ||
28 | import org.kde.kquickcontrolsaddons 2.0 | 28 | import org.kde.kquickcontrolsaddons 2.0 | ||
29 | 29 | | |||
30 | import org.kde.notificationmanager 1.0 as NotificationManager | 30 | import org.kde.notificationmanager 1.0 as NotificationManager | ||
31 | 31 | | |||
32 | import org.kde.plasma.private.notifications 2.0 as Notifications | ||||
33 | | ||||
32 | import ".." | 34 | import ".." | ||
33 | 35 | | |||
34 | // This singleton object contains stuff shared between all notification plasmoids, namely: | 36 | // This singleton object contains stuff shared between all notification plasmoids, namely: | ||
35 | // - Popup creation and placement | 37 | // - Popup creation and placement | ||
36 | // - Do not disturb mode | 38 | // - Do not disturb mode | ||
37 | QtObject { | 39 | QtObject { | ||
38 | id: globals | 40 | id: globals | ||
39 | 41 | | |||
▲ Show 20 Lines • Show All 170 Lines • ▼ Show 20 Line(s) | 200 | globals.inhibited = Qt.binding(function() { | |||
210 | if (notificationSettings.inhibitNotificationsWhenScreensMirrored) { | 212 | if (notificationSettings.inhibitNotificationsWhenScreensMirrored) { | ||
211 | inhibited |= notificationSettings.screensMirrored; | 213 | inhibited |= notificationSettings.screensMirrored; | ||
212 | } | 214 | } | ||
213 | 215 | | |||
214 | return inhibited; | 216 | return inhibited; | ||
215 | }); | 217 | }); | ||
216 | } | 218 | } | ||
217 | 219 | | |||
220 | function revokeInhibitions() { | ||||
221 | notificationSettings.notificationsInhibitedUntil = undefined; | ||||
222 | notificationSettings.revokeApplicationInhibitions(); | ||||
223 | // overrules current mirrored screen setup, updates again when screen configuration changes | ||||
224 | notificationSettings.screensMirrored = false; | ||||
225 | | ||||
226 | notificationSettings.save(); | ||||
227 | } | ||||
228 | | ||||
218 | function rectIntersect(rect1 /*dialog*/, rect2 /*popup*/) { | 229 | function rectIntersect(rect1 /*dialog*/, rect2 /*popup*/) { | ||
219 | return rect1.x < rect2.x + rect2.width | 230 | return rect1.x < rect2.x + rect2.width | ||
220 | && rect2.x < rect1.x + rect1.width | 231 | && rect2.x < rect1.x + rect1.width | ||
221 | && rect1.y < rect2.y + rect2.height | 232 | && rect1.y < rect2.y + rect2.height | ||
222 | && rect2.y < rect1.y + rect1.height; | 233 | && rect2.y < rect1.y + rect1.height; | ||
223 | } | 234 | } | ||
224 | 235 | | |||
225 | function positionPopups() { | 236 | function positionPopups() { | ||
▲ Show 20 Lines • Show All 245 Lines • ▼ Show 20 Line(s) | |||||
471 | } | 482 | } | ||
472 | 483 | | |||
473 | // Keeps the Inhibited property on DBus in sync with our inhibition handling | 484 | // Keeps the Inhibited property on DBus in sync with our inhibition handling | ||
474 | property Binding serverInhibitedBinding: Binding { | 485 | property Binding serverInhibitedBinding: Binding { | ||
475 | target: NotificationManager.Server | 486 | target: NotificationManager.Server | ||
476 | property: "inhibited" | 487 | property: "inhibited" | ||
477 | value: globals.inhibited | 488 | value: globals.inhibited | ||
478 | } | 489 | } | ||
490 | | ||||
491 | property Notifications.GlobalShortcuts shortcuts: Notifications.GlobalShortcuts { | ||||
492 | onToggleDoNotDisturbTriggered: { | ||||
493 | if (globals.inhibited) { | ||||
494 | globals.revokeInhibitions(); | ||||
495 | } else { | ||||
496 | // Effectively "in a year" is "until turned off" | ||||
497 | var d = new Date(); | ||||
498 | d.setFullYear(d.getFullYear() + 1); | ||||
499 | notificationSettings.notificationsInhibitedUntil = d; | ||||
500 | notificationSettings.save(); | ||||
501 | } | ||||
502 | | ||||
503 | checkInhibition(); | ||||
504 | showDoNotDisturbOsd(globals.inhibited); | ||||
505 | } | ||||
506 | } | ||||
479 | } | 507 | } |