diff --git a/TODO.md b/TODO.md index e06dba7c..c942e576 100644 --- a/TODO.md +++ b/TODO.md @@ -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 diff --git a/src/backend/user_files.py b/src/backend/user_files.py index d0d5d810..16ddb8b2 100644 --- a/src/backend/user_files.py +++ b/src/backend/user_files.py @@ -260,19 +260,24 @@ class UISettings(JSONDataFile): "previousTab": ["Alt+Shift+Left", "Alt+Shift+H"], "nextTab": ["Alt+Shift+Right", "Alt+Shift+L"], - "showEveryRoom": ["Alt+E"], - "addNewAccount": ["Alt+Shift+A"], - "accountSettings": ["Alt+A"], - "addNewChat": ["Alt+C"], - "toggleFocusMainPane": ["Alt+F"], - "clearRoomFilter": ["Alt+Shift+F"], - - "goToLastPage": ["Ctrl+Tab"], - "goToPreviousAccount": ["Alt+Shift+N"], - "goToNextAccount": ["Alt+N"], - "goToPreviousRoom": ["Alt+Shift+Up", "Alt+Shift+K"], - "goToNextRoom": ["Alt+Shift+Down", "Alt+Shift+J"], + "showEveryRoom": ["Alt+E"], + "addNewAccount": ["Alt+Shift+A"], + "accountSettings": ["Alt+A"], + "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"], + "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", diff --git a/src/gui/MainPane/RoomList.qml b/src/gui/MainPane/RoomList.qml index 1fcb6030..55b9e38d 100644 --- a/src/gui/MainPane/RoomList.qml +++ b/src/gui/MainPane/RoomList.qml @@ -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)