1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-06-15 15:45:20 -04:00

feat(media-control): support scroll and right-click on audio output devices in media popout (#2615)

* feat(media-control): support scroll and right-click on audio output devices in media popout

* feat(media-control): make device list volume scrolling optional
This commit is contained in:
Huỳnh Thiện Lộc
2026-06-14 04:51:03 +07:00
committed by GitHub
parent 3701b3d7a3
commit 9d1a81c93c
7 changed files with 86 additions and 7 deletions
+35 -2
View File
@@ -58,6 +58,8 @@ Singleton {
return SessionData.deviceMaxVolumes[name] ?? 100;
}
readonly property int wheelVolumeStep: SettingsData.audioWheelScrollAmount
signal micMuteChanged
signal audioOutputCycled(string deviceName, string deviceIcon)
signal deviceAliasChanged(string nodeName, string newAlias)
@@ -156,14 +158,19 @@ Singleton {
return false;
}
function cycleAudioOutput() {
function cycleAudioOutputDirection(forward) {
const sinks = getAvailableSinks();
if (sinks.length < 2)
return null;
const currentName = root.sink?.name ?? "";
const currentIndex = sinks.findIndex(s => s.name === currentName);
const nextIndex = (currentIndex + 1) % sinks.length;
let nextIndex;
if (forward) {
nextIndex = (currentIndex + 1) % sinks.length;
} else {
nextIndex = (currentIndex - 1 + sinks.length) % sinks.length;
}
const nextSink = sinks[nextIndex];
setDefaultSinkByName(nextSink.name);
const name = displayName(nextSink);
@@ -171,6 +178,10 @@ Singleton {
return name;
}
function cycleAudioOutput() {
return cycleAudioOutputDirection(true);
}
function getDeviceAlias(nodeName) {
if (!nodeName)
return null;
@@ -833,6 +844,28 @@ EOFCONFIG
return root.sink.audio.muted ? "Audio muted" : "Audio unmuted";
}
function handleNodeVolumeWheel(node, wheelEvent) {
if (!node?.audio)
return;
SessionData.suppressOSDTemporarily();
const delta = wheelEvent.angleDelta.y;
if (delta === 0)
return;
const current = Math.round(node.audio.volume * 100);
const maxVol = getMaxVolumePercent(node);
const newVolume = delta > 0 ? Math.min(maxVol, current + root.wheelVolumeStep) : Math.max(0, current - root.wheelVolumeStep);
node.audio.muted = false;
node.audio.volume = newVolume / 100;
if (node === sink) {
playVolumeChangeSoundIfEnabled();
}
wheelEvent.accepted = true;
}
function setMicVolume(percentage) {
if (!root.source?.audio) {
return "No audio source available";