Changeset View
Changeset View
Standalone View
Standalone View
applets/notifications/package/contents/ui/global/Globals.qml
Show All 40 Lines | |||||
41 | QtObject { | 41 | QtObject { | ||
42 | id: globals | 42 | id: globals | ||
43 | 43 | | |||
44 | // Listened to by "ago" label in NotificationHeader to update all of them in unison | 44 | // Listened to by "ago" label in NotificationHeader to update all of them in unison | ||
45 | signal timeChanged | 45 | signal timeChanged | ||
46 | 46 | | |||
47 | property bool inhibited: false | 47 | property bool inhibited: false | ||
48 | 48 | | |||
49 | onInhibitedChanged: { | 49 | function onInhibitedChanged() { | ||
50 | var pa = pulseAudio.item; | 50 | var pa = pulseAudio.item; | ||
51 | if (!pa) { | 51 | if (!pa) { | ||
52 | return; | 52 | return; | ||
53 | } | 53 | } | ||
54 | 54 | | |||
55 | var stream = pa.notificationStream; | 55 | var stream = pa.notificationStream; | ||
56 | if (!stream) { | 56 | if (!stream) { | ||
57 | return; | 57 | return; | ||
Show All 16 Lines | |||||
74 | } | 74 | } | ||
75 | 75 | | |||
76 | // Some parts of the code rely on plasmoid.nativeInterface and since we're in a singleton here | 76 | // Some parts of the code rely on plasmoid.nativeInterface and since we're in a singleton here | ||
77 | // this is named "plasmoid" | 77 | // this is named "plasmoid" | ||
78 | property QtObject plasmoid: plasmoids[0] | 78 | property QtObject plasmoid: plasmoids[0] | ||
79 | 79 | | |||
80 | // HACK When a plasmoid is destroyed, QML sets its value to "null" in the Array | 80 | // HACK When a plasmoid is destroyed, QML sets its value to "null" in the Array | ||
81 | // so we then remove it so we have a working "plasmoid" again | 81 | // so we then remove it so we have a working "plasmoid" again | ||
82 | onPlasmoidChanged: { | 82 | function onPlasmoidChanged() { | ||
83 | if (!plasmoid) { | 83 | if (!plasmoid) { | ||
84 | // this doesn't emit a change, only in ratePlasmoids() it will detect the change | 84 | // this doesn't emit a change, only in ratePlasmoids() it will detect the change | ||
85 | plasmoids.splice(0, 1); // remove first | 85 | plasmoids.splice(0, 1); // remove first | ||
86 | ratePlasmoids(); | 86 | ratePlasmoids(); | ||
87 | } | 87 | } | ||
88 | } | 88 | } | ||
89 | 89 | | |||
90 | // all notification plasmoids | 90 | // all notification plasmoids | ||
Show All 40 Lines | 93 | property int popupLocation: { | |||
131 | case NotificationManager.Settings.BottomCenter: | 131 | case NotificationManager.Settings.BottomCenter: | ||
132 | return Qt.AlignBottom | Qt.AlignHCenter; | 132 | return Qt.AlignBottom | Qt.AlignHCenter; | ||
133 | case NotificationManager.Settings.BottomRight: | 133 | case NotificationManager.Settings.BottomRight: | ||
134 | return Qt.AlignBottom | Qt.AlignRight; | 134 | return Qt.AlignBottom | Qt.AlignRight; | ||
135 | } | 135 | } | ||
136 | } | 136 | } | ||
137 | 137 | | |||
138 | readonly property QtObject focusDialog: plasmoid.nativeInterface.focussedPlasmaDialog | 138 | readonly property QtObject focusDialog: plasmoid.nativeInterface.focussedPlasmaDialog | ||
139 | onFocusDialogChanged: positionPopups() | 139 | function onFocusDialogChanged() { positionPopups() } | ||
140 | 140 | | |||
141 | // The raw width of the popup's content item, the Dialog itself adds some margins | 141 | // The raw width of the popup's content item, the Dialog itself adds some margins | ||
142 | // Make it wider when on the top or the bottom center, since there's more horizontal | 142 | // Make it wider when on the top or the bottom center, since there's more horizontal | ||
143 | // space available without looking weird | 143 | // space available without looking weird | ||
144 | property int popupWidth: popupLocation & Qt.AlignHCenter ? units.gridUnit * 28 : units.gridUnit * 18 | 144 | property int popupWidth: popupLocation & Qt.AlignHCenter ? units.gridUnit * 28 : units.gridUnit * 18 | ||
145 | property int popupEdgeDistance: units.largeSpacing * 2 | 145 | property int popupEdgeDistance: units.largeSpacing * 2 | ||
146 | // Reduce spacing between popups when centered so the stack doesn't intrude into the | 146 | // Reduce spacing between popups when centered so the stack doesn't intrude into the | ||
147 | // view as much | 147 | // view as much | ||
148 | property int popupSpacing: popupLocation & Qt.AlignHCenter ? units.smallSpacing : units.largeSpacing | 148 | property int popupSpacing: popupLocation & Qt.AlignHCenter ? units.smallSpacing : units.largeSpacing | ||
149 | 149 | | |||
150 | // How much vertical screen real estate the notification popups may consume | 150 | // How much vertical screen real estate the notification popups may consume | ||
151 | readonly property real popupMaximumScreenFill: 0.75 | 151 | readonly property real popupMaximumScreenFill: 0.75 | ||
152 | 152 | | |||
153 | onPopupLocationChanged: Qt.callLater(positionPopups) | 153 | function onPopupLocationChanged() { Qt.callLater(positionPopups) } | ||
154 | 154 | | |||
155 | Component.onCompleted: checkInhibition() | 155 | Component.onCompleted: checkInhibition() | ||
156 | 156 | | |||
157 | function adopt(plasmoid) { | 157 | function adopt(plasmoid) { | ||
158 | // this doesn't emit a change, only in ratePlasmoids() it will detect the change | 158 | // this doesn't emit a change, only in ratePlasmoids() it will detect the change | ||
159 | globals.plasmoids.push(plasmoid); | 159 | globals.plasmoids.push(plasmoid); | ||
160 | ratePlasmoids(); | 160 | ratePlasmoids(); | ||
161 | } | 161 | } | ||
▲ Show 20 Lines • Show All 191 Lines • ▼ Show 20 Line(s) | 352 | if (!globals.inhibited && notificationSettings.lowPriorityPopups) { | |||
353 | urgencies |=NotificationManager.Notifications.LowUrgency; | 353 | urgencies |=NotificationManager.Notifications.LowUrgency; | ||
354 | } | 354 | } | ||
355 | 355 | | |||
356 | return urgencies; | 356 | return urgencies; | ||
357 | } | 357 | } | ||
358 | } | 358 | } | ||
359 | 359 | | |||
360 | property QtObject notificationSettings: NotificationManager.Settings { | 360 | property QtObject notificationSettings: NotificationManager.Settings { | ||
361 | onNotificationsInhibitedUntilChanged: globals.checkInhibition() | 361 | function onNotificationsInhibitedUntilChanged() { globals.checkInhibition() } | ||
362 | } | 362 | } | ||
363 | 363 | | |||
364 | property QtObject tasksModel: TaskManager.TasksModel { | 364 | property QtObject tasksModel: TaskManager.TasksModel { | ||
365 | groupMode: TaskManager.TasksModel.GroupApplications | 365 | groupMode: TaskManager.TasksModel.GroupApplications | ||
366 | groupInline: false | 366 | groupInline: false | ||
367 | } | 367 | } | ||
368 | 368 | | |||
369 | // This periodically checks whether do not disturb mode timed out and updates the "minutes ago" labels | 369 | // This periodically checks whether do not disturb mode timed out and updates the "minutes ago" labels | ||
370 | property QtObject timeSource: PlasmaCore.DataSource { | 370 | property QtObject timeSource: PlasmaCore.DataSource { | ||
371 | engine: "time" | 371 | engine: "time" | ||
372 | connectedSources: ["Local"] | 372 | connectedSources: ["Local"] | ||
373 | interval: 60000 // 1 min | 373 | interval: 60000 // 1 min | ||
374 | intervalAlignment: PlasmaCore.Types.AlignToMinute | 374 | intervalAlignment: PlasmaCore.Types.AlignToMinute | ||
375 | onDataChanged: { | 375 | function onDataChanged() { | ||
376 | checkInhibition(); | 376 | checkInhibition(); | ||
377 | globals.timeChanged(); | 377 | globals.timeChanged(); | ||
378 | } | 378 | } | ||
379 | } | 379 | } | ||
380 | 380 | | |||
381 | property Instantiator popupInstantiator: Instantiator { | 381 | property Instantiator popupInstantiator: Instantiator { | ||
382 | model: popupNotificationsModel | 382 | model: popupNotificationsModel | ||
383 | delegate: NotificationPopup { | 383 | delegate: NotificationPopup { | ||
▲ Show 20 Lines • Show All 113 Lines • ▼ Show 20 Line(s) | |||||
497 | } | 497 | } | ||
498 | onFileActionInvoked: popupNotificationsModel.close(popupNotificationsModel.index(index, 0)) | 498 | onFileActionInvoked: popupNotificationsModel.close(popupNotificationsModel.index(index, 0)) | ||
499 | 499 | | |||
500 | onSuspendJobClicked: popupNotificationsModel.suspendJob(popupNotificationsModel.index(index, 0)) | 500 | onSuspendJobClicked: popupNotificationsModel.suspendJob(popupNotificationsModel.index(index, 0)) | ||
501 | onResumeJobClicked: popupNotificationsModel.resumeJob(popupNotificationsModel.index(index, 0)) | 501 | onResumeJobClicked: popupNotificationsModel.resumeJob(popupNotificationsModel.index(index, 0)) | ||
502 | onKillJobClicked: popupNotificationsModel.killJob(popupNotificationsModel.index(index, 0)) | 502 | onKillJobClicked: popupNotificationsModel.killJob(popupNotificationsModel.index(index, 0)) | ||
503 | 503 | | |||
504 | // popup width is fixed | 504 | // popup width is fixed | ||
505 | onHeightChanged: positionPopups() | 505 | function onHeightChanged() { positionPopups() } | ||
506 | 506 | | |||
507 | Component.onCompleted: { | 507 | Component.onCompleted: { | ||
508 | if (model.type === NotificationManager.Notifications.NotificationType && model.desktopEntry) { | 508 | if (model.type === NotificationManager.Notifications.NotificationType && model.desktopEntry) { | ||
509 | // Register apps that were seen spawning a popup so they can be configured later | 509 | // Register apps that were seen spawning a popup so they can be configured later | ||
510 | // Apps with notifyrc can already be configured anyway | 510 | // Apps with notifyrc can already be configured anyway | ||
511 | if (!model.notifyRcName) { | 511 | if (!model.notifyRcName) { | ||
512 | notificationSettings.registerKnownApplication(model.desktopEntry); | 512 | notificationSettings.registerKnownApplication(model.desktopEntry); | ||
513 | notificationSettings.save(); | 513 | notificationSettings.save(); | ||
Show All 35 Lines | |||||
549 | 549 | | |||
550 | // TODO use pulseaudio-qt for this once it becomes a framework | 550 | // TODO use pulseaudio-qt for this once it becomes a framework | ||
551 | property QtObject pulseAudio: Loader { | 551 | property QtObject pulseAudio: Loader { | ||
552 | source: "PulseAudio.qml" | 552 | source: "PulseAudio.qml" | ||
553 | } | 553 | } | ||
554 | 554 | | |||
555 | property Connections screenWatcher: Connections { | 555 | property Connections screenWatcher: Connections { | ||
556 | target: plasmoid | 556 | target: plasmoid | ||
557 | onAvailableScreenRectChanged: repositionTimer.start() | 557 | function onAvailableScreenRectChanged() { repositionTimer.start() } | ||
558 | onScreenGeometryChanged: repositionTimer.start() | 558 | function onScreenGeometryChanged() { repositionTimer.start() } | ||
559 | } | 559 | } | ||
560 | 560 | | |||
561 | // Normally popups are repositioned through Qt.callLater but in case of e.g. screen geometry changes we want to compress that | 561 | // Normally popups are repositioned through Qt.callLater but in case of e.g. screen geometry changes we want to compress that | ||
562 | property Timer repositionTimer: Timer { | 562 | property Timer repositionTimer: Timer { | ||
563 | interval: 250 | 563 | interval: 250 | ||
564 | onTriggered: positionPopups() | 564 | onTriggered: positionPopups() | ||
565 | } | 565 | } | ||
566 | 566 | | |||
Show All 28 Lines |