diff --git a/src/config/settings.py b/src/config/settings.py index 6275eceb..88e2bb4a 100644 --- a/src/config/settings.py +++ b/src/config/settings.py @@ -376,6 +376,17 @@ class Keys: 9 = [Keys.alt_or_cmd() + "+9"] 10 = [Keys.alt_or_cmd() + "+0"] + class Direct: + # Switch to specific rooms with keybindings. + # An unlimited number of properties can be added, where each + # property maps a room to a list of keybind. + # A room's ID can be copied by right clicking on it in the room list. + "!roomID:example.org" = [] + + # If you have multiple accounts in the same room, you can also set + # which account should be targeted as " ": + "@account:example.org !roomID:example.org" = [] + class Chat: # Keybinds specific to the current chat page. diff --git a/src/gui/MainPane/RoomList.qml b/src/gui/MainPane/RoomList.qml index 2ba665fd..905ec1a0 100644 --- a/src/gui/MainPane/RoomList.qml +++ b/src/gui/MainPane/RoomList.qml @@ -73,6 +73,27 @@ HListView { keepListCentered = true } + function showById(roomId, accountId=null) { + // If only a room ID is passed, first account with this room is used + if (accountId === null) { + const roomIndex = model.findIndex(roomId) + + roomIndex === null ? + console.warn("No account with such room ID:", roomId) : + showItemAtIndex(roomIndex) + + return + } + + if (! (accountId in accountIndice)) { + console.warn("No such account:", accountId) + return + } + + pageLoader.showRoom(accountId, roomId) + startCorrectItemSearch() + } + function showAccountRoomAtIndex(index) { const item = model.get(currentIndex === -1 ? 0 : currentIndex) @@ -284,6 +305,16 @@ HListView { } } + Instantiator { + model: Object.keys(window.settings.Keys.Rooms.Direct) + delegate: Loader { + sourceComponent: HShortcut { + sequences: window.settings.Keys.Rooms.Direct[modelData] + onActivated: showById(...modelData.split(/\s+/).reverse()) + } + } + } + Rectangle { anchors.fill: parent z: -100