Changeset View
Changeset View
Standalone View
Standalone View
applets/notifications/package/contents/ui/global/Globals.qml
Show First 20 Lines • Show All 229 Lines • ▼ Show 20 Line(s) | 211 | function positionPopups() { | |||
---|---|---|---|---|---|
230 | 230 | | |||
231 | var x = screenRect.x; | 231 | var x = screenRect.x; | ||
232 | if (popupLocation & Qt.AlignLeft) { | 232 | if (popupLocation & Qt.AlignLeft) { | ||
233 | x += popupEdgeDistance; | 233 | x += popupEdgeDistance; | ||
234 | } | 234 | } | ||
235 | 235 | | |||
236 | for (var i = 0; i < popupInstantiator.count; ++i) { | 236 | for (var i = 0; i < popupInstantiator.count; ++i) { | ||
237 | var popup = popupInstantiator.objectAt(i); | 237 | var popup = popupInstantiator.objectAt(i); | ||
238 | // Popup width is fixed, so don't rely on the actual window size | ||||
239 | var popupEffectiveWidth = popupWidth + popup.margins.left + popup.margins.right; | ||||
238 | 240 | | |||
239 | if (popupLocation & Qt.AlignHCenter) { | 241 | if (popupLocation & Qt.AlignHCenter) { | ||
240 | popup.x = x + (screenRect.width - popup.width) / 2; | 242 | popup.x = x + (screenRect.width - popupEffectiveWidth) / 2; | ||
241 | } else if (popupLocation & Qt.AlignRight) { | 243 | } else if (popupLocation & Qt.AlignRight) { | ||
242 | popup.x = x + screenRect.width - popupEdgeDistance - popup.width; | 244 | popup.x = x + screenRect.width - popupEdgeDistance - popupEffectiveWidth; | ||
243 | } else { | 245 | } else { | ||
244 | popup.x = x; | 246 | popup.x = x; | ||
245 | } | 247 | } | ||
246 | 248 | | |||
247 | var delta = popupSpacing + popup.height; | 249 | // If the popup isn't ready yet, ignore its occupied space for now. | ||
250 | // We'll reposition everything in onHeightChanged eventually. | ||||
251 | var delta = popup.height + (popup.height > 0 ? popupSpacing : 0); | ||||
248 | 252 | | |||
249 | if (popupLocation & Qt.AlignTop) { | 253 | if (popupLocation & Qt.AlignTop) { | ||
250 | popup.y = y; | 254 | popup.y = y; | ||
251 | y += delta; | 255 | y += delta; | ||
252 | } else { | 256 | } else { | ||
253 | y -= delta; | 257 | y -= delta; | ||
254 | popup.y = y; | 258 | popup.y = y; | ||
255 | } | 259 | } | ||
▲ Show 20 Lines • Show All 134 Lines • ▼ Show 20 Line(s) | 392 | onOpenUrl: { | |||
390 | popupNotificationsModel.close(popupNotificationsModel.index(index, 0)) | 394 | popupNotificationsModel.close(popupNotificationsModel.index(index, 0)) | ||
391 | } | 395 | } | ||
392 | onFileActionInvoked: popupNotificationsModel.close(popupNotificationsModel.index(index, 0)) | 396 | onFileActionInvoked: popupNotificationsModel.close(popupNotificationsModel.index(index, 0)) | ||
393 | 397 | | |||
394 | onSuspendJobClicked: popupNotificationsModel.suspendJob(popupNotificationsModel.index(index, 0)) | 398 | onSuspendJobClicked: popupNotificationsModel.suspendJob(popupNotificationsModel.index(index, 0)) | ||
395 | onResumeJobClicked: popupNotificationsModel.resumeJob(popupNotificationsModel.index(index, 0)) | 399 | onResumeJobClicked: popupNotificationsModel.resumeJob(popupNotificationsModel.index(index, 0)) | ||
396 | onKillJobClicked: popupNotificationsModel.killJob(popupNotificationsModel.index(index, 0)) | 400 | onKillJobClicked: popupNotificationsModel.killJob(popupNotificationsModel.index(index, 0)) | ||
397 | 401 | | |||
398 | onHeightChanged: Qt.callLater(positionPopups) | 402 | // popup width is fixed | ||
399 | onWidthChanged: Qt.callLater(positionPopups) | 403 | onHeightChanged: positionPopups() | ||
400 | 404 | | |||
401 | Component.onCompleted: { | 405 | Component.onCompleted: { | ||
402 | // Register apps that were seen spawning a popup so they can be configured later | 406 | // Register apps that were seen spawning a popup so they can be configured later | ||
403 | // Apps with notifyrc can already be configured anyway | 407 | // Apps with notifyrc can already be configured anyway | ||
404 | if (model.type === NotificationManager.Notifications.NotificationType && model.desktopEntry && !model.notifyRcName) { | 408 | if (model.type === NotificationManager.Notifications.NotificationType && model.desktopEntry && !model.notifyRcName) { | ||
405 | notificationSettings.registerKnownApplication(model.desktopEntry); | 409 | notificationSettings.registerKnownApplication(model.desktopEntry); | ||
406 | notificationSettings.save(); | 410 | notificationSettings.save(); | ||
407 | } | 411 | } | ||
408 | 412 | | |||
409 | // Tell the model that we're handling the timeout now | 413 | // Tell the model that we're handling the timeout now | ||
410 | popupNotificationsModel.stopTimeout(popupNotificationsModel.index(index, 0)); | 414 | popupNotificationsModel.stopTimeout(popupNotificationsModel.index(index, 0)); | ||
411 | } | 415 | } | ||
412 | } | 416 | } | ||
413 | onObjectAdded: { | 417 | onObjectAdded: { | ||
414 | // also needed for it to correctly layout its contents | 418 | positionPopups(); | ||
415 | object.visible = true; | 419 | object.visible = true; | ||
416 | Qt.callLater(positionPopups); | | |||
417 | } | 420 | } | ||
418 | onObjectRemoved: { | 421 | onObjectRemoved: { | ||
419 | var notificationId = object.notificationId | 422 | var notificationId = object.notificationId | ||
420 | // Popup might have been destroyed because of a filter change, tell the model to do the timeout work for us again | 423 | // Popup might have been destroyed because of a filter change, tell the model to do the timeout work for us again | ||
421 | // cannot use QModelIndex here as the model row is already gone | 424 | // cannot use QModelIndex here as the model row is already gone | ||
422 | popupNotificationsModel.startTimeout(notificationId); | 425 | popupNotificationsModel.startTimeout(notificationId); | ||
423 | 426 | | |||
424 | Qt.callLater(positionPopups); | 427 | positionPopups(); | ||
425 | } | 428 | } | ||
426 | } | 429 | } | ||
427 | 430 | | |||
428 | // TODO use pulseaudio-qt for this once it becomes a framework | 431 | // TODO use pulseaudio-qt for this once it becomes a framework | ||
429 | property QtObject pulseAudio: Loader { | 432 | property QtObject pulseAudio: Loader { | ||
430 | source: "PulseAudio.qml" | 433 | source: "PulseAudio.qml" | ||
431 | } | 434 | } | ||
432 | 435 | | |||
Show All 12 Lines |