diff options
| author | Leander Scherer <leander@schererleander.de> | 2026-05-30 15:35:27 +0200 |
|---|---|---|
| committer | Leander Scherer <leander@schererleander.de> | 2026-05-30 15:35:27 +0200 |
| commit | d2747e2ca1e211a32e91e44010f40a00e0ac97e4 (patch) | |
| tree | fb229d6a18541c7a5f1944390b21edde028955f9 /modules/system/quickshell/Notifications.qml | |
| parent | 51b3cbd50b92d026549ce3ebff17ca9b3344f441 (diff) | |
feat(quickshell): add popup controls and privacy indicators
Diffstat (limited to 'modules/system/quickshell/Notifications.qml')
| -rw-r--r-- | modules/system/quickshell/Notifications.qml | 96 |
1 files changed, 52 insertions, 44 deletions
diff --git a/modules/system/quickshell/Notifications.qml b/modules/system/quickshell/Notifications.qml index d17e903..79223eb 100644 --- a/modules/system/quickshell/Notifications.qml +++ b/modules/system/quickshell/Notifications.qml @@ -11,68 +11,72 @@ Scope { property int nextId: 0 property var liveNotifs: ({}) - ListModel { id: popupModel } + ListModel { + id: popupModel + } function removeNotificationData(id) { for (let i = 0; i < popupModel.count; i++) { if (popupModel.get(i).nId === id) { - popupModel.remove(i) - break + popupModel.remove(i); + break; } } - delete liveNotifs[id] + delete liveNotifs[id]; } function dismissExplicitly(id) { - const n = liveNotifs[id] - if (n) n.dismiss() - removeNotificationData(id) + const n = liveNotifs[id]; + if (n) + n.dismiss(); + removeNotificationData(id); } function hidePopup(id) { for (let i = 0; i < popupModel.count; i++) { if (popupModel.get(i).nId === id) { - popupModel.remove(i) - break + popupModel.remove(i); + break; } } } function activateById(id) { - const n = liveNotifs[id] - if (!n) return - - let invoked = false + const n = liveNotifs[id]; + if (!n) + return; + let invoked = false; for (const action of n.actions) { if (action.identifier === "default") { - action.invoke() - invoked = true - break + action.invoke(); + invoked = true; + break; } } if (!invoked && n.desktopEntry) { - Quickshell.execDetached(["gtk-launch", n.desktopEntry]) + Quickshell.execDetached(["gtk-launch", n.desktopEntry]); } - dismissExplicitly(id) + dismissExplicitly(id); } function invokeAction(id, identifier) { - const n = liveNotifs[id] + const n = liveNotifs[id]; if (n) { for (const action of n.actions) { if (action.identifier === identifier) { - action.invoke() - break + action.invoke(); + break; } } } - dismissExplicitly(id) + dismissExplicitly(id); } function sendReply(id, text) { - const n = liveNotifs[id] - if (n && n.hasInlineReply) n.sendInlineReply(text) - dismissExplicitly(id) + const n = liveNotifs[id]; + if (n && n.hasInlineReply) + n.sendInlineReply(text); + dismissExplicitly(id); } NotificationServer { @@ -87,34 +91,38 @@ Scope { persistenceSupported: true onNotification: notif => { - notif.tracked = true + notif.tracked = true; - const id = nextId - nextId = nextId + 1 - liveNotifs[id] = notif + const id = nextId; + nextId = nextId + 1; + liveNotifs[id] = notif; - const acts = [] - let hasDefault = false + const acts = []; + let hasDefault = false; for (const a of notif.actions) { - if (a.identifier === "default") hasDefault = true - else acts.push({ identifier: a.identifier, text: a.text }) + if (a.identifier === "default") + hasDefault = true; + else + acts.push({ + identifier: a.identifier, + text: a.text + }); } - notif.closed.connect(() => removeNotificationData(id)) + notif.closed.connect(() => removeNotificationData(id)); - let formattedAppIcon = notif.appIcon || "" + let formattedAppIcon = notif.appIcon || ""; if (formattedAppIcon !== "") { - if (formattedAppIcon.startsWith("file://")) { - } else if (formattedAppIcon.startsWith("/")) { - formattedAppIcon = "file://" + formattedAppIcon + if (formattedAppIcon.startsWith("file://")) {} else if (formattedAppIcon.startsWith("/")) { + formattedAppIcon = "file://" + formattedAppIcon; } else { - formattedAppIcon = `image://icon/${formattedAppIcon}` + formattedAppIcon = `image://icon/${formattedAppIcon}`; } } - let formattedImage = notif.image || "" + let formattedImage = notif.image || ""; if (formattedImage !== "" && formattedImage.startsWith("/")) { - formattedImage = "file://" + formattedImage + formattedImage = "file://" + formattedImage; } const data = { @@ -131,9 +139,10 @@ Scope { nHasInlineReply: notif.hasInlineReply || false, nReplyPlaceholder: notif.inlineReplyPlaceholder || "Reply", nResident: notif.resident || false - } + }; - popupModel.insert(0, data) + GlobalState.addNotification(data); + popupModel.insert(0, data); } } @@ -146,4 +155,3 @@ Scope { onHideRequested: id => scope.hidePopup(id) } } - |
