diff --git a/Modules/OSD/OSD.qml b/Modules/OSD/OSD.qml index 8275689ba..e32d4670a 100644 --- a/Modules/OSD/OSD.qml +++ b/Modules/OSD/OSD.qml @@ -37,6 +37,7 @@ Variants { property bool startupComplete: false property real currentBrightness: 0 property string customText: "" + property string customIcon: "" // Lock Key States property string lastLockKeyChanged: "" // "caps", "num", "scroll", or "" @@ -51,13 +52,17 @@ Variants { // LockKey OSD enabled state (reactive to settings) readonly property bool lockKeyOSDEnabled: { const enabledTypes = Settings.data.osd.enabledTypes || []; - // If enabledTypes is empty, no types are enabled (no OSD will be shown) if (enabledTypes.length === 0) return false; return enabledTypes.includes(OSD.Type.LockKey); } - // Helper Functions + readonly property var validIcons: { + const iconKeys = Object.keys(Icons.icons); + const aliasKeys = Object.keys(Icons.aliases); + return new Set([...iconKeys, ...aliasKeys]); + } + function getIcon() { switch (currentOSDType) { case OSD.Type.Volume: @@ -77,7 +82,7 @@ Variants { case OSD.Type.LockKey: return "keyboard"; case OSD.Type.CustomText: - return "info-circle"; + return root.customIcon || "info-circle"; default: return ""; } @@ -232,15 +237,23 @@ Variants { } // Signal Connections - Connections { - target: OSDService + Connections { + target: OSDService - function onShowCustomText(text) { - root.customText = text; - showOSD(OSD.Type.CustomText); + function onShowCustomText(text, icon) { + root.customText = text; + + if (icon && root.validIcons.has(icon)) { + root.customIcon = icon; + } else { + if (icon) { + Logger.w("OSD", "Invalid custom icon name received: '" + icon + "'. Falling back to default."); + } + root.customIcon = "info-circle"; } + showOSD(OSD.Type.CustomText); } - + } // AudioService monitoring Connections { @@ -524,8 +537,9 @@ Variants { onTriggered: { osdItem.visible = false; root.currentOSDType = -1; - root.lastLockKeyChanged = ""; // Reset the lock key change indicator + root.lastLockKeyChanged = ""; root.customText = ""; + root.customIcon = ""; root.active = false; } } diff --git a/Services/Control/IPCService.qml b/Services/Control/IPCService.qml index 00dee25ff..0079da0e7 100644 --- a/Services/Control/IPCService.qml +++ b/Services/Control/IPCService.qml @@ -380,8 +380,8 @@ Item { IpcHandler { target: "osd" - function showText(text: string) { - OSDService.showCustomText(text); + function showText(text: string, icon: string) { + OSDService.showCustomText(text, icon || ""); } } diff --git a/Services/UI/OSDService.qml b/Services/UI/OSDService.qml index 25f89642e..0156b62eb 100644 --- a/Services/UI/OSDService.qml +++ b/Services/UI/OSDService.qml @@ -6,5 +6,5 @@ import Quickshell Singleton { id: root - signal showCustomText(string text) + signal showCustomText(string text, string icon) }