OSD: add overdrive display

Volume/Microphone: allow overdrive, clamp to 100/150% max
AudioService: properly clamp to 100/150% (not only visually)
This commit is contained in:
Ly-sec
2025-11-19 23:27:42 +01:00
parent 19672a3d46
commit 074da9069c
4 changed files with 75 additions and 5 deletions
+10 -2
View File
@@ -134,12 +134,20 @@ Item {
icon: AudioService.getInputIcon()
density: Settings.data.bar.density
autoHide: false // Important to be false so we can hover as long as we want
text: Math.round(AudioService.inputVolume * 100)
text: {
const maxVolume = Settings.data.audio.volumeOverdrive ? 1.5 : 1.0;
const displayVolume = Math.min(maxVolume, AudioService.inputVolume);
return Math.round(displayVolume * 100);
}
suffix: "%"
forceOpen: displayMode === "alwaysShow"
forceClose: displayMode === "alwaysHide"
tooltipText: I18n.tr("tooltips.microphone-volume-at", {
"volume": Math.round(AudioService.inputVolume * 100)
"volume": (() => {
const maxVolume = Settings.data.audio.volumeOverdrive ? 1.5 : 1.0;
const displayVolume = Math.min(maxVolume, AudioService.inputVolume);
return Math.round(displayVolume * 100);
})()
})
onWheel: function (delta) {
+10 -2
View File
@@ -117,12 +117,20 @@ Item {
oppositeDirection: BarService.getPillDirection(root)
icon: AudioService.getOutputIcon()
autoHide: false // Important to be false so we can hover as long as we want
text: Math.round(AudioService.volume * 100)
text: {
const maxVolume = Settings.data.audio.volumeOverdrive ? 1.5 : 1.0;
const displayVolume = Math.min(maxVolume, AudioService.volume);
return Math.round(displayVolume * 100);
}
suffix: "%"
forceOpen: displayMode === "alwaysShow"
forceClose: displayMode === "alwaysHide"
tooltipText: I18n.tr("tooltips.volume-at", {
"volume": Math.round(AudioService.volume * 100)
"volume": (() => {
const maxVolume = Settings.data.audio.volumeOverdrive ? 1.5 : 1.0;
const displayVolume = Math.min(maxVolume, AudioService.volume);
return Math.round(displayVolume * 100);
})()
})
onWheel: function (delta) {
+15 -1
View File
@@ -73,13 +73,27 @@ Variants {
function getDisplayPercentage() {
const value = getCurrentValue();
const max = getMaxValue();
if ((currentOSDType === "volume" || currentOSDType === "inputVolume") && Settings.data.audio.volumeOverdrive) {
const pct = Math.round(value * 100);
return pct + "%";
}
const pct = Math.round(Math.min(max, value) * 100);
return pct + "%";
}
function getProgressColor() {
const isMutedState = (currentOSDType === "volume" && isMuted) || (currentOSDType === "inputVolume" && isInputMuted);
return isMutedState ? Color.mError : Color.mPrimary;
if (isMutedState) {
return Color.mError;
}
// When volumeOverdrive is enabled, show error color if volume is above 100%
if ((currentOSDType === "volume" || currentOSDType === "inputVolume") && Settings.data.audio.volumeOverdrive) {
const value = getCurrentValue();
if (value > 1.0) {
return Color.mError;
}
}
return Color.mPrimary;
}
function getIconColor() {