Add audoOverdrive to Volume Symbol in bar

This commit is contained in:
Ly-sec 2025-08-13 14:03:02 +02:00
parent 3389cb9a5d
commit e2a0e491a0

View file

@ -28,17 +28,17 @@ Item {
}
function getIconColor() {
return (Audio.volume <= 1.0) ? Colors.textPrimary : getVolumeColor()
return (getDisplayVolume() <= 1.0) ? Colors.textPrimary : getVolumeColor()
}
function getVolumeColor() {
if (Audio.volume <= 1.0) {
if (getDisplayVolume() <= 1.0) {
return Colors.accentPrimary
}
// Indicate that the volume is over 100%
// Calculate interpolation factor (0 at 100%, 1.0 at 200%)
let factor = (Audio.volume - 1.0)
let factor = (getDisplayVolume() - 1.0)
// Blend between accent and warning colors
return Qt.rgba(Colors.accentPrimary.r + (Colors.error.r - Colors.accentPrimary.r) * factor,
@ -46,6 +46,15 @@ Item {
Colors.accentPrimary.b + (Colors.error.b - Colors.accentPrimary.b) * factor, 1)
}
function getDisplayVolume() {
// If volumeOverdrive is false, clamp to 100%
if (!Settings.data.audio || !Settings.data.audio.volumeOverdrive) {
return Math.min(Audio.volume, 1.0)
}
// If volumeOverdrive is true, allow up to 200%
return Math.min(Audio.volume, 2.0)
}
// Connection used to open the pill when volume changes
Connections {
target: Audio.sink?.audio ? Audio.sink?.audio : null
@ -66,9 +75,9 @@ Item {
iconCircleColor: getVolumeColor()
collapsedIconColor: getIconColor()
autoHide: true
text: Math.round(Audio.volume * 100) + "%"
text: Math.round(getDisplayVolume() * 100) + "%"
tooltipText: "Volume: " + Math.round(
Audio.volume * 100) + "%\nLeft click for advanced settings.\nScroll up/down to change volume."
getDisplayVolume() * 100) + "%\nLeft click for advanced settings.\nScroll up/down to change volume."
onWheel: function (angle) {
if (angle > 0) {