From acd776a187e237d3982a21f8fdbbceeeb1da9a42 Mon Sep 17 00:00:00 2001 From: lysec Date: Fri, 10 Oct 2025 15:08:25 +0200 Subject: [PATCH] OSD: add audio input osd IPC: add audio input --- Modules/OSD/OSD.qml | 40 ++++++++++++++++++++++++++++++++++++++-- Services/IPCService.qml | 10 +++++++--- 2 files changed, 45 insertions(+), 5 deletions(-) diff --git a/Modules/OSD/OSD.qml b/Modules/OSD/OSD.qml index 91c551a8..a4ec5701 100644 --- a/Modules/OSD/OSD.qml +++ b/Modules/OSD/OSD.qml @@ -25,7 +25,7 @@ Variants { active: false // Current OSD display state - property string currentOSDType: "" // "volume", "brightness", or "" + property string currentOSDType: "" // "volume", "inputVolume", "brightness", or "" // Volume properties readonly property real currentVolume: AudioService.volume @@ -33,6 +33,12 @@ Variants { property bool volumeInitialized: false property bool muteInitialized: false + // Input volume properties + readonly property real currentInputVolume: AudioService.inputVolume + readonly property bool isInputMuted: AudioService.inputMuted + property bool inputVolumeInitialized: false + property bool inputMuteInitialized: false + // Brightness properties property bool brightnessInitialized: false readonly property real currentBrightness: { @@ -49,6 +55,11 @@ Variants { return "volume-mute" } return (AudioService.volume <= Number.EPSILON) ? "volume-zero" : (AudioService.volume <= 0.5) ? "volume-low" : "volume-high" + } else if (currentOSDType === "inputVolume") { + if (AudioService.inputMuted) { + return "microphone-off" + } + return "microphone" } else if (currentOSDType === "brightness") { return currentBrightness <= 0.5 ? "brightness-low" : "brightness-high" } @@ -59,6 +70,8 @@ Variants { function getCurrentValue() { if (currentOSDType === "volume") { return isMuted ? 0 : currentVolume + } else if (currentOSDType === "inputVolume") { + return isInputMuted ? 0 : currentInputVolume } else if (currentOSDType === "brightness") { return currentBrightness } @@ -72,6 +85,11 @@ Variants { return "0%" const pct = Math.round(Math.min(1.0, currentVolume) * 100) return pct + "%" + } else if (currentOSDType === "inputVolume") { + if (isInputMuted) + return "0%" + const pct = Math.round(Math.min(1.0, currentInputVolume) * 100) + return pct + "%" } else if (currentOSDType === "brightness") { const pct = Math.round(Math.min(1.0, currentBrightness) * 100) return pct + "%" @@ -85,13 +103,17 @@ Variants { if (isMuted) return Color.mError return Color.mPrimary + } else if (currentOSDType === "inputVolume") { + if (isInputMuted) + return Color.mError + return Color.mPrimary } return Color.mPrimary } // Get icon color function getIconColor() { - if (currentOSDType === "volume" && isMuted) { + if ((currentOSDType === "volume" && isMuted) || (currentOSDType === "inputVolume" && isInputMuted)) { return Color.mError } return Color.mOnSurface @@ -467,6 +489,18 @@ Variants { showOSD("volume") } } + + function onInputVolumeChanged() { + if (inputVolumeInitialized) { + showOSD("inputVolume") + } + } + + function onInputMutedChanged() { + if (inputMuteInitialized) { + showOSD("inputVolume") + } + } } // Timer to initialize volume/mute flags after services are ready @@ -477,6 +511,8 @@ Variants { onTriggered: { volumeInitialized = true muteInitialized = true + inputVolumeInitialized = true + inputMuteInitialized = true } } diff --git a/Services/IPCService.qml b/Services/IPCService.qml index 711d44dd..70999aa1 100644 --- a/Services/IPCService.qml +++ b/Services/IPCService.qml @@ -112,10 +112,14 @@ Item { function muteOutput() { AudioService.setOutputMuted(!AudioService.muted) } + function increaseInput() { + AudioService.increaseInputVolume() + } + function decreaseInput() { + AudioService.decreaseInputVolume() + } function muteInput() { - if (AudioService.source?.ready && AudioService.source?.audio) { - AudioService.source.audio.muted = !AudioService.source.audio.muted - } + AudioService.setInputMuted(!AudioService.inputMuted) } }