From c6e05919778b96094c7f20c53bd0053185b9d7d5 Mon Sep 17 00:00:00 2001 From: Micah Stanley Date: Fri, 22 Nov 2024 01:55:50 +0000 Subject: [PATCH] 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. --- .../notificationpopup/NotificationPopup.qml | 31 ++++++++++--------- .../NotificationPopupManager.qml | 8 +++-- .../NotificationPopupProvider.qml | 5 +-- 3 files changed, 25 insertions(+), 19 deletions(-) diff --git a/components/mobileshell/qml/notificationpopup/NotificationPopup.qml b/components/mobileshell/qml/notificationpopup/NotificationPopup.qml index 83aecf7a..70b372ec 100644 --- a/components/mobileshell/qml/notificationpopup/NotificationPopup.qml +++ b/components/mobileshell/qml/notificationpopup/NotificationPopup.qml @@ -45,8 +45,9 @@ Item { interval: Kirigami.Units.veryLongDuration running: true onTriggered: { - updateNotificationPopups(); visible = true; + updateNotificationPopups(); + checkActionDrawerOpened(); } } @@ -133,8 +134,9 @@ Item { // if the popup height ever changes, update the notification below wiht new height // also update the allowed touch area for the main window onPopupHeightChanged: { - if (popupIndex + 1 < popupCount) { - popupNotifications.objectAt(popupIndex + 1).aboveNotificationHeight = popupHeight; + let abovePopup = popupNotifications.objectAt(popupIndex + 1) + if (popupIndex + 1 < popupCount && abovePopup) { + abovePopup.aboveNotificationHeight = popupHeight; } if (popupNotifications.currentPopupIndex == notificationPopup.popupIndex && notificationItem.state == "open") { notificationPopup.updateTouchArea(); @@ -143,22 +145,25 @@ Item { // if the offset position need in the expanded drawer changes, update the notification below wiht new offset onFullOpenOffsetChanged: { - if (popupIndex + 1 < popupCount) { - popupNotifications.objectAt(popupIndex + 1).aboveNotificationFullOffset = fullOpenOffset; + let abovePopup = popupNotifications.objectAt(popupIndex + 1) + if (popupIndex + 1 < popupCount && abovePopup) { + abovePopup.aboveNotificationFullOffset = fullOpenOffset; } } // if the notification is being draged and is the current one // update 'currentDragOffset' so all notifications can easily access this value onDragOffsetChanged: { + let abovePopup = popupNotifications.objectAt(popupIndex + 1) if (popupNotifications.currentPopupIndex == notificationPopup.popupIndex) { popupNotifications.currentDragOffset = dragOffset; } } // if a new notification is added, update the above notification values need for the expanded drawer onPopupCountChanged: { - if (popupIndex + 1 < popupCount) { - popupNotifications.objectAt(popupIndex + 1).aboveNotificationHeight = popupHeight; - popupNotifications.objectAt(popupIndex + 1).aboveNotificationFullOffset = fullOpenOffset; + let abovePopup = popupNotifications.objectAt(popupIndex + 1) + if (popupIndex + 1 < abovePopup) { + abovePopup.aboveNotificationHeight = popupHeight; + abovePopup.aboveNotificationFullOffset = fullOpenOffset; } } // update the current popup index value if the index ever changes. @@ -201,14 +206,10 @@ Item { return model.timeout; } - Component.onCompleted: checkActionDrawerOpened() - - // check if the action drawer is opened, and if so, close the popup with scale + // check if the action drawer is opened and the popup is fully created + // if so, close the popup with a scale effect function checkActionDrawerOpened() { - if (isActionDrawerOpen) { - if (popupNotifications.currentPopupIndex == notificationPopup.popupIndex) { - notificationPopup.setInputTransparent(); - } + if (isActionDrawerOpen && popupNotifications.objectAt(popupIndex)) { notificationPopup.expired(); keyboardInteractivity = LayerShell.Window.KeyboardInteractivityNone; notificationItem.state = "closeWithScale"; diff --git a/components/mobileshell/qml/notificationpopup/NotificationPopupManager.qml b/components/mobileshell/qml/notificationpopup/NotificationPopupManager.qml index 9c95e2cc..3ade5132 100644 --- a/components/mobileshell/qml/notificationpopup/NotificationPopupManager.qml +++ b/components/mobileshell/qml/notificationpopup/NotificationPopupManager.qml @@ -151,7 +151,7 @@ Window { model: popupNotificationsModel // 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 currentPopupIndex: 0 @@ -224,7 +224,11 @@ Window { // but don't actually invalidate the notification model.expired = true; } else { - popupNotificationsModel.expire(popupNotificationsModel.index(index, 0)); + if (notificationModelType === NotificationsModelType.WatchedNotificationsModel) { + popupNotificationsModel.expire(model.notificationId); + } else if (notificationModelType === NotificationsModelType.NotificationsModel) { + popupNotificationsModel.expire(popupNotificationsModel.index(index, 0)); + } } } diff --git a/components/mobileshell/qml/notificationpopup/NotificationPopupProvider.qml b/components/mobileshell/qml/notificationpopup/NotificationPopupProvider.qml index 60f8eed2..712db175 100644 --- a/components/mobileshell/qml/notificationpopup/NotificationPopupProvider.qml +++ b/components/mobileshell/qml/notificationpopup/NotificationPopupProvider.qml @@ -33,8 +33,9 @@ QtObject { showDismissed: false blacklistedDesktopEntries: notificationSettings.popupBlacklistedApplications blacklistedNotifyRcNames: notificationSettings.popupBlacklistedServices - whitelistedDesktopEntries: [] - whitelistedNotifyRcNames: [] + whitelistedDesktopEntries: notificationProvider.inhibited ? notificationSettings.doNotDisturbPopupWhitelistedApplications : [] + whitelistedNotifyRcNames: notificationProvider.inhibited ? notificationSettings.doNotDisturbPopupWhitelistedServices : [] + showJobs: notificationSettings.jobsInNotifications sortMode: NotificationManager.Notifications.SortByTypeAndUrgency sortOrder: Qt.DescendingOrder