popupnotifications: a bit of cleanup and bugfixes

This fixes an issue where if a notification is delivered while the action drawer is opened, it won't dismiss properly. Causing an issue where if a new notification comes through any time afterwards, the top touch area will get stuck and prevent touch inputs.
This also finishes connecting the do not disturb popup whitelist to the notification model.
This commit is contained in:
Micah Stanley 2024-11-22 01:55:50 +00:00 committed by Devin Lin
parent abb9b963f0
commit c6e0591977
3 changed files with 25 additions and 19 deletions

View file

@ -45,8 +45,9 @@ Item {
interval: Kirigami.Units.veryLongDuration interval: Kirigami.Units.veryLongDuration
running: true running: true
onTriggered: { onTriggered: {
updateNotificationPopups();
visible = true; visible = true;
updateNotificationPopups();
checkActionDrawerOpened();
} }
} }
@ -133,8 +134,9 @@ Item {
// if the popup height ever changes, update the notification below wiht new height // if the popup height ever changes, update the notification below wiht new height
// also update the allowed touch area for the main window // also update the allowed touch area for the main window
onPopupHeightChanged: { onPopupHeightChanged: {
if (popupIndex + 1 < popupCount) { let abovePopup = popupNotifications.objectAt(popupIndex + 1)
popupNotifications.objectAt(popupIndex + 1).aboveNotificationHeight = popupHeight; if (popupIndex + 1 < popupCount && abovePopup) {
abovePopup.aboveNotificationHeight = popupHeight;
} }
if (popupNotifications.currentPopupIndex == notificationPopup.popupIndex && notificationItem.state == "open") { if (popupNotifications.currentPopupIndex == notificationPopup.popupIndex && notificationItem.state == "open") {
notificationPopup.updateTouchArea(); notificationPopup.updateTouchArea();
@ -143,22 +145,25 @@ Item {
// if the offset position need in the expanded drawer changes, update the notification below wiht new offset // if the offset position need in the expanded drawer changes, update the notification below wiht new offset
onFullOpenOffsetChanged: { onFullOpenOffsetChanged: {
if (popupIndex + 1 < popupCount) { let abovePopup = popupNotifications.objectAt(popupIndex + 1)
popupNotifications.objectAt(popupIndex + 1).aboveNotificationFullOffset = fullOpenOffset; if (popupIndex + 1 < popupCount && abovePopup) {
abovePopup.aboveNotificationFullOffset = fullOpenOffset;
} }
} }
// if the notification is being draged and is the current one // if the notification is being draged and is the current one
// update 'currentDragOffset' so all notifications can easily access this value // update 'currentDragOffset' so all notifications can easily access this value
onDragOffsetChanged: { onDragOffsetChanged: {
let abovePopup = popupNotifications.objectAt(popupIndex + 1)
if (popupNotifications.currentPopupIndex == notificationPopup.popupIndex) { if (popupNotifications.currentPopupIndex == notificationPopup.popupIndex) {
popupNotifications.currentDragOffset = dragOffset; popupNotifications.currentDragOffset = dragOffset;
} }
} }
// if a new notification is added, update the above notification values need for the expanded drawer // if a new notification is added, update the above notification values need for the expanded drawer
onPopupCountChanged: { onPopupCountChanged: {
if (popupIndex + 1 < popupCount) { let abovePopup = popupNotifications.objectAt(popupIndex + 1)
popupNotifications.objectAt(popupIndex + 1).aboveNotificationHeight = popupHeight; if (popupIndex + 1 < abovePopup) {
popupNotifications.objectAt(popupIndex + 1).aboveNotificationFullOffset = fullOpenOffset; abovePopup.aboveNotificationHeight = popupHeight;
abovePopup.aboveNotificationFullOffset = fullOpenOffset;
} }
} }
// update the current popup index value if the index ever changes. // update the current popup index value if the index ever changes.
@ -201,14 +206,10 @@ Item {
return model.timeout; return model.timeout;
} }
Component.onCompleted: checkActionDrawerOpened() // check if the action drawer is opened and the popup is fully created
// if so, close the popup with a scale effect
// check if the action drawer is opened, and if so, close the popup with scale
function checkActionDrawerOpened() { function checkActionDrawerOpened() {
if (isActionDrawerOpen) { if (isActionDrawerOpen && popupNotifications.objectAt(popupIndex)) {
if (popupNotifications.currentPopupIndex == notificationPopup.popupIndex) {
notificationPopup.setInputTransparent();
}
notificationPopup.expired(); notificationPopup.expired();
keyboardInteractivity = LayerShell.Window.KeyboardInteractivityNone; keyboardInteractivity = LayerShell.Window.KeyboardInteractivityNone;
notificationItem.state = "closeWithScale"; notificationItem.state = "closeWithScale";

View file

@ -151,7 +151,7 @@ Window {
model: popupNotificationsModel model: popupNotificationsModel
// get the height, drag offset, and idx of the current popup notifition and make it easily accessible by all popup notifications // get the height, drag offset, and idx of the current popup notifition and make it easily accessible by all popup notifications
property int currentPopupHeight: (count > 0 && currentPopupIndex < count) ? objectAt(currentPopupIndex).popupHeight : 0; property int currentPopupHeight: (count > 0 && currentPopupIndex < count && objectAt(currentPopupIndex)) ? objectAt(currentPopupIndex).popupHeight : 0;
property int currentDragOffset: 0 property int currentDragOffset: 0
property int currentPopupIndex: 0 property int currentPopupIndex: 0
@ -224,9 +224,13 @@ Window {
// but don't actually invalidate the notification // but don't actually invalidate the notification
model.expired = true; model.expired = true;
} else { } else {
if (notificationModelType === NotificationsModelType.WatchedNotificationsModel) {
popupNotificationsModel.expire(model.notificationId);
} else if (notificationModelType === NotificationsModelType.NotificationsModel) {
popupNotificationsModel.expire(popupNotificationsModel.index(index, 0)); popupNotificationsModel.expire(popupNotificationsModel.index(index, 0));
} }
} }
}
Component.onCompleted: { Component.onCompleted: {
if (model.type === NotificationManager.Notifications.NotificationType && model.desktopEntry) { if (model.type === NotificationManager.Notifications.NotificationType && model.desktopEntry) {

View file

@ -33,8 +33,9 @@ QtObject {
showDismissed: false showDismissed: false
blacklistedDesktopEntries: notificationSettings.popupBlacklistedApplications blacklistedDesktopEntries: notificationSettings.popupBlacklistedApplications
blacklistedNotifyRcNames: notificationSettings.popupBlacklistedServices blacklistedNotifyRcNames: notificationSettings.popupBlacklistedServices
whitelistedDesktopEntries: [] whitelistedDesktopEntries: notificationProvider.inhibited ? notificationSettings.doNotDisturbPopupWhitelistedApplications : []
whitelistedNotifyRcNames: [] whitelistedNotifyRcNames: notificationProvider.inhibited ? notificationSettings.doNotDisturbPopupWhitelistedServices : []
showJobs: notificationSettings.jobsInNotifications showJobs: notificationSettings.jobsInNotifications
sortMode: NotificationManager.Notifications.SortByTypeAndUrgency sortMode: NotificationManager.Notifications.SortByTypeAndUrgency
sortOrder: Qt.DescendingOrder sortOrder: Qt.DescendingOrder