1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-04-03 20:32:07 -04:00

audio: add per-device max volume limit setting

This commit is contained in:
bbedward
2026-02-09 09:26:34 -05:00
parent fce120fa31
commit 1ed44ee6f3
10 changed files with 197 additions and 63 deletions

View File

@@ -121,6 +121,8 @@ Singleton {
property string vpnLastConnected: ""
property var deviceMaxVolumes: ({})
Component.onCompleted: {
if (!isGreeterMode) {
loadSettings();
@@ -1052,6 +1054,35 @@ Singleton {
saveSettings();
}
function setDeviceMaxVolume(nodeName, maxPercent) {
if (!nodeName)
return;
const updated = Object.assign({}, deviceMaxVolumes);
const clamped = Math.max(100, Math.min(200, Math.round(maxPercent)));
if (clamped === 100) {
delete updated[nodeName];
} else {
updated[nodeName] = clamped;
}
deviceMaxVolumes = updated;
saveSettings();
}
function getDeviceMaxVolume(nodeName) {
if (!nodeName)
return 100;
return deviceMaxVolumes[nodeName] ?? 100;
}
function removeDeviceMaxVolume(nodeName) {
if (!nodeName)
return;
const updated = Object.assign({}, deviceMaxVolumes);
delete updated[nodeName];
deviceMaxVolumes = updated;
saveSettings();
}
function syncWallpaperForCurrentMode() {
if (!perModeWallpaper)
return;