From bcb0b3df39608db0384dc3a8df29236c8bd5271f Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Sat, 10 May 2025 23:25:38 +1000 Subject: notifs: all notifs have icon Guess icon or default --- modules/notifications/Notification.qml | 59 ++++++++++++++++++++++++++++++---- 1 file changed, 52 insertions(+), 7 deletions(-) (limited to 'modules') diff --git a/modules/notifications/Notification.qml b/modules/notifications/Notification.qml index a6329e3..bacf192 100644 --- a/modules/notifications/Notification.qml +++ b/modules/notifications/Notification.qml @@ -98,8 +98,8 @@ StyledRect { anchors.left: parent.left anchors.top: parent.top - width: root.hasImage || root.hasAppIcon ? root.imageSize : 0 - height: root.hasImage || root.hasAppIcon ? root.imageSize : 0 + width: root.imageSize + height: root.imageSize visible: root.hasImage || root.hasAppIcon sourceComponent: ClippingRectangle { @@ -120,7 +120,7 @@ StyledRect { Loader { id: appIcon - active: root.hasAppIcon + active: root.hasAppIcon || !root.hasImage asynchronous: true anchors.horizontalCenter: root.hasImage ? undefined : image.horizontalCenter @@ -134,14 +134,23 @@ StyledRect { implicitWidth: root.hasImage ? NotifsConfig.sizes.badge : root.imageSize implicitHeight: root.hasImage ? NotifsConfig.sizes.badge : root.imageSize - IconImage { + Loader { id: icon + active: root.hasAppIcon + asynchronous: true + anchors.centerIn: parent visible: !root.modelData.appIcon.includes("symbolic") - implicitSize: Math.round(parent.width * 0.6) - source: Quickshell.iconPath(root.modelData.appIcon) - asynchronous: true + + width: Math.round(parent.width * 0.6) + height: Math.round(parent.width * 0.6) + + sourceComponent: IconImage { + implicitSize: Math.round(parent.width * 0.6) + source: Quickshell.iconPath(root.modelData.appIcon) + asynchronous: true + } } Loader { @@ -154,6 +163,42 @@ StyledRect { colorizationColor: root.modelData.urgency === NotificationUrgency.Critical ? Colours.palette.m3onError : root.modelData.urgency === NotificationUrgency.Low ? Colours.palette.m3onSurface : Colours.palette.m3onTertiaryContainer } } + + Loader { + active: !root.hasAppIcon + asynchronous: true + anchors.centerIn: parent + + sourceComponent: MaterialIcon { + text: { + const summary = root.modelData.summary.toLowerCase(); + if (summary.includes("reboot")) + return "restart_alt"; + if (summary.includes("recording")) + return "screen_record"; + if (summary.includes("battery")) + return "power"; + if (summary.includes("screenshot")) + return "screenshot_monitor"; + if (summary.includes("welcome")) + return "waving_hand"; + if (summary.includes("time")) + return "schedule"; + if (summary.includes("installed")) + return "download"; + if (summary.includes("update")) + return "update"; + if (summary.startsWith("file")) + return "folder_copy"; + if (root.modelData.urgency === NotificationUrgency.Critical) + return "release_alert"; + return "chat"; + } + + color: root.modelData.urgency === NotificationUrgency.Critical ? Colours.palette.m3onError : root.modelData.urgency === NotificationUrgency.Low ? Colours.palette.m3onSurface : Colours.palette.m3onTertiaryContainer + font.pointSize: Appearance.font.size.large + } + } } } -- cgit v1.2.3-freya