94 lines
4.5 KiB
Diff
94 lines
4.5 KiB
Diff
From 79d010f4bcdb19d5a19d222dd3c3cb581fde891d Mon Sep 17 00:00:00 2001
|
||
From: David Redondo <kde@david-redondo.de>
|
||
Date: Fri, 17 Oct 2025 15:15:51 +0200
|
||
Subject: [PATCH] applets/taskmanager: Allow changing a tasks volume by
|
||
scrolling
|
||
|
||
FEATURE:510668
|
||
FIXED-IN:6.6
|
||
---
|
||
.../package/contents/config/main.xml | 1 +
|
||
.../package/contents/ui/ConfigBehavior.qml | 3 ++-
|
||
.../package/contents/ui/MouseHandler.qml | 20 +++++++++++++++++++
|
||
3 files changed, 23 insertions(+), 1 deletion(-)
|
||
|
||
diff --git a/applets/taskmanager/package/contents/config/main.xml b/applets/taskmanager/package/contents/config/main.xml
|
||
index f71a7a8457..8c3b68785b 100644
|
||
--- a/applets/taskmanager/package/contents/config/main.xml
|
||
+++ b/applets/taskmanager/package/contents/config/main.xml
|
||
@@ -90,6 +90,7 @@
|
||
<choice name="None"/>
|
||
<choice name="AllTask"/>
|
||
<choice name="TaskOnly"/>
|
||
+ <choice name="AdjustVolume"/>
|
||
</choices>
|
||
<default>0</default>
|
||
</entry>
|
||
diff --git a/applets/taskmanager/package/contents/ui/ConfigBehavior.qml b/applets/taskmanager/package/contents/ui/ConfigBehavior.qml
|
||
index 2c0dc19154..73357e9dcd 100644
|
||
--- a/applets/taskmanager/package/contents/ui/ConfigBehavior.qml
|
||
+++ b/applets/taskmanager/package/contents/ui/ConfigBehavior.qml
|
||
@@ -202,13 +202,14 @@ KCMUtils.SimpleKCM {
|
||
|
||
QQC2.ComboBox {
|
||
id: wheelEnabled
|
||
- Kirigami.FormData.label: i18nc("@label:listbox Part of a sentence: 'Scrolling behavior does nothing/cycles through tasks/cycles through the selected task's windows'", "Scrolling behavior:")
|
||
+ Kirigami.FormData.label: i18nc("@label:listbox Part of a sentence: 'Scrolling behavior does nothing/cycles through tasks/cycles through the selected task's windows/adjusts the hovered task’s volume''", "Scrolling behavior:")
|
||
Layout.fillWidth: true
|
||
Layout.minimumWidth: Kirigami.Units.gridUnit * 14
|
||
model: [
|
||
i18nc("@item:inlistbox Part of a sentence: 'Scrolling behavior does nothing'", "Does nothing"),
|
||
i18nc("@item:inlistbox Part of a sentence: 'Scrolling behavior cycles through all tasks'", "Cycles through all tasks"),
|
||
i18nc("@item:inlistbox Part of a sentence: 'Scrolling behavior cycles through the hovered task's windows'", "Cycles through the hovered task’s windows"),
|
||
+ i18nc("@item:inlistbox Part of a sentence: 'Scrolling behavior adjusts the hovered task’s volume'", "Adjusts the hovered task’s volume"),
|
||
]
|
||
}
|
||
|
||
diff --git a/applets/taskmanager/package/contents/ui/MouseHandler.qml b/applets/taskmanager/package/contents/ui/MouseHandler.qml
|
||
index cf2362835a..3f8d703d73 100644
|
||
--- a/applets/taskmanager/package/contents/ui/MouseHandler.qml
|
||
+++ b/applets/taskmanager/package/contents/ui/MouseHandler.qml
|
||
@@ -8,6 +8,7 @@ import QtQuick
|
||
|
||
import org.kde.taskmanager as TaskManager
|
||
import org.kde.plasma.plasmoid
|
||
+import org.kde.plasma.private.volume as PlasmaPa
|
||
|
||
import "code/tools.js" as TaskTools
|
||
|
||
@@ -157,6 +158,10 @@ DropArea {
|
||
}
|
||
}
|
||
|
||
+ PlasmaPa.GlobalConfig {
|
||
+ id: plasmaPaConfig
|
||
+ }
|
||
+
|
||
WheelHandler {
|
||
id: wheelHandler
|
||
|
||
@@ -179,6 +184,21 @@ DropArea {
|
||
increment--;
|
||
}
|
||
const anchor = dropArea.target.childAt(event.x, event.y);
|
||
+ if (Plasmoid.configuration.wheelEnabled === 3) {
|
||
+ const loudest = anchor?.audioStreams?.reduce((loudest, stream) => Math.max(loudest, stream.volume), 0)
|
||
+ const step = (pulseAudio.item.normalVolume - pulseAudio.item.minimalVolume) * plasmaPaConfig.volumeStep / 100;
|
||
+ anchor?.audioStreams?.forEach((stream) => {
|
||
+ let delta = step * increment;
|
||
+ if (loudest > 0) {
|
||
+ delta *= stream.volume / loudest;
|
||
+ }
|
||
+ const volume = stream.volume + delta;
|
||
+ console.log(volume, Math.max(pulseAudio.item.minimalVolume, Math.min(volume, pulseAudio.item.normalVolume)));
|
||
+ stream.model.Volume = Math.max(pulseAudio.item.minimalVolume, Math.min(volume, pulseAudio.item.normalVolume));
|
||
+ stream.model.Muted = volume === 0
|
||
+ })
|
||
+ return;
|
||
+ }
|
||
while (increment !== 0) {
|
||
TaskTools.activateNextPrevTask(anchor, increment < 0, Plasmoid.configuration.wheelSkipMinimized, Plasmoid.configuration.wheelEnabled, tasks);
|
||
increment += (increment < 0) ? 1 : -1;
|
||
--
|
||
GitLab
|
||
|