From 92cbc4b0069c6277cefd5fe269f97a4f14f320b9 Mon Sep 17 00:00:00 2001 From: miruka Date: Thu, 9 Jul 2020 14:53:01 -0400 Subject: [PATCH] Add keyboard controls for members list & profile --- TODO.md | 1 - .../MemberView/DeviceVerification.qml | 23 ++++++++++++++----- .../RoomPane/MemberView/MemberProfile.qml | 5 ++++ .../Chat/RoomPane/MemberView/MemberView.qml | 9 ++++++++ 4 files changed, 31 insertions(+), 7 deletions(-) diff --git a/TODO.md b/TODO.md index d3975783..32035c5a 100644 --- a/TODO.md +++ b/TODO.md @@ -2,7 +2,6 @@ - fix highlight when logging in to new account - warn about no E2E room shared if no devices -- keyboard controls - Make HTile enter key trigger leftClicked() ## Refactoring diff --git a/src/gui/Pages/Chat/RoomPane/MemberView/DeviceVerification.qml b/src/gui/Pages/Chat/RoomPane/MemberView/DeviceVerification.qml index 2e1ee545..f73c690a 100644 --- a/src/gui/Pages/Chat/RoomPane/MemberView/DeviceVerification.qml +++ b/src/gui/Pages/Chat/RoomPane/MemberView/DeviceVerification.qml @@ -16,9 +16,17 @@ HFlickableColumnPage { property string ed25519Key property HStackView stackView + property Item previouslyFocused: null + signal trustSet(bool trust) + function close() { + if (previouslyFocused) previouslyFocused.forceActiveFocus() + stackView.pop() + } + + footer: ButtonLayout { ApplyButton { text: qsTr("They're the same") @@ -32,7 +40,7 @@ HFlickableColumnPage { () => { loading = false page.trustSet(true) - stackView.pop() + page.close() } ) } @@ -50,7 +58,7 @@ HFlickableColumnPage { () => { loading = false page.trustSet(false) - stackView.pop() + page.close() } ) } @@ -58,12 +66,15 @@ HFlickableColumnPage { CancelButton { id: cancelButton - onClicked: stackView.pop() - Component.onCompleted: forceActiveFocus() + onClicked: page.close() + Component.onCompleted: { + page.previouslyFocused = window.activeFocusItem + forceActiveFocus() + } } } - onKeyboardCancel: stackView.pop() + onKeyboardCancel: page.close() HRowLayout { @@ -72,7 +83,7 @@ HFlickableColumnPage { circle: true icon.name: "close-view" iconItem.small: true - onClicked: page.stackView.pop() + onClicked: page.close() Layout.rightMargin: theme.spacing } diff --git a/src/gui/Pages/Chat/RoomPane/MemberView/MemberProfile.qml b/src/gui/Pages/Chat/RoomPane/MemberView/MemberProfile.qml index d2e29d88..f42dffe7 100644 --- a/src/gui/Pages/Chat/RoomPane/MemberView/MemberProfile.qml +++ b/src/gui/Pages/Chat/RoomPane/MemberView/MemberProfile.qml @@ -133,6 +133,11 @@ HListView { Component.onCompleted: loadDevices() + Keys.onEnterPressed: Keys.onReturnPressed(event) + Keys.onReturnPressed: { + currentItem.leftClicked() + currentItem.clicked() + } Keys.onEscapePressed: stackView.pop() diff --git a/src/gui/Pages/Chat/RoomPane/MemberView/MemberView.qml b/src/gui/Pages/Chat/RoomPane/MemberView/MemberView.qml index 36a6d383..a856c899 100644 --- a/src/gui/Pages/Chat/RoomPane/MemberView/MemberView.qml +++ b/src/gui/Pages/Chat/RoomPane/MemberView/MemberView.qml @@ -37,6 +37,12 @@ HColumnLayout { }, ) } + + Keys.onEnterPressed: Keys.onReturnPressed(event) + Keys.onReturnPressed: { + currentItem.leftClicked() + currentItem.clicked() + } } Layout.fillWidth: true @@ -75,6 +81,9 @@ HColumnLayout { py.callCoro("set_substring_filter", [modelSyncId, text]) } + Keys.forwardTo: [stackView.currentItem] + Keys.priority: Keys.AfterItem + Keys.onEscapePressed: { roomPane.toggleFocus() if (window.settings.clearMemberFilterOnEscape) text = ""