pragma ComponentBehavior: Bound import QtQuick import Quickshell import Quickshell.Wayland import "../.." as N Scope { id: root required property N.Theme theme required property Notifications notificationService required property string primaryScreenName readonly property var toasts: notificationService.activeToastRows() Variants { model: Quickshell.screens delegate: Component { PanelWindow { id: toastSurface required property var modelData objectName: "notificationToastSurface" screen: modelData // primary monitor only, so a toast shows once, not once per screen. visible: root.toasts.length > 0 && modelData.name === root.primaryScreenName implicitWidth: 404 implicitHeight: Math.max(1, toastColumn.implicitHeight + 64) color: "transparent" exclusionMode: ExclusionMode.Ignore WlrLayershell.layer: WlrLayer.Overlay WlrLayershell.namespace: "nuguland-toast" WlrLayershell.keyboardFocus: WlrKeyboardFocus.None anchors { top: true right: true } Column { id: toastColumn anchors.top: parent.top anchors.right: parent.right anchors.topMargin: 56 anchors.rightMargin: 24 anchors.leftMargin: 8 anchors.bottomMargin: 8 width: parent.width - 32 spacing: 8 Repeater { model: root.toasts // Wrap in a plain Item: Qt6 does NOT inject an array // model's modelData into a required property on an // external-component (NotificationCard) delegate root — // the wrapper takes the injection and passes it down // explicitly. (Same fix used for the popup in Task 3.) delegate: Item { id: toastWrap required property var modelData width: toastColumn.width implicitHeight: toastCard.implicitHeight height: implicitHeight NotificationCard { id: toastCard width: parent.width theme: root.theme modelData: toastWrap.modelData compact: true onDismiss: id => root.notificationService.dismissToast(id) onInvokeAction: (id, actionId) => root.notificationService.runAction(id, actionId) } // Dismiss + drain derive from the service-stamped // absolute expiresAt, not a fresh interval, so a // Repeater rebuild (any other toast added/removed) // resumes the countdown rather than restarting it. readonly property real toastTotal: toastWrap.modelData.timeoutMs || 0 readonly property real toastExpiry: toastWrap.modelData.expiresAt || 0 readonly property real toastRemaining: Math.max(0, toastExpiry - Date.now()) readonly property int toastProgress: toastWrap.modelData.value !== undefined ? Number(toastWrap.modelData.value) : -1 readonly property bool toastHasProgress: toastProgress >= 0 // Progress toasts persist until complete (no drain // dismissal); plain toasts auto-dismiss at expiry. Timer { running: toastWrap.toastExpiry > 0 && !toastWrap.toastHasProgress interval: Math.max(1, toastWrap.toastRemaining) repeat: false onTriggered: root.notificationService.expireToast(String(toastWrap.modelData.id)) } // Progress complete: auto-dismiss shortly after 100%. Timer { running: toastWrap.toastHasProgress && toastWrap.toastProgress >= 100 interval: 1500 repeat: false onTriggered: root.notificationService.expireToast(String(toastWrap.modelData.id)) } // bottom bar: content progress when the toast carries // a value hint, otherwise the auto-dismiss drain. Rectangle { visible: toastWrap.toastHasProgress anchors.left: toastCard.left anchors.bottom: toastCard.bottom anchors.leftMargin: 12 anchors.bottomMargin: 4 height: 2 radius: 1 color: root.theme ? root.theme.ui.accent : "transparent" width: (toastCard.width - 24) * Math.max(0, Math.min(100, toastWrap.toastProgress)) / 100 Behavior on width { NumberAnimation { duration: root.theme && root.theme.lowPowerMode ? 0 : 200 } } } Rectangle { visible: toastWrap.toastExpiry > 0 && !toastWrap.toastHasProgress anchors.left: toastCard.left anchors.bottom: toastCard.bottom anchors.leftMargin: 12 anchors.bottomMargin: 4 height: 2 radius: 1 color: root.theme ? root.theme.withAlpha(root.theme.ui.accent, 0.55) : "transparent" width: (toastCard.width - 24) * (toastWrap.toastTotal > 0 ? toastWrap.toastRemaining / toastWrap.toastTotal : 1) NumberAnimation on width { running: toastWrap.toastExpiry > 0 && !toastWrap.toastHasProgress && !(root.theme && root.theme.lowPowerMode) to: 0 duration: Math.max(1, toastWrap.toastRemaining) } } } } } // Accept input only over the toast cards (click to dismiss); // the transparent margins stay click-through to apps below. mask: Region { item: toastColumn } } } } }