1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2025-12-08 06:25:37 -05:00

feat: Add mouse wheel support for app/workspace switching (#143)

This commit is contained in:
jichang
2025-09-01 21:11:47 +08:00
committed by GitHub
parent 924f2f6ea7
commit 26e27e2686
2 changed files with 82 additions and 0 deletions

View File

@@ -51,6 +51,46 @@ Rectangle {
baseColor.a * Theme.widgetTransparency)
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
acceptedButtons: Qt.NoButton
onWheel: {
var windows = root.sortedToplevels;
if (windows.length < 2) {
return;
}
var currentIndex = -1;
for (var i = 0; i < windows.length; i++) {
if (windows[i].activated) {
currentIndex = i;
break;
}
}
var nextIndex;
if (wheel.angleDelta.y < 0) {
if (currentIndex === -1) {
nextIndex = 0;
} else {
nextIndex = (currentIndex + 1) % windows.length;
}
} else {
if (currentIndex === -1) {
nextIndex = windows.length - 1;
} else {
nextIndex = (currentIndex - 1 + windows.length) % windows.length;
}
}
var nextWindow = windows[nextIndex];
if (nextWindow) {
nextWindow.activate();
}
}
}
Row {
id: windowRow