SettingsPanel: added keyboard navigation (Tab, Vim, Up/Down) to change active tab.

This commit is contained in:
LemmyCook 2025-09-04 17:14:54 -04:00
parent b00f058eac
commit be1643c5b8

View file

@ -217,11 +217,63 @@ NPanel {
root.currentTabIndex = initialIndex
}
// Add navigation functions
function selectNextTab() {
if (tabsModel.length > 0) {
currentTabIndex = (currentTabIndex + 1) % tabsModel.length
}
}
function selectPreviousTab() {
if (tabsModel.length > 0) {
currentTabIndex = (currentTabIndex - 1 + tabsModel.length) % tabsModel.length
}
}
panelContent: Rectangle {
anchors.fill: parent
anchors.margins: Style.marginL * scaling
color: Color.transparent
// Add shortcuts at the panel level
Shortcut {
sequence: "Ctrl+J"
onActivated: root.selectNextTab()
enabled: root.opened
}
Shortcut {
sequence: "Ctrl+K"
onActivated: root.selectPreviousTab()
enabled: root.opened
}
// Optional: Add more navigation shortcuts
Shortcut {
sequence: "Down"
onActivated: root.selectNextTab()
enabled: root.opened
}
Shortcut {
sequence: "Up"
onActivated: root.selectPreviousTab()
enabled: root.opened
}
// Optional: Tab/Shift+Tab navigation
Shortcut {
sequence: "Tab"
onActivated: root.selectNextTab()
enabled: root.opened
}
Shortcut {
sequence: "Shift+Tab"
onActivated: root.selectPreviousTab()
enabled: root.opened
}
RowLayout {
anchors.fill: parent
spacing: Style.marginM * scaling