AudioCard/Panel: add one-shot timer to prevent 100% volume on startup

This commit is contained in:
Ly-sec
2025-11-11 15:16:32 +01:00
parent 3c8a49d7c0
commit bd0ddda7c6
2 changed files with 62 additions and 14 deletions
+31 -7
View File
@@ -39,15 +39,23 @@ SmartPanel {
}
}
// Timer to debounce volume changes
// Debounce timers to avoid forcing PipeWire volume on startup
Timer {
id: outputDebounceTimer
interval: 100
running: true
repeat: true
repeat: false
onTriggered: {
if (Math.abs(localOutputVolume - AudioService.volume) >= 0.01) {
AudioService.setVolume(localOutputVolume)
}
}
}
Timer {
id: inputDebounceTimer
interval: 100
repeat: false
onTriggered: {
if (Math.abs(localInputVolume - AudioService.inputVolume) >= 0.01) {
AudioService.setInputVolume(localInputVolume)
}
@@ -164,8 +172,16 @@ SmartPanel {
value: localOutputVolume
stepSize: 0.01
heightRatio: 0.5
onMoved: value => localOutputVolume = value
onPressedChanged: (pressed, value) => localOutputVolumeChanging = pressed
onMoved: value => {
localOutputVolume = value
outputDebounceTimer.restart()
}
onPressedChanged: (pressed, value) => {
localOutputVolumeChanging = pressed
if (!pressed) {
outputDebounceTimer.restart()
}
}
text: Math.round(localOutputVolume * 100) + "%"
Layout.bottomMargin: Style.marginM
}
@@ -221,8 +237,16 @@ SmartPanel {
value: localInputVolume
stepSize: 0.01
heightRatio: 0.5
onMoved: value => localInputVolume = value
onPressedChanged: (pressed, value) => localInputVolumeChanging = pressed
onMoved: value => {
localInputVolume = value
inputDebounceTimer.restart()
}
onPressedChanged: (pressed, value) => {
localInputVolumeChanging = pressed
if (!pressed) {
inputDebounceTimer.restart()
}
}
text: Math.round(localInputVolume * 100) + "%"
Layout.bottomMargin: Style.marginM
}