notifications: centralize icon resolution in NotifItem.resolvedIcon, fix lock pill grouping and missing fallbacks

This commit is contained in:
Damocles 2026-04-29 17:58:26 +02:00
parent 99b63a2756
commit d4001f7900
4 changed files with 23 additions and 32 deletions

View file

@ -1,5 +1,4 @@
import QtQuick import QtQuick
import Quickshell
import "../services" as S import "../services" as S
import "../modules" as M import "../modules" as M
@ -76,12 +75,14 @@ Column {
if (!map[key]) if (!map[key])
map[key] = { map[key] = {
appName: key, appName: key,
appIcon: n.appIcon, resolvedIcon: "",
notifs: [], notifs: [],
maxUrgency: 0, maxUrgency: 0,
maxTime: 0 maxTime: 0
}; };
map[key].notifs.push(n); map[key].notifs.push(n);
if (!map[key].resolvedIcon && n.resolvedIcon)
map[key].resolvedIcon = n.resolvedIcon;
if (n.urgency > map[key].maxUrgency) if (n.urgency > map[key].maxUrgency)
map[key].maxUrgency = n.urgency; map[key].maxUrgency = n.urgency;
if (n.time > map[key].maxTime) if (n.time > map[key].maxTime)
@ -101,7 +102,7 @@ Column {
arr.push({ arr.push({
type: "header", type: "header",
appName: g.appName, appName: g.appName,
appIcon: g.appIcon, resolvedIcon: g.resolvedIcon,
count: g.notifs.length, count: g.notifs.length,
collapsed: collapsed, collapsed: collapsed,
summaries: g.notifs.map(n => n.summary || "") summaries: g.notifs.map(n => n.summary || "")
@ -299,14 +300,7 @@ Column {
anchors.topMargin: (28 - height) / 2 anchors.topMargin: (28 - height) / 2
width: S.Theme.fontSize + 2 width: S.Theme.fontSize + 2
height: S.Theme.fontSize + 2 height: S.Theme.fontSize + 2
source: { source: notifDelegate._type === "header" ? (notifDelegate.modelData.resolvedIcon || "") : ""
if (notifDelegate._type !== "header")
return "";
const ic = notifDelegate.modelData.appIcon;
if (!ic)
return "";
return (ic.startsWith("/") || ic.startsWith("file://")) ? ic : Quickshell.iconPath(ic, "dialog-information");
}
visible: status === Image.Ready visible: status === Image.Ready
fillMode: Image.PreserveAspectFit fillMode: Image.PreserveAspectFit
sourceSize: Qt.size(S.Theme.fontSize + 2, S.Theme.fontSize + 2) sourceSize: Qt.size(S.Theme.fontSize + 2, S.Theme.fontSize + 2)

View file

@ -1,5 +1,4 @@
import QtQuick import QtQuick
import Quickshell
import "../services" as S import "../services" as S
Row { Row {
@ -12,13 +11,15 @@ Row {
const notifs = S.NotifService.list.filter(n => n.state !== "dismissed"); const notifs = S.NotifService.list.filter(n => n.state !== "dismissed");
const groups = {}; const groups = {};
for (const n of notifs) { for (const n of notifs) {
const key = n.appIcon || n.appName || "unknown"; const key = n.appName || "unknown";
if (!groups[key]) if (!groups[key])
groups[key] = { groups[key] = {
icon: n.appIcon, resolvedIcon: "",
name: n.appName, name: n.appName,
count: 0 count: 0
}; };
if (!groups[key].resolvedIcon && n.resolvedIcon)
groups[key].resolvedIcon = n.resolvedIcon;
groups[key].count++; groups[key].count++;
} }
return Object.values(groups); return Object.values(groups);
@ -62,14 +63,7 @@ Row {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
width: 14 width: 14
height: 14 height: 14
source: { source: _pill.modelData.resolvedIcon || ""
const icon = _pill.modelData.icon;
if (!icon)
return "";
if (icon.startsWith("/"))
return icon;
return Quickshell.iconPath(icon) ?? "";
}
sourceSize: Qt.size(14, 14) sourceSize: Qt.size(14, 14)
visible: source !== "" visible: source !== ""
} }

View file

@ -1,5 +1,4 @@
import QtQuick import QtQuick
import Quickshell
import Quickshell.Services.Notifications import Quickshell.Services.Notifications
import "." as M import "." as M
import "../services" as S import "../services" as S
@ -87,15 +86,7 @@ Item {
anchors.topMargin: 8 anchors.topMargin: 8
width: root.iconSize width: root.iconSize
height: root.iconSize height: root.iconSize
source: { source: root.notif?.resolvedIcon ?? ""
const img = root.notif?.image;
if (img)
return img;
const ic = root.notif?.appIcon;
if (!ic)
return "";
return (ic.startsWith("/") || ic.startsWith("file://")) ? ic : Quickshell.iconPath(ic, "dialog-information");
}
visible: status === Image.Ready visible: status === Image.Ready
fillMode: Image.PreserveAspectFit fillMode: Image.PreserveAspectFit
sourceSize: Qt.size(root.iconSize, root.iconSize) sourceSize: Qt.size(root.iconSize, root.iconSize)

View file

@ -1,4 +1,5 @@
import QtQuick import QtQuick
import Quickshell
import Quickshell.Services.Notifications import Quickshell.Services.Notifications
import "." as S import "." as S
@ -20,6 +21,17 @@ QtObject {
property var actions: [] property var actions: []
property real time: Date.now() property real time: Date.now()
// Resolved icon URL - checks image first, then resolves appIcon via XDG lookup
readonly property string resolvedIcon: {
if (image)
return image;
if (!appIcon)
return "";
if (appIcon.startsWith("/") || appIcon.startsWith("file://"))
return appIcon;
return Quickshell.iconPath(appIcon, "dialog-information");
}
// Expire timer owned by this item, not dynamically created // Expire timer owned by this item, not dynamically created
readonly property Timer _expireTimer: Timer { readonly property Timer _expireTimer: Timer {
running: false running: false