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
This commit is contained in:
miruka
2020-07-10 03:11:26 -04:00
parent 612ded755a
commit 099c20c138
3 changed files with 25 additions and 2 deletions

View File

@@ -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: