Add keybinds to switch accounts

This commit is contained in:
miruka 2020-04-27 22:10:10 -04:00
parent 72c96b3ba5
commit 65103eaaba
6 changed files with 30 additions and 0 deletions

View File

@ -1,5 +1,6 @@
# TODO # TODO
- lag when switching accounts
- message delegate too tall - message delegate too tall
- fix escape keybinds (filter rooms, message selection) - fix escape keybinds (filter rooms, message selection)

View File

@ -267,6 +267,8 @@ class UISettings(JSONDataFile):
"addNewChat": ["Alt+C"], "addNewChat": ["Alt+C"],
"goToLastPage": ["Ctrl+Tab"], "goToLastPage": ["Ctrl+Tab"],
"goToPreviousAccount": ["Alt+Shift+N"],
"goToNextAccount": ["Alt+N"],
"goToPreviousRoom": ["Alt+Shift+Up", "Alt+Shift+K"], "goToPreviousRoom": ["Alt+Shift+Up", "Alt+Shift+K"],
"goToNextRoom": ["Alt+Shift+Down", "Alt+Shift+J"], "goToNextRoom": ["Alt+Shift+Down", "Alt+Shift+J"],
"toggleCollapseAccount": [ "Alt+O"], "toggleCollapseAccount": [ "Alt+O"],

View File

@ -39,6 +39,18 @@ SwipeView {
function reset() { setCurrentIndex(defaultIndex) } function reset() { setCurrentIndex(defaultIndex) }
function incrementWrapIndex() {
currentIndex === count - 1 ?
setCurrentIndex(0) :
incrementCurrentIndex()
}
function decrementWrapIndex() {
currentIndex === 0 ?
setCurrentIndex(count - 1) :
decrementCurrentIndex()
}
TabShortcuts { TabShortcuts {
container: swipeView container: swipeView

View File

@ -54,6 +54,16 @@ HColumnLayout {
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true
HShortcut {
sequences: window.settings.keys.goToPreviousAccount
onActivated: roomContainer.decrementWrapIndex()
}
HShortcut {
sequences: window.settings.keys.goToNextAccount
onActivated: roomContainer.incrementWrapIndex()
}
} }
HButton { HButton {

View File

@ -15,6 +15,8 @@ HListView {
onActivated: showRoom(model.index) onActivated: showRoom(model.index)
} }
onIsCurrentChanged: if (isCurrent) showRoom()
property var accountModel property var accountModel
property var roomPane property var roomPane
@ -22,6 +24,8 @@ HListView {
function showRoom(index=currentIndex) { function showRoom(index=currentIndex) {
if (index === -1) index = 0
if (index >= model.count) return
pageLoader.showRoom(accountModel.id, model.get(index).id) pageLoader.showRoom(accountModel.id, model.get(index).id)
currentIndex = index currentIndex = index
} }

View File

@ -9,6 +9,7 @@ HSwipeView {
id: swipeView id: swipeView
orientation: Qt.Vertical orientation: Qt.Vertical
Repeater { Repeater {
model: ModelStore.get("accounts") model: ModelStore.get("accounts")