From 9f52fa86fa459065b91e6761d3ed844d21e2ffc2 Mon Sep 17 00:00:00 2001 From: miruka Date: Sun, 22 Mar 2020 14:07:49 -0400 Subject: [PATCH] Add Alt+1-0 keybinds to switch to a room at index --- src/backend/user_files.py | 12 ++++++++++++ src/gui/GlobalShortcuts.qml | 14 ++++++++++++++ src/gui/MainPane/AccountRoomsList.qml | 6 ++++++ 3 files changed, 32 insertions(+) diff --git a/src/backend/user_files.py b/src/backend/user_files.py index c0cc7a57..65e96023 100644 --- a/src/backend/user_files.py +++ b/src/backend/user_files.py @@ -256,6 +256,18 @@ class UISettings(JSONDataFile): "goToPreviousRoom": ["Alt+Shift+Up", "Alt+Shift+K"], "goToNextRoom": ["Alt+Shift+Down", "Alt+Shift+J"], "toggleCollapseAccount": [ "Alt+O"], + "focusRoomAtIndex": { + "01": "Alt+1", + "02": "Alt+2", + "03": "Alt+3", + "04": "Alt+4", + "05": "Alt+5", + "06": "Alt+6", + "07": "Alt+7", + "08": "Alt+8", + "09": "Alt+9", + "10": "Alt+0", + }, "clearRoomMessages": ["Ctrl+L"], "sendFile": ["Alt+S"], diff --git a/src/gui/GlobalShortcuts.qml b/src/gui/GlobalShortcuts.qml index 98c86426..1c022373 100644 --- a/src/gui/GlobalShortcuts.qml +++ b/src/gui/GlobalShortcuts.qml @@ -211,6 +211,20 @@ Item { } } + Repeater { + model: Object.keys(settings.keys.focusRoomAtIndex) + + Item { + HShortcut { + enabled: mainUI.accountsPresent + sequence: settings.keys.focusRoomAtIndex[modelData] + onActivated: mainUI.mainPane.mainPaneList.goToRoom( + parseInt(modelData - 1, 10), + ) + } + } + } + // Chat diff --git a/src/gui/MainPane/AccountRoomsList.qml b/src/gui/MainPane/AccountRoomsList.qml index af779d4a..734a5ba5 100644 --- a/src/gui/MainPane/AccountRoomsList.qml +++ b/src/gui/MainPane/AccountRoomsList.qml @@ -182,6 +182,12 @@ HListView { } } + function goToRoom(index) { + if (! currentItem) next() + const room = currentItem.roomList.contentItem.children[index] + if (room && room.activated) room.activated() + } + function requestActivate() { activateLimiter.restart() }