Add keybinds for previous/next unread/mention room

This commit is contained in:
miruka 2020-05-14 01:21:44 -04:00
parent 200f0c33a8
commit 974478f576
3 changed files with 58 additions and 14 deletions

View File

@ -1,7 +1,6 @@
# TODO
- add account number binds
- next room with unread/mention keybinds
- revise pane collapse mode
- fix escape keybinds (filter rooms, message selection)
@ -12,7 +11,6 @@
- account delegates refactor
- lag when switching accounts
- update glass theme
- improve room highlight
- if last room event is a membership change, it won't be visible in timeline
- use uiState instead of open_room

View File

@ -266,13 +266,18 @@ class UISettings(JSONDataFile):
"addNewChat": ["Alt+C"],
"toggleFocusMainPane": ["Alt+F"],
"clearRoomFilter": ["Alt+Shift+F"],
"toggleCollapseAccount": [ "Alt+O"],
"goToLastPage": ["Ctrl+Tab"],
"goToPreviousAccount": ["Alt+Shift+N"],
"goToNextAccount": ["Alt+N"],
"goToPreviousRoom": ["Alt+Shift+Up", "Alt+Shift+K"],
"goToNextRoom": ["Alt+Shift+Down", "Alt+Shift+J"],
"toggleCollapseAccount": [ "Alt+O"],
"goToPreviousUnreadRoom": ["Alt+Shift+U"],
"goToNextUnreadRoom": ["Alt+U"],
"goToPreviousMentionedRoom": ["Alt+Shift+M"],
"goToNextMentionedRoom": ["Alt+M"],
"focusRoomAtIndex": {
"01": f"{alt_or_cmd()}+1",
"02": f"{alt_or_cmd()}+2",

View File

@ -102,6 +102,26 @@ HListView {
showItemAtIndex(accountIndice[currentUserId] + 1 + index)
}
function cycleUnreadRooms(forward=true, mentions=false) {
const prop = mentions ? "mentions" : "unreads"
const start = currentIndex === -1 ? 0 : currentIndex
let index = start
while (true) {
index += forward ? 1 : -1
if (index < 0) index = model.count - 1
if (index > model.count - 1) index = 0
if (index === start) return false
const item = model.get(index)
if (item.type === "Room" && item[prop]) {
currentIndex = index
return true
}
}
}
function setCorrectCurrentItem() {
if (! currentShouldBeRoom && ! currentShouldBeAccount) {
@ -165,6 +185,27 @@ HListView {
onActivated: { incrementCurrentIndex(); showItemLimiter.restart() }
}
HShortcut {
sequences: window.settings.keys.goToPreviousUnreadRoom
onActivated: { cycleUnreadRooms(false) && showItemLimiter.restart() }
}
HShortcut {
sequences: window.settings.keys.goToNextUnreadRoom
onActivated: { cycleUnreadRooms(true) && showItemLimiter.restart() }
}
HShortcut {
sequences: window.settings.keys.goToPreviousMentionedRoom
onActivated: cycleUnreadRooms(false, true) && showItemLimiter.restart()
}
HShortcut {
sequences: window.settings.keys.goToNextMentionedRoom
onActivated: cycleUnreadRooms(true, true) && showItemLimiter.restart()
}
Repeater {
model: Object.keys(window.settings.keys.focusRoomAtIndex)