From 099c20c138f29c7c71e59c3ed34cdaf465dfb7c2 Mon Sep 17 00:00:00 2001 From: miruka Date: Fri, 10 Jul 2020 03:11:26 -0400 Subject: [PATCH] Add keyboard navigation for account device list Enter/Return/Menu: open device menu Space: toggle check device Escape: uncheck all Alt+R/F5: refresh device list Alt+S/Delete: sign out checked or all sessions --- TODO.md | 2 -- src/backend/user_files.py | 3 +++ src/gui/Pages/AccountSettings/Sessions.qml | 22 ++++++++++++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/TODO.md b/TODO.md index bacd030f..1fcfb0b6 100644 --- a/TODO.md +++ b/TODO.md @@ -1,6 +1,5 @@ # TODO -- composer menu? - fix members not synced bug - fix local unread counters order - fix highlight when logging in to new account @@ -57,7 +56,6 @@ - Show scrollbars for a few seconds if there's content to scroll on when opening a page or popup -- Device list keyboard navigation - Device IP geolocation - Can rooms but left with a reason? diff --git a/src/backend/user_files.py b/src/backend/user_files.py index c5d3aed0..9e9a4ca7 100644 --- a/src/backend/user_files.py +++ b/src/backend/user_files.py @@ -337,6 +337,9 @@ class UISettings(JSONDataFile): "forgetRoom": ["Alt+Shift+Escape"], "toggleFocusRoomPane": ["Alt+R"], + + "refreshDevices": ["Alt+R", "F5"], + "signOutCheckedOrAllDevices": ["Alt+S", "Delete"], }, } diff --git a/src/gui/Pages/AccountSettings/Sessions.qml b/src/gui/Pages/AccountSettings/Sessions.qml index 51620d08..1786c58b 100644 --- a/src/gui/Pages/AccountSettings/Sessions.qml +++ b/src/gui/Pages/AccountSettings/Sessions.qml @@ -39,6 +39,8 @@ HColumnPage { loadFuture = null deviceList.sectionItemCounts = getSectionItemCounts() + + if (! deviceList.currentItem) deviceList.currentIndex = 0 }) } @@ -97,12 +99,14 @@ HColumnPage { footer: ButtonLayout { OtherButton { + id: refreshButton text: qsTr("Refresh") icon.name: "device-refresh-list" onClicked: page.loadDevices() } OtherButton { + id: signOutCheckedButton enabled: deviceList.model.count > 0 text: deviceList.selectedCount === 0 ? @@ -118,6 +122,8 @@ HColumnPage { } } + Keys.forwardTo: [deviceList] + HListView { id: deviceList @@ -149,6 +155,22 @@ HColumnPage { Layout.fillWidth: true Layout.fillHeight: true + Keys.onEscapePressed: uncheckAll() + Keys.onSpacePressed: if (currentItem) toggleCheck(currentIndex) + Keys.onEnterPressed: if (currentItem) currentItem.openMenu(false) + Keys.onReturnPressed: Keys.onEnterPressed(event) + Keys.onMenuPressed: Keys.onEnterPressed(event) + + HShortcut { + sequences: window.settings.keys.refreshDevices + onActivated: refreshButton.clicked() + } + + HShortcut { + sequences: window.settings.keys.signOutCheckedOrAllDevices + onActivated: signOutCheckedButton.clicked() + } + FlickShortcuts { flickable: deviceList active: