From 073a2eacee2851a1c9e0906f69aa6d54043b40a2 Mon Sep 17 00:00:00 2001 From: miruka Date: Tue, 20 Aug 2019 13:41:55 -0400 Subject: [PATCH] Add arrow navigation to sidepane when focused --- src/qml/SidePane/AccountRoomList.qml | 14 +++++++++----- src/qml/SidePane/SidePane.qml | 11 +++++++++++ 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/qml/SidePane/AccountRoomList.qml b/src/qml/SidePane/AccountRoomList.qml index 4c30158a..ed50a5c3 100644 --- a/src/qml/SidePane/AccountRoomList.qml +++ b/src/qml/SidePane/AccountRoomList.qml @@ -57,15 +57,19 @@ HListView { model.source = show } - function previous() { + function previous(activate=true) { decrementCurrentIndex() - activateLimiter.requestFire() + if (activate) activateLimiter.requestFire() } - function next() { + function next(activate=true) { incrementCurrentIndex() - activateLimiter.requestFire() + if (activate) activateLimiter.requestFire() + } + + function activate() { + currentItem.item.activate() } function toggleCollapseAccount() { @@ -109,7 +113,7 @@ HListView { HRateLimiter { id: activateLimiter - onFired: currentItem.item.activate() + onFired: activate() extendOnRequestWhileCooldownActive: true } } diff --git a/src/qml/SidePane/SidePane.qml b/src/qml/SidePane/SidePane.qml index 8973cf94..3e84ffaa 100644 --- a/src/qml/SidePane/SidePane.qml +++ b/src/qml/SidePane/SidePane.qml @@ -82,6 +82,17 @@ HRectangle { } + Keys.enabled: sidePane.hasFocus + Keys.onUpPressed: accountRoomList.previous(false) // do not activate + Keys.onDownPressed: accountRoomList.next(false) + Keys.onEnterPressed: Keys.onReturnPressed(event) + Keys.onReturnPressed: if (event.modifiers & Qt.ShiftModifier) { + accountRoomList.toggleCollapseAccount() + } else { + accountRoomList.activate() + } + + HColumnLayout { anchors.fill: parent