From db1e3cbab16cb453e27d4caea1d585e46bf7cfa2 Mon Sep 17 00:00:00 2001 From: end-4 <97237370+end-4@users.noreply.github.com> Date: Wed, 14 May 2025 22:07:19 +0200 Subject: [PATCH] put notif popup in lazy loader --- .../notificationPopup/NotificationPopup.qml | 189 +++++++++--------- 1 file changed, 96 insertions(+), 93 deletions(-) diff --git a/.config/quickshell/modules/notificationPopup/NotificationPopup.qml b/.config/quickshell/modules/notificationPopup/NotificationPopup.qml index ec8f2c5e..49fe7c38 100644 --- a/.config/quickshell/modules/notificationPopup/NotificationPopup.qml +++ b/.config/quickshell/modules/notificationPopup/NotificationPopup.qml @@ -15,103 +15,106 @@ Scope { Variants { model: Quickshell.screens - PanelWindow { - id: root - visible: true + LazyLoader { + loading: true + PanelWindow { + id: root + visible: true - property var modelData - property Component notifComponent: NotificationWidget {} - property list notificationWidgetList: [] + property var modelData + property Component notifComponent: NotificationWidget {} + property list notificationWidgetList: [] - screen: modelData - WlrLayershell.namespace: "quickshell:notificationPopup" - WlrLayershell.layer: WlrLayer.Overlay - exclusiveZone: 0 + screen: modelData + WlrLayershell.namespace: "quickshell:notificationPopup" + WlrLayershell.layer: WlrLayer.Overlay + exclusiveZone: 0 + + anchors { + top: true + right: true + bottom: true + } + + mask: Region { + item: columnLayout + } + + color: "transparent" + implicitWidth: Appearance.sizes.notificationPopupWidth + + // Signal handlers to add/remove notifications + Connections { + target: Notifications + function onNotify(notification) { + if (GlobalStates.sidebarRightOpenCount > 0) { + return + } + // notificationRepeater.model = [notification, ...notificationRepeater.model] + const notif = root.notifComponent.createObject(columnLayout, { + notificationObject: notification, + popup: true + }); + notificationWidgetList.unshift(notif) + + // Remove stuff from t he column, add back + for (let i = 0; i < notificationWidgetList.length; i++) { + if (notificationWidgetList[i].parent === columnLayout) { + notificationWidgetList[i].parent = null; + } + } + + // Add notification widgets to the column + for (let i = 0; i < notificationWidgetList.length; i++) { + if (notificationWidgetList[i].parent === null) { + notificationWidgetList[i].parent = columnLayout; + } + } + } + function onDiscard(id) { + for (let i = notificationWidgetList.length - 1; i >= 0; i--) { + const widget = notificationWidgetList[i]; + if (widget && widget.notificationObject && widget.notificationObject.id === id) { + widget.destroyWithAnimation(); + notificationWidgetList.splice(i, 1); + } + } + } + function onTimeout(id) { + for (let i = notificationWidgetList.length - 1; i >= 0; i--) { + const widget = notificationWidgetList[i]; + if (widget && widget.notificationObject && widget.notificationObject.id === id) { + widget.destroyWithAnimation(); + notificationWidgetList.splice(i, 1); + } + } + } + function onDiscardAll() { + for (let i = notificationWidgetList.length - 1; i >= 0; i--) { + const widget = notificationWidgetList[i]; + if (widget && widget.notificationObject) { + widget.destroyWithAnimation(); + } + } + notificationWidgetList = []; + } + } + + ColumnLayout { // Scrollable window content + id: columnLayout + anchors.horizontalCenter: parent.horizontalCenter + width: parent.width - Appearance.sizes.hyprlandGapsOut * 2 + spacing: 0 // The widgets themselves have margins for spacing + + Item { + implicitHeight: 1 + implicitWidth: 1 + } + + // Notifications are added by the above signal handlers + } - anchors { - top: true - right: true - bottom: true } - - mask: Region { - item: columnLayout - } - - color: "transparent" - implicitWidth: Appearance.sizes.notificationPopupWidth - - // Signal handlers to add/remove notifications - Connections { - target: Notifications - function onNotify(notification) { - if (GlobalStates.sidebarRightOpenCount > 0) { - return - } - // notificationRepeater.model = [notification, ...notificationRepeater.model] - const notif = root.notifComponent.createObject(columnLayout, { - notificationObject: notification, - popup: true - }); - notificationWidgetList.unshift(notif) - - // Remove stuff from t he column, add back - for (let i = 0; i < notificationWidgetList.length; i++) { - if (notificationWidgetList[i].parent === columnLayout) { - notificationWidgetList[i].parent = null; - } - } - - // Add notification widgets to the column - for (let i = 0; i < notificationWidgetList.length; i++) { - if (notificationWidgetList[i].parent === null) { - notificationWidgetList[i].parent = columnLayout; - } - } - } - function onDiscard(id) { - for (let i = notificationWidgetList.length - 1; i >= 0; i--) { - const widget = notificationWidgetList[i]; - if (widget && widget.notificationObject && widget.notificationObject.id === id) { - widget.destroyWithAnimation(); - notificationWidgetList.splice(i, 1); - } - } - } - function onTimeout(id) { - for (let i = notificationWidgetList.length - 1; i >= 0; i--) { - const widget = notificationWidgetList[i]; - if (widget && widget.notificationObject && widget.notificationObject.id === id) { - widget.destroyWithAnimation(); - notificationWidgetList.splice(i, 1); - } - } - } - function onDiscardAll() { - for (let i = notificationWidgetList.length - 1; i >= 0; i--) { - const widget = notificationWidgetList[i]; - if (widget && widget.notificationObject) { - widget.destroyWithAnimation(); - } - } - notificationWidgetList = []; - } - } - - ColumnLayout { // Scrollable window content - id: columnLayout - anchors.horizontalCenter: parent.horizontalCenter - width: parent.width - Appearance.sizes.hyprlandGapsOut * 2 - spacing: 0 // The widgets themselves have margins for spacing - - Item { - implicitHeight: 1 - implicitWidth: 1 - } - - // Notifications are added by the above signal handlers - } - } }