fix(@desktop/onboarding): pressing enter/return key issue fixed

- skipping some screens pressing enter/return key fixed
- pressing enter for all screens will trigger a primary button for that screen
This commit is contained in:
Sale Djenic 2023-04-03 11:15:34 +02:00 committed by saledjenic
parent 0426d7de55
commit 3f4dd40a3b
5 changed files with 75 additions and 11 deletions

View File

@ -15,6 +15,10 @@ Item {
property StartupStore startupStore
Component.onCompleted: {
btnOk.forceActiveFocus()
}
QtObject {
id: d
readonly property int titlePixelSize: 22
@ -67,5 +71,11 @@ Item {
onClicked: {
root.startupStore.doPrimaryAction()
}
Keys.onPressed: {
if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) {
event.accepted = true
root.startupStore.doPrimaryAction()
}
}
}
}

View File

@ -35,10 +35,17 @@ Item {
root.pubKey = root.startupStore.startupModuleInst.importedAccountPubKey;
}
nameInput.text = root.startupStore.getDisplayName();
nameInput.input.edit.forceActiveFocus();
userImage.asset.name = root.startupStore.getCroppedProfileImage();
}
onStateChanged: {
if (state === Constants.startupState.userProfileCreate) {
nameInput.input.edit.forceActiveFocus()
return
}
nextBtn.forceActiveFocus()
}
Loader {
active: !root.startupStore.startupModuleInst.importedAccountPubKey
sourceComponent: StatusListView {
@ -54,6 +61,21 @@ Item {
}
}
QtObject {
id: d
function doAction() {
if(!nextBtn.enabled) {
return
}
if (root.state === Constants.startupState.userProfileCreate) {
root.startupStore.setDisplayName(nameInput.text)
root.displayName = nameInput.text;
}
root.startupStore.doPrimaryAction()
}
}
ColumnLayout {
height: 461
anchors.centerIn: parent
@ -144,13 +166,10 @@ Item {
onTextChanged: {
userImage.name = text;
}
input.acceptReturn: true
onKeyPressed: {
if (input.edit.keyEvent === Qt.Key_Return || input.edit.keyEvent === Qt.Key_Enter) {
Keys.onPressed: {
if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) {
event.accepted = true
if(nextBtn.enabled) {
nextBtn.clicked(null)
}
d.doAction()
}
}
}
@ -215,11 +234,13 @@ Item {
font.weight: Font.Medium
text: qsTr("Next")
onClicked: {
if (root.state === Constants.startupState.userProfileCreate) {
root.startupStore.setDisplayName(nameInput.text)
root.displayName = nameInput.text;
d.doAction()
}
Keys.onPressed: {
if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) {
event.accepted = true
d.doAction()
}
root.startupStore.doPrimaryAction()
}
}
@ -269,6 +290,7 @@ Item {
}
PropertyChanges {
target: nameInputItem
enabled: true
visible: true
}
},
@ -301,6 +323,7 @@ Item {
}
PropertyChanges {
target: nameInputItem
enabled: false
visible: false
}
}

View File

@ -21,6 +21,12 @@ Item {
property StartupStore startupStore
Component.onCompleted: {
if (button1.visible) {
button1.forceActiveFocus()
}
}
QtObject {
id: d
readonly property int infoWidth: 292
@ -214,6 +220,12 @@ Item {
onClicked: {
root.startupStore.doPrimaryAction()
}
Keys.onPressed: {
if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) {
event.accepted = true
root.startupStore.doPrimaryAction()
}
}
}
StatusBaseText {

View File

@ -19,6 +19,10 @@ Item {
property StartupStore startupStore
Component.onCompleted: {
button.forceActiveFocus()
}
Item {
id: container
enabled: !dimBackground.active
@ -84,6 +88,12 @@ Item {
dimBackground.active = true
root.startupStore.doPrimaryAction()
}
Keys.onPressed: {
if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) {
event.accepted = true
root.startupStore.doPrimaryAction()
}
}
}
StatusBaseText {
id: keycardLink

View File

@ -19,13 +19,16 @@ Item {
Component.onCompleted: {
if (root.startupStore.showBeforeGetStartedPopup()) {
beforeGetStartedModal.open();
return
}
btnNewUser.forceActiveFocus()
}
BeforeGetStartedModal {
id: beforeGetStartedModal
onClosed: {
root.startupStore.beforeGetStartedPopupAccepted()
btnNewUser.forceActiveFocus()
}
}
@ -79,6 +82,12 @@ Item {
onClicked: {
root.startupStore.doPrimaryAction()
}
Keys.onPressed: {
if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) {
event.accepted = true
root.startupStore.doPrimaryAction()
}
}
}
StatusFlatButton {