Changeset View
Changeset View
Standalone View
Standalone View
applets/notifications/package/contents/ui/global/Globals.qml
Show First 20 Lines • Show All 128 Lines • ▼ Show 20 Line(s) | 37 | QtObject { | |||
---|---|---|---|---|---|
129 | // The raw width of the popup's content item, the Dialog itself adds some margins | 129 | // The raw width of the popup's content item, the Dialog itself adds some margins | ||
130 | property int popupWidth: units.gridUnit * 18 | 130 | property int popupWidth: units.gridUnit * 18 | ||
131 | property int popupEdgeDistance: units.largeSpacing | 131 | property int popupEdgeDistance: units.largeSpacing | ||
132 | property int popupSpacing: units.largeSpacing | 132 | property int popupSpacing: units.largeSpacing | ||
133 | 133 | | |||
134 | // How much vertical screen real estate the notification popups may consume | 134 | // How much vertical screen real estate the notification popups may consume | ||
135 | readonly property real popupMaximumScreenFill: 0.75 | 135 | readonly property real popupMaximumScreenFill: 0.75 | ||
136 | 136 | | |||
137 | property var screenRect: plasmoid ? Qt.rect(plasmoid.screenGeometry.x + plasmoid.availableScreenRect.x, | | |||
138 | plasmoid.screenGeometry.y + plasmoid.availableScreenRect.y, | | |||
139 | plasmoid.availableScreenRect.width, | | |||
140 | plasmoid.availableScreenRect.height) : undefined | | |||
141 | | ||||
142 | onPopupLocationChanged: Qt.callLater(positionPopups) | 137 | onPopupLocationChanged: Qt.callLater(positionPopups) | ||
143 | onScreenRectChanged: Qt.callLater(positionPopups) | | |||
144 | 138 | | |||
145 | Component.onCompleted: checkInhibition() | 139 | Component.onCompleted: checkInhibition() | ||
146 | 140 | | |||
147 | function adopt(plasmoid) { | 141 | function adopt(plasmoid) { | ||
148 | // this doesn't emit a change, only in ratePlasmoids() it will detect the change | 142 | // this doesn't emit a change, only in ratePlasmoids() it will detect the change | ||
149 | globals.plasmoids.push(plasmoid); | 143 | globals.plasmoids.push(plasmoid); | ||
150 | ratePlasmoids(); | 144 | ratePlasmoids(); | ||
151 | } | 145 | } | ||
▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Line(s) | 203 | if (notificationSettings.notificationsInhibitedByApplication) { | |||
210 | inhibited |= true; | 204 | inhibited |= true; | ||
211 | } | 205 | } | ||
212 | 206 | | |||
213 | return inhibited; | 207 | return inhibited; | ||
214 | }); | 208 | }); | ||
215 | } | 209 | } | ||
216 | 210 | | |||
217 | function positionPopups() { | 211 | function positionPopups() { | ||
218 | var rect = screenRect; | 212 | if (!plasmoid) { | ||
219 | if (!rect || rect.width <= 0 || rect.height <= 0) { | 213 | return; | ||
214 | } | ||||
215 | | ||||
216 | var screenRect = Qt.rect(plasmoid.screenGeometry.x + plasmoid.availableScreenRect.x, | ||||
217 | plasmoid.screenGeometry.y + plasmoid.availableScreenRect.y, | ||||
218 | plasmoid.availableScreenRect.width, | ||||
219 | plasmoid.availableScreenRect.height); | ||||
220 | if (screenRect.width <= 0 || screenRect.height <= 0) { | ||||
220 | return; | 221 | return; | ||
221 | } | 222 | } | ||
222 | 223 | | |||
223 | var y = screenRect.y; | 224 | var y = screenRect.y; | ||
224 | if (popupLocation & Qt.AlignBottom) { | 225 | if (popupLocation & Qt.AlignBottom) { | ||
225 | y += screenRect.height; | 226 | y += screenRect.height; | ||
226 | } else { | 227 | } else { | ||
227 | y += popupEdgeDistance; | 228 | y += popupEdgeDistance; | ||
Show All 36 Lines | 236 | for (var i = 0; i < popupInstantiator.count; ++i) { | |||
264 | } | 265 | } | ||
265 | 266 | | |||
266 | // TODO would be nice to hide popups when systray or panel controller is open | 267 | // TODO would be nice to hide popups when systray or panel controller is open | ||
267 | popup.visible = visible; | 268 | popup.visible = visible; | ||
268 | } | 269 | } | ||
269 | } | 270 | } | ||
270 | 271 | | |||
271 | property QtObject popupNotificationsModel: NotificationManager.Notifications { | 272 | property QtObject popupNotificationsModel: NotificationManager.Notifications { | ||
272 | limit: globals.screenRect ? (Math.ceil(globals.screenRect.height / (theme.mSize(theme.defaultFont).height * 4))) : 0 | 273 | limit: plasmoid ? (Math.ceil(plasmoid.availableScreenRect.height / (theme.mSize(theme.defaultFont).height * 4))) : 0 | ||
273 | showExpired: false | 274 | showExpired: false | ||
274 | showDismissed: false | 275 | showDismissed: false | ||
275 | blacklistedDesktopEntries: notificationSettings.popupBlacklistedApplications | 276 | blacklistedDesktopEntries: notificationSettings.popupBlacklistedApplications | ||
276 | blacklistedNotifyRcNames: notificationSettings.popupBlacklistedServices | 277 | blacklistedNotifyRcNames: notificationSettings.popupBlacklistedServices | ||
277 | whitelistedDesktopEntries: globals.inhibited ? notificationSettings.doNotDisturbPopupWhitelistedApplications : [] | 278 | whitelistedDesktopEntries: globals.inhibited ? notificationSettings.doNotDisturbPopupWhitelistedApplications : [] | ||
278 | whitelistedNotifyRcNames: globals.inhibited ? notificationSettings.doNotDisturbPopupWhitelistedServices : [] | 279 | whitelistedNotifyRcNames: globals.inhibited ? notificationSettings.doNotDisturbPopupWhitelistedServices : [] | ||
279 | showJobs: notificationSettings.jobsInNotifications | 280 | showJobs: notificationSettings.jobsInNotifications | ||
280 | sortMode: NotificationManager.Notifications.SortByTypeAndUrgency | 281 | sortMode: NotificationManager.Notifications.SortByTypeAndUrgency | ||
▲ Show 20 Lines • Show All 142 Lines • ▼ Show 20 Line(s) | 418 | onObjectRemoved: { | |||
423 | Qt.callLater(positionPopups); | 424 | Qt.callLater(positionPopups); | ||
424 | } | 425 | } | ||
425 | } | 426 | } | ||
426 | 427 | | |||
427 | // TODO use pulseaudio-qt for this once it becomes a framework | 428 | // TODO use pulseaudio-qt for this once it becomes a framework | ||
428 | property QtObject pulseAudio: Loader { | 429 | property QtObject pulseAudio: Loader { | ||
429 | source: "PulseAudio.qml" | 430 | source: "PulseAudio.qml" | ||
430 | } | 431 | } | ||
432 | | ||||
433 | property Connections screenWatcher: Connections { | ||||
434 | target: plasmoid | ||||
435 | onAvailableScreenRectChanged: repositionTimer.start() | ||||
436 | onScreenGeometryChanged: repositionTimer.start() | ||||
437 | } | ||||
438 | | ||||
439 | // Normally popups are repositioned through Qt.callLater but in case of e.g. screen geometry changes we want to compress that | ||||
440 | property Timer repositionTimer: Timer { | ||||
441 | interval: 250 | ||||
442 | onTriggered: positionPopups() | ||||
443 | } | ||||
431 | } | 444 | } |