diff options
| author | ATMDA <atdma2600@gmail.com> | 2025-11-12 14:51:22 -0500 |
|---|---|---|
| committer | ATMDA <atdma2600@gmail.com> | 2025-11-12 14:51:22 -0500 |
| commit | c1510b547645de5e8f70f6be99a0ba894b797241 (patch) | |
| tree | ce67826496f6530ef0ad09482f28ffc85c79eb51 /services | |
| parent | tray: if background enabled and empty, background is hidden (diff) | |
| download | caelestia-shell-c1510b547645de5e8f70f6be99a0ba894b797241.tar.gz caelestia-shell-c1510b547645de5e8f70f6be99a0ba894b797241.tar.bz2 caelestia-shell-c1510b547645de5e8f70f6be99a0ba894b797241.zip | |
notifs/toasts: reworked notifications and toasts and how they display and work together. see pull request comment.
Diffstat (limited to 'services')
| -rw-r--r-- | services/Notifs.qml | 37 |
1 files changed, 36 insertions, 1 deletions
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<var> 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: { |