OSD: add audio input osd

IPC: add audio input
This commit is contained in:
lysec
2025-10-10 15:08:25 +02:00
parent 338624b4a8
commit acd776a187
2 changed files with 45 additions and 5 deletions
+38 -2
View File
@@ -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
}
}
+7 -3
View File
@@ -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)
}
}