From c841a7a84103c991e8d8d4bd67c85b169cc61fe2 Mon Sep 17 00:00:00 2001 From: miruka Date: Mon, 19 Aug 2019 14:28:12 -0400 Subject: [PATCH] Add keybind to toggle collapsing account --- src/python/config_files.py | 6 ++++++ src/qml/Shortcuts.qml | 5 +++++ src/qml/SidePane/AccountRoomList.qml | 28 ++++++++++++++++++++++++---- src/qml/SidePane/DelegateAccount.qml | 2 ++ src/qml/SidePane/DelegateRoom.qml | 2 ++ 5 files changed, 39 insertions(+), 4 deletions(-) diff --git a/src/python/config_files.py b/src/python/config_files.py index e0f7ca29..b4694d38 100644 --- a/src/python/config_files.py +++ b/src/python/config_files.py @@ -122,6 +122,12 @@ class UISettings(JSONConfigFile): "clearRoomFilter": ["Alt+Shift+S", "Ctrl+Shift+S"], "goToPreviousRoom": ["Alt+Shift+Up", "Alt+Shift+K"], "goToNextRoom": ["Alt+Shift+Down", "Alt+Shift+J"], + + "toggleCollapseAccount": [ + "Alt+Shift+Left", "Alt+Shift+Right", + "Alt+Shift+H", "Alt+Shift+R", + ], + "startDebugger": ["Alt+Shift+D"], }, } diff --git a/src/qml/Shortcuts.qml b/src/qml/Shortcuts.qml index bee79026..89fc9508 100644 --- a/src/qml/Shortcuts.qml +++ b/src/qml/Shortcuts.qml @@ -56,6 +56,11 @@ Item { onActivated: mainUI.sidePane.accountRoomList.next() } + Shortcut { + sequences: settings.keys ? settings.keys.toggleCollapseAccount : [] + onActivated: mainUI.sidePane.accountRoomList.toggleCollapseAccount() + } + /* Shortcut { sequence: "Ctrl+-" diff --git a/src/qml/SidePane/AccountRoomList.qml b/src/qml/SidePane/AccountRoomList.qml index 942df962..1405355a 100644 --- a/src/qml/SidePane/AccountRoomList.qml +++ b/src/qml/SidePane/AccountRoomList.qml @@ -51,13 +51,33 @@ HListView { } function previous() { - accountRoomList.decrementCurrentIndex() - accountRoomList.currentItem.item.activate() + decrementCurrentIndex() + currentItem.item.activate() } function next() { - accountRoomList.incrementCurrentIndex() - accountRoomList.currentItem.item.activate() + incrementCurrentIndex() + currentItem.item.activate() + } + + function toggleCollapseAccount() { + if (! currentItem) return + + if (currentItem.item.delegateModel.type == "Account") { + currentItem.item.toggleCollapse() + return + } + + for (let i = 0; i < model.source.length; i++) { + let item = model.source[i] + + if (item.type == "Account" && item.user_id == + currentItem.item.delegateModel.user_id) + { + currentIndex = i + currentItem.item.toggleCollapse() + } + } } diff --git a/src/qml/SidePane/DelegateAccount.qml b/src/qml/SidePane/DelegateAccount.qml index 30c0c700..eaced1a7 100644 --- a/src/qml/SidePane/DelegateAccount.qml +++ b/src/qml/SidePane/DelegateAccount.qml @@ -9,6 +9,8 @@ HInteractiveRectangle { height: row.height + readonly property var delegateModel: model + readonly property bool isCurrent: window.uiState.page == "Pages/EditAccount/EditAccount.qml" && window.uiState.pageProperties.userId == model.data.user_id diff --git a/src/qml/SidePane/DelegateRoom.qml b/src/qml/SidePane/DelegateRoom.qml index c4636883..aa7a1b7c 100644 --- a/src/qml/SidePane/DelegateRoom.qml +++ b/src/qml/SidePane/DelegateRoom.qml @@ -14,6 +14,8 @@ HInteractiveRectangle { Behavior on opacity { HNumberAnimation {} } + readonly property var delegateModel: model + readonly property bool forceExpand: Boolean(accountRoomList.filter)