feat(bar): improve volume scroll handling on bar with smooth accumulation

This commit is contained in:
tibssy
2026-03-24 00:37:05 +00:00
parent 7d4ee04461
commit 700d377f0f
+22 -13
View File
@@ -442,7 +442,7 @@ Item {
}
}
// Scroll on empty bar area to switch workspaces
// Scroll on empty bar area action
WheelHandler {
id: barWheelHandler
target: bar
@@ -450,8 +450,6 @@ Item {
enabled: bar.barWheelAction !== "none"
onWheel: function (event) {
if (bar.barWheelCooldown)
return;
if (bar.isPointOverWidget(event.x, event.y))
return;
@@ -459,9 +457,29 @@ Item {
var dx = event.angleDelta.x;
var useDy = Math.abs(dy) >= Math.abs(dx);
var delta = useDy ? dy : dx;
var step = 120;
if (bar.barWheelAction === "volume") {
if (Settings.data.bar.reverseScroll)
delta *= -1;
bar.barWheelAccumulatedDelta += delta;
if (bar.barWheelAccumulatedDelta >= step) {
AudioService.increaseVolume();
bar.barWheelAccumulatedDelta = 0;
event.accepted = true;
} else if (bar.barWheelAccumulatedDelta <= -step) {
AudioService.decreaseVolume();
bar.barWheelAccumulatedDelta = 0;
event.accepted = true;
}
return;
}
if (bar.barWheelCooldown)
return;
bar.barWheelAccumulatedDelta += delta;
var step = 120;
if (Math.abs(bar.barWheelAccumulatedDelta) >= step) {
var direction = bar.barWheelAccumulatedDelta > 0 ? -1 : 1;
if (Settings.data.bar.reverseScroll)
@@ -470,15 +488,6 @@ Item {
bar.switchWorkspaceByOffset(direction);
} else if (bar.barWheelAction === "content") {
CompositorService.scrollWorkspaceContent(direction);
} else if (bar.barWheelAction === "volume") {
var volumeDirection = bar.barWheelAccumulatedDelta > 0 ? 1 : -1;
if (Settings.data.bar.reverseScroll)
volumeDirection *= -1;
if (volumeDirection > 0) {
AudioService.increaseVolume();
} else {
AudioService.decreaseVolume();
}
}
bar.barWheelCooldown = true;
barWheelDebounce.restart();