Add tab navigation shortcuts (for AddChat)

This commit is contained in:
miruka 2019-11-10 09:28:57 -04:00
parent 484e9e595d
commit f2ab84c754
3 changed files with 31 additions and 0 deletions

View File

@ -130,6 +130,9 @@ class UISettings(JSONConfigFile):
"scrollToBottom":
["Alt+Ctrl+Shift+Down", "Alt+Ctrl+Shift+J", "End"],
"previousTab": ["Alt+Shift+Left", "Alt+Shift+H"],
"nextTab": ["Alt+Shift+Right", "Alt+Shift+L"],
"focusSidePane": ["Alt+S"],
"clearRoomFilter": ["Alt+Shift+S"],
"accountSettings": ["Alt+A"],

View File

@ -26,6 +26,7 @@ HPage {
HTabBar {
id: tabBar
currentIndex: 0
Component.onCompleted: shortcuts.tabsTarget = this
Layout.fillWidth: true

View File

@ -1,11 +1,19 @@
import QtQuick 2.12
import QtQuick.Controls 2.12
import "Base"
import "utils.js" as Utils
HShortcutHandler {
// Flickable or ListView that should be affected by scroll shortcuts
property Item flickTarget
// TabBar that should be affected by tab navigation shortcuts
property TabBar tabsTarget
// DebugConsole that should be affected by console shortcuts
property DebugConsole debugConsole
// App
HShortcut {
@ -84,6 +92,25 @@ HShortcutHandler {
}
// Tab navigation
HShortcut {
enabled: tabsTarget
sequences: settings.keys.previousTab
onPressed: tabsTarget.setCurrentIndex(
Utils.numberWrapAt(tabsTarget.currentIndex - 1, tabsTarget.count),
)
}
HShortcut {
enabled: tabsTarget
sequences: settings.keys.nextTab
onPressed: tabsTarget.setCurrentIndex(
Utils.numberWrapAt(tabsTarget.currentIndex + 1, tabsTarget.count),
)
}
// SidePane
HShortcut {