diff --git a/quickshell/Common/Paths.qml b/quickshell/Common/Paths.qml index ffc23224..ee50cefb 100644 --- a/quickshell/Common/Paths.qml +++ b/quickshell/Common/Paths.qml @@ -71,15 +71,40 @@ Singleton { return appId; } + function resolveIconPath(iconName: string): string { + if (!iconName) return ""; + const moddedId = moddedAppId(iconName); + if (moddedId !== iconName) { + if (moddedId.startsWith("~") || moddedId.startsWith("/")) + return toFileUrl(expandTilde(moddedId)); + if (moddedId.startsWith("file://")) + return moddedId; + return Quickshell.iconPath(moddedId, true); + } + return Quickshell.iconPath(iconName, true) || DesktopService.resolveIconPath(iconName); + } + + function resolveIconUrl(iconName: string): string { + if (!iconName) return ""; + const moddedId = moddedAppId(iconName); + if (moddedId !== iconName) { + if (moddedId.startsWith("~") || moddedId.startsWith("/")) + return toFileUrl(expandTilde(moddedId)); + if (moddedId.startsWith("file://")) + return moddedId; + return "image://icon/" + moddedId; + } + return "image://icon/" + iconName; + } + function getAppIcon(appId: string, desktopEntry: var): string { if (appId === "org.quickshell") { return Qt.resolvedUrl("../assets/danklogo.svg"); } const moddedId = moddedAppId(appId); - if (moddedId !== appId) { - return Quickshell.iconPath(moddedId, true); - } + if (moddedId !== appId) + return resolveIconPath(appId); if (desktopEntry && desktopEntry.icon) { return Quickshell.iconPath(desktopEntry.icon, true); diff --git a/quickshell/Modals/DankLauncherV2/LauncherContent.qml b/quickshell/Modals/DankLauncherV2/LauncherContent.qml index f7b85907..20e8ddf1 100644 --- a/quickshell/Modals/DankLauncherV2/LauncherContent.qml +++ b/quickshell/Modals/DankLauncherV2/LauncherContent.qml @@ -643,7 +643,7 @@ FocusScope { Image { width: 40 height: 40 - source: editingApp?.icon ? "image://icon/" + editingApp.icon : "image://icon/application-x-executable" + source: Paths.resolveIconUrl(editingApp?.icon || "application-x-executable") sourceSize.width: 40 sourceSize.height: 40 fillMode: Image.PreserveAspectFit diff --git a/quickshell/Modules/DankBar/Widgets/AppsDockContextMenu.qml b/quickshell/Modules/DankBar/Widgets/AppsDockContextMenu.qml index 166befce..e6c6b185 100644 --- a/quickshell/Modules/DankBar/Widgets/AppsDockContextMenu.qml +++ b/quickshell/Modules/DankBar/Widgets/AppsDockContextMenu.qml @@ -273,7 +273,7 @@ PanelWindow { IconImage { anchors.fill: parent - source: modelData.icon ? Quickshell.iconPath(modelData.icon, true) : "" + source: modelData.icon ? Paths.resolveIconPath(modelData.icon) : "" smooth: true asynchronous: true visible: status === Image.Ready diff --git a/quickshell/Modules/Dock/DockContextMenu.qml b/quickshell/Modules/Dock/DockContextMenu.qml index fa2a1a36..50a144c3 100644 --- a/quickshell/Modules/Dock/DockContextMenu.qml +++ b/quickshell/Modules/Dock/DockContextMenu.qml @@ -329,7 +329,7 @@ PanelWindow { IconImage { anchors.fill: parent - source: modelData.icon ? Quickshell.iconPath(modelData.icon, true) : "" + source: modelData.icon ? Paths.resolveIconPath(modelData.icon) : "" smooth: true asynchronous: true visible: status === Image.Ready diff --git a/quickshell/Modules/Notifications/Center/HistoryNotificationCard.qml b/quickshell/Modules/Notifications/Center/HistoryNotificationCard.qml index 7e9e8bcb..ef735e3d 100644 --- a/quickshell/Modules/Notifications/Center/HistoryNotificationCard.qml +++ b/quickshell/Modules/Notifications/Center/HistoryNotificationCard.qml @@ -127,7 +127,7 @@ Rectangle { return appIcon; if (appIcon.startsWith("material:") || appIcon.startsWith("svg:") || appIcon.startsWith("unicode:") || appIcon.startsWith("image:")) return ""; - return Quickshell.iconPath(appIcon, true); + return Paths.resolveIconPath(appIcon); } hasImage: hasNotificationImage diff --git a/quickshell/Modules/Notifications/Center/NotificationCard.qml b/quickshell/Modules/Notifications/Center/NotificationCard.qml index af16d986..0fd23bf4 100644 --- a/quickshell/Modules/Notifications/Center/NotificationCard.qml +++ b/quickshell/Modules/Notifications/Center/NotificationCard.qml @@ -174,7 +174,7 @@ Rectangle { return appIcon; if (appIcon.startsWith("material:") || appIcon.startsWith("svg:") || appIcon.startsWith("unicode:") || appIcon.startsWith("image:")) return ""; - return Quickshell.iconPath(appIcon, true); + return Paths.resolveIconPath(appIcon); } hasImage: hasNotificationImage @@ -508,7 +508,7 @@ Rectangle { return appIcon; if (appIcon.startsWith("material:") || appIcon.startsWith("svg:") || appIcon.startsWith("unicode:") || appIcon.startsWith("image:")) return ""; - return Quickshell.iconPath(appIcon, true); + return Paths.resolveIconPath(appIcon); } fallbackIcon: { diff --git a/quickshell/Modules/Notifications/Popup/NotificationPopup.qml b/quickshell/Modules/Notifications/Popup/NotificationPopup.qml index cf4f4e75..b5b2d6ee 100644 --- a/quickshell/Modules/Notifications/Popup/NotificationPopup.qml +++ b/quickshell/Modules/Notifications/Popup/NotificationPopup.qml @@ -484,7 +484,7 @@ PanelWindow { return appIcon; if (appIcon.startsWith("material:") || appIcon.startsWith("svg:") || appIcon.startsWith("unicode:") || appIcon.startsWith("image:")) return ""; - return Quickshell.iconPath(appIcon, true); + return Paths.resolveIconPath(appIcon); } hasImage: hasNotificationImage diff --git a/quickshell/Modules/Settings/LauncherTab.qml b/quickshell/Modules/Settings/LauncherTab.qml index e6bd6546..e71b29d4 100644 --- a/quickshell/Modules/Settings/LauncherTab.qml +++ b/quickshell/Modules/Settings/LauncherTab.qml @@ -897,7 +897,7 @@ Item { Image { width: 24 height: 24 - source: modelData.icon ? "image://icon/" + modelData.icon : "image://icon/application-x-executable" + source: Paths.resolveIconUrl(modelData.icon || "application-x-executable") sourceSize.width: 24 sourceSize.height: 24 fillMode: Image.PreserveAspectFit @@ -1008,7 +1008,7 @@ Item { Image { width: 24 height: 24 - source: modelData.icon ? "image://icon/" + modelData.icon : "image://icon/application-x-executable" + source: Paths.resolveIconUrl(modelData.icon || "application-x-executable") sourceSize.width: 24 sourceSize.height: 24 fillMode: Image.PreserveAspectFit @@ -1154,7 +1154,7 @@ Item { Image { width: 24 height: 24 - source: modelData.icon ? "image://icon/" + modelData.icon : "image://icon/application-x-executable" + source: Paths.resolveIconUrl(modelData.icon || "application-x-executable") sourceSize.width: 24 sourceSize.height: 24 fillMode: Image.PreserveAspectFit diff --git a/quickshell/Widgets/AppIconRenderer.qml b/quickshell/Widgets/AppIconRenderer.qml index 7090ce34..8bb960b5 100644 --- a/quickshell/Widgets/AppIconRenderer.qml +++ b/quickshell/Widgets/AppIconRenderer.qml @@ -49,15 +49,7 @@ Item { readonly property string iconPath: { if (hasSpecialPrefix || !iconValue) return ""; - const moddedId = Paths.moddedAppId(iconValue); - if (moddedId !== iconValue) { - if (moddedId.startsWith("~") || moddedId.startsWith("/")) - return Paths.toFileUrl(Paths.expandTilde(moddedId)); - if (moddedId.startsWith("file://")) - return moddedId; - return Quickshell.iconPath(moddedId, true); - } - return Quickshell.iconPath(iconValue, true) || DesktopService.resolveIconPath(iconValue); + return Paths.resolveIconPath(iconValue); } visible: iconValue !== undefined && iconValue !== ""