SessionMenu: replace select next/previous usage with wrapping version

This commit is contained in:
Damian D'Souza
2025-10-17 00:49:10 +02:00
parent 68b3483162
commit 4be26bc604
+9 -29
View File
@@ -119,18 +119,6 @@ NPanel {
}
// Navigation functions
function selectNext() {
if (powerOptions.length > 0) {
selectedIndex = Math.min(selectedIndex + 1, powerOptions.length - 1)
}
}
function selectPrevious() {
if (powerOptions.length > 0) {
selectedIndex = Math.max(selectedIndex - 1, 0)
}
}
function selectNextWrapped() {
if (powerOptions.length > 0) {
selectedIndex = (selectedIndex + 1) % powerOptions.length
@@ -182,30 +170,24 @@ NPanel {
// Keyboard shortcuts
Shortcut {
sequence: "Ctrl+K"
onActivated: ui.selectPrevious()
onActivated: ui.selectPreviousWrapped()
enabled: root.opened
}
Shortcut {
sequence: "Ctrl+J"
onActivated: ui.selectNext()
onActivated: ui.selectNextWrapped()
enabled: root.opened
}
Shortcut {
sequence: "Up"
onActivated: ui.selectPrevious()
onActivated: ui.selectPreviousWrapped()
enabled: root.opened
}
Shortcut {
sequence: "Down"
onActivated: ui.selectNext()
enabled: root.opened
}
Shortcut {
sequence: "Tab"
onActivated: ui.selectNextWrapped()
enabled: root.opened
}
@@ -216,6 +198,12 @@ NPanel {
enabled: root.opened
}
Shortcut {
sequence: "Tab"
onActivated: ui.selectNextWrapped()
enabled: root.opened
}
Shortcut {
sequence: "Home"
onActivated: ui.selectFirst()
@@ -255,14 +243,6 @@ NPanel {
}
// Navigation functions
function selectNext() {
root.selectNext()
}
function selectPrevious() {
root.selectPrevious()
}
function selectFirst() {
root.selectFirst()
}