From c1510b547645de5e8f70f6be99a0ba894b797241 Mon Sep 17 00:00:00 2001 From: ATMDA Date: Wed, 12 Nov 2025 14:51:22 -0500 Subject: notifs/toasts: reworked notifications and toasts and how they display and work together. see pull request comment. --- services/Notifs.qml | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) (limited to 'services') diff --git a/services/Notifs.qml b/services/Notifs.qml index 4a89c7f..ea0c52a 100644 --- a/services/Notifs.qml +++ b/services/Notifs.qml @@ -77,8 +77,10 @@ Singleton { onNotification: notif => { notif.tracked = true; + const shouldShowAsToast = !props.dnd && ![...Visibilities.screens.values()].some(v => v.sidebar); const comp = notifComp.createObject(root, { - popup: !props.dnd && ![...Visibilities.screens.values()].some(v => v.sidebar), + popup: shouldShowAsToast, + showAsToast: shouldShowAsToast, notification: notif }); root.list = [comp, ...root.list]; @@ -143,6 +145,7 @@ Singleton { property bool popup property bool closed + property bool showAsToast: false property var locks: new Set() property date time: new Date() @@ -177,6 +180,38 @@ Singleton { property list actions readonly property Timer timer: Timer { + id: toastTimer + + running: notif.showAsToast + interval: { + let timeout = notif.expireTimeout; + if (timeout <= 0) { + switch (notif.urgency) { + case NotificationUrgency.Critical: + timeout = 10000; + break; + case NotificationUrgency.Normal: + timeout = 5000; + break; + case NotificationUrgency.Low: + timeout = 5000; + break; + default: + timeout = 5000; + } + } + return timeout; + } + onTriggered: { + if (Config.notifs.expire) + notif.popup = false; + if (notif.showAsToast) { + notif.showAsToast = false; + } + } + } + + readonly property Timer popupTimer: Timer { running: true interval: notif.expireTimeout > 0 ? notif.expireTimeout : Config.notifs.defaultExpireTimeout onTriggered: { -- cgit v1.2.3-freya