From 89d46c1b2fd1a35a3229511f745205ac4956bf9e Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Sat, 20 Sep 2025 15:47:44 +1000 Subject: sidebar/notifs: better anims + misc fixes --- services/Notifs.qml | 113 ++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 91 insertions(+), 22 deletions(-) (limited to 'services') diff --git a/services/Notifs.qml b/services/Notifs.qml index cb52bc5..7136959 100644 --- a/services/Notifs.qml +++ b/services/Notifs.qml @@ -12,17 +12,23 @@ import QtQuick Singleton { id: root - readonly property list list: [] + property list list: [] + readonly property list notClosed: list.filter(n => !n.closed) readonly property list popups: list.filter(n => n.popup) property alias dnd: props.dnd property bool loaded onListChanged: { - if (!loaded) - return; + if (loaded) + saveTimer.restart(); + } + + Timer { + id: saveTimer - storage.setText(JSON.stringify(list.filter(n => !n.closed).map(n => ({ + interval: 1000 + onTriggered: storage.setText(JSON.stringify(root.notClosed.map(n => ({ time: n.time, id: n.id, summary: n.summary, @@ -35,7 +41,7 @@ Singleton { resident: n.resident, hasActionIcons: n.hasActionIcons, actions: n.actions - })))); + })))) } PersistentProperties { @@ -60,10 +66,11 @@ Singleton { onNotification: notif => { notif.tracked = true; - root.list.push(notifComp.createObject(root, { + const comp = notifComp.createObject(root, { popup: !props.dnd && ![...Visibilities.screens.values()].some(v => v.sidebar), notification: notif - })); + }); + root.list = [comp, ...root.list]; } } @@ -75,6 +82,7 @@ Singleton { const data = JSON.parse(text()); for (const notif of data) root.list.push(notifComp.createObject(root, notif)); + root.list.sort((a, b) => a.time - b.time); root.loaded = true; } onLoadFailed: err => { @@ -140,21 +148,17 @@ Singleton { } property Notification notification - property string id: notification?.id ?? "" - property string summary: notification?.summary ?? "" - property string body: notification?.body ?? "" - property string appIcon: notification?.appIcon ?? "" - property string appName: notification?.appName ?? "" - property string image: notification?.image ?? "" - property real expireTimeout: notification?.expireTimeout ?? Config.notifs.defaultExpireTimeout - property int urgency: notification?.urgency ?? NotificationUrgency.Normal - property bool resident: notification?.resident ?? false - property bool hasActionIcons: notification?.hasActionIcons ?? false - property list actions: notification?.actions.map(a => ({ - identifier: a.identifier, - text: a.text, - invoke: () => a.invoke() - })) ?? [] + property string id + property string summary + property string body + property string appIcon + property string appName + property string image + property real expireTimeout: Config.notifs.defaultExpireTimeout + property int urgency: NotificationUrgency.Normal + property bool resident + property bool hasActionIcons + property list actions readonly property Timer timer: Timer { running: true @@ -171,6 +175,50 @@ Singleton { function onClosed(): void { notif.close(); } + + function onSummaryChanged(): void { + notif.summary = notif.notification.summary; + } + + function onBodyChanged(): void { + notif.body = notif.notification.body; + } + + function onAppIconChanged(): void { + notif.appIcon = notif.notification.appIcon; + } + + function onAppNameChanged(): void { + notif.appName = notif.notification.appName; + } + + function onImageChanged(): void { + notif.image = notif.notification.image; + } + + function onExpireTimeoutChanged(): void { + notif.expireTimeout = notif.notification.expireTimeout; + } + + function onUrgencyChanged(): void { + notif.urgency = notif.notification.urgency; + } + + function onResidentChanged(): void { + notif.resident = notif.notification.resident; + } + + function onHasActionIconsChanged(): void { + notif.hasActionIcons = notif.notification.hasActionIcons; + } + + function onActionsChanged(): void { + notif.actions = notif.notification.actions.map(a => ({ + identifier: a.identifier, + text: a.text, + invoke: () => a.invoke() + })); + } } function lock(item: Item): void { @@ -195,6 +243,27 @@ Singleton { destroy(); } } + + Component.onCompleted: { + if (!notification) + return; + + id = notification.id; + summary = notification.summary; + body = notification.body; + appIcon = notification.appIcon; + appName = notification.appName; + image = notification.image; + expireTimeout = notification.expireTimeout; + urgency = notification.urgency; + resident = notification.resident; + hasActionIcons = notification.hasActionIcons; + actions = notification.actions.map(a => ({ + identifier: a.identifier, + text: a.text, + invoke: () => a.invoke() + })); + } } Component { -- cgit v1.2.3-freya