Add keyboard controls for members list & profile

This commit is contained in:
miruka 2020-07-09 14:53:01 -04:00
parent dc2a7b8ee1
commit 92cbc4b006
4 changed files with 31 additions and 7 deletions

View File

@ -2,7 +2,6 @@
- fix highlight when logging in to new account - fix highlight when logging in to new account
- warn about no E2E room shared if no devices - warn about no E2E room shared if no devices
- keyboard controls
- Make HTile enter key trigger leftClicked() - Make HTile enter key trigger leftClicked()
## Refactoring ## Refactoring

View File

@ -16,9 +16,17 @@ HFlickableColumnPage {
property string ed25519Key property string ed25519Key
property HStackView stackView property HStackView stackView
property Item previouslyFocused: null
signal trustSet(bool trust) signal trustSet(bool trust)
function close() {
if (previouslyFocused) previouslyFocused.forceActiveFocus()
stackView.pop()
}
footer: ButtonLayout { footer: ButtonLayout {
ApplyButton { ApplyButton {
text: qsTr("They're the same") text: qsTr("They're the same")
@ -32,7 +40,7 @@ HFlickableColumnPage {
() => { () => {
loading = false loading = false
page.trustSet(true) page.trustSet(true)
stackView.pop() page.close()
} }
) )
} }
@ -50,7 +58,7 @@ HFlickableColumnPage {
() => { () => {
loading = false loading = false
page.trustSet(false) page.trustSet(false)
stackView.pop() page.close()
} }
) )
} }
@ -58,12 +66,15 @@ HFlickableColumnPage {
CancelButton { CancelButton {
id: cancelButton id: cancelButton
onClicked: stackView.pop() onClicked: page.close()
Component.onCompleted: forceActiveFocus() Component.onCompleted: {
page.previouslyFocused = window.activeFocusItem
forceActiveFocus()
}
} }
} }
onKeyboardCancel: stackView.pop() onKeyboardCancel: page.close()
HRowLayout { HRowLayout {
@ -72,7 +83,7 @@ HFlickableColumnPage {
circle: true circle: true
icon.name: "close-view" icon.name: "close-view"
iconItem.small: true iconItem.small: true
onClicked: page.stackView.pop() onClicked: page.close()
Layout.rightMargin: theme.spacing Layout.rightMargin: theme.spacing
} }

View File

@ -133,6 +133,11 @@ HListView {
Component.onCompleted: loadDevices() Component.onCompleted: loadDevices()
Keys.onEnterPressed: Keys.onReturnPressed(event)
Keys.onReturnPressed: {
currentItem.leftClicked()
currentItem.clicked()
}
Keys.onEscapePressed: stackView.pop() Keys.onEscapePressed: stackView.pop()

View File

@ -37,6 +37,12 @@ HColumnLayout {
}, },
) )
} }
Keys.onEnterPressed: Keys.onReturnPressed(event)
Keys.onReturnPressed: {
currentItem.leftClicked()
currentItem.clicked()
}
} }
Layout.fillWidth: true Layout.fillWidth: true
@ -75,6 +81,9 @@ HColumnLayout {
py.callCoro("set_substring_filter", [modelSyncId, text]) py.callCoro("set_substring_filter", [modelSyncId, text])
} }
Keys.forwardTo: [stackView.currentItem]
Keys.priority: Keys.AfterItem
Keys.onEscapePressed: { Keys.onEscapePressed: {
roomPane.toggleFocus() roomPane.toggleFocus()
if (window.settings.clearMemberFilterOnEscape) text = "" if (window.settings.clearMemberFilterOnEscape) text = ""