From 7547703bb0d9a550d4baaad4e7d911ed60f522bd Mon Sep 17 00:00:00 2001 From: miruka Date: Thu, 13 Feb 2020 05:56:10 -0400 Subject: [PATCH] Main pane list items keyboard activation --- src/gui/GlobalShortcuts.qml | 10 ++++++++-- src/gui/MainPane/Account.qml | 2 ++ src/gui/MainPane/AccountRoomsList.qml | 18 ++++++++++++++++-- src/gui/MainPane/MainPane.qml | 4 ++++ src/gui/MainPane/MainPaneToolBar.qml | 5 ++++- 5 files changed, 34 insertions(+), 5 deletions(-) diff --git a/src/gui/GlobalShortcuts.qml b/src/gui/GlobalShortcuts.qml index ca7e525c..f4f68b17 100644 --- a/src/gui/GlobalShortcuts.qml +++ b/src/gui/GlobalShortcuts.qml @@ -187,13 +187,19 @@ Item { HShortcut { enabled: mainUI.accountsPresent sequences: settings.keys.goToPreviousRoom - onActivated: mainUI.mainPane.mainPaneList.previous() + onActivated: { + mainUI.mainPane.mainPaneList.previous() + mainUI.mainPane.mainPaneList.requestActivate() + } } HShortcut { enabled: mainUI.accountsPresent sequences: settings.keys.goToNextRoom - onActivated: mainUI.mainPane.mainPaneList.next() + onActivated: { + mainUI.mainPane.mainPaneList.next() + mainUI.mainPane.mainPaneList.requestActivate() + } } diff --git a/src/gui/MainPane/Account.qml b/src/gui/MainPane/Account.qml index 30aa4db0..aeb19f01 100644 --- a/src/gui/MainPane/Account.qml +++ b/src/gui/MainPane/Account.qml @@ -48,6 +48,8 @@ HTileDelegate { ) + readonly property alias addChat: addChat + readonly property bool collapsed: window.uiState.collapseAccounts[model.id] || false diff --git a/src/gui/MainPane/AccountRoomsList.qml b/src/gui/MainPane/AccountRoomsList.qml index 05ca3a0f..a3508237 100644 --- a/src/gui/MainPane/AccountRoomsList.qml +++ b/src/gui/MainPane/AccountRoomsList.qml @@ -20,6 +20,8 @@ HListView { highlightRangeMode: ListView.NoHighlightRange highlight: Rectangle { + Component.onCompleted: print("coc") + Component.onDestruction: print("cod") id: highlightRectangle y: selectedRoom ? @@ -120,8 +122,15 @@ HListView { } } + function requestActivate() { + activateLimiter.restart() + } + function activate() { - currentItem.item.activated() + if (! currentItem) incrementCurrentIndex() + selectedRoom ? + currentItem.roomList.currentItem.activated() : + currentItem.account.activated() } function accountSettings() { @@ -133,7 +142,7 @@ HListView { function addNewChat() { if (! currentItem) incrementCurrentIndex() currentItem.roomList.currentIndex = -1 - currentItem.account.activated() + currentItem.account.addChat.clicked() } function toggleCollapseAccount() { @@ -142,6 +151,11 @@ HListView { currentItem.account.toggleCollapse() } + function clearSelection() { + if (selectedRoom) currentItem.roomList.currentIndex = -1 + currentIndex = -1 + } + Timer { id: activateLimiter diff --git a/src/gui/MainPane/MainPane.qml b/src/gui/MainPane/MainPane.qml index e764db85..f5b955f7 100644 --- a/src/gui/MainPane/MainPane.qml +++ b/src/gui/MainPane/MainPane.qml @@ -27,6 +27,10 @@ HDrawer { toolBar.filterField.forceActiveFocus() } + function addccount() { + toolBar.addAccountButton.clicked() + } + Behavior on opacity { HNumberAnimation {} } diff --git a/src/gui/MainPane/MainPaneToolBar.qml b/src/gui/MainPane/MainPaneToolBar.qml index 2226540a..b3f57424 100644 --- a/src/gui/MainPane/MainPaneToolBar.qml +++ b/src/gui/MainPane/MainPaneToolBar.qml @@ -19,7 +19,10 @@ HRowLayout { icon.name: "add-account" toolTip.text: qsTr("Add another account") backgroundColor: theme.mainPane.settingsButton.background - onClicked: pageLoader.showPage("AddAccount/AddAccount") + onClicked: { + mainPaneList.clearSelection() + pageLoader.showPage("AddAccount/AddAccount") + } Layout.fillHeight: true }