From 3f4dd40a3b5e53e54fdf8c01f6f24256e08ddfb2 Mon Sep 17 00:00:00 2001 From: Sale Djenic Date: Mon, 3 Apr 2023 11:15:34 +0200 Subject: [PATCH] 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 --- .../views/AllowNotificationsView.qml | 10 +++++ .../Onboarding/views/InsertDetailsView.qml | 45 ++++++++++++++----- .../Onboarding/views/KeysMainView.qml | 12 +++++ .../Onboarding/views/TouchIDAuthView.qml | 10 +++++ .../Onboarding/views/WelcomeView.qml | 9 ++++ 5 files changed, 75 insertions(+), 11 deletions(-) diff --git a/ui/app/AppLayouts/Onboarding/views/AllowNotificationsView.qml b/ui/app/AppLayouts/Onboarding/views/AllowNotificationsView.qml index 84fbd0a363..01cf138d71 100644 --- a/ui/app/AppLayouts/Onboarding/views/AllowNotificationsView.qml +++ b/ui/app/AppLayouts/Onboarding/views/AllowNotificationsView.qml @@ -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() + } + } } } diff --git a/ui/app/AppLayouts/Onboarding/views/InsertDetailsView.qml b/ui/app/AppLayouts/Onboarding/views/InsertDetailsView.qml index b5a9a88af1..0beef664b5 100644 --- a/ui/app/AppLayouts/Onboarding/views/InsertDetailsView.qml +++ b/ui/app/AppLayouts/Onboarding/views/InsertDetailsView.qml @@ -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 } } diff --git a/ui/app/AppLayouts/Onboarding/views/KeysMainView.qml b/ui/app/AppLayouts/Onboarding/views/KeysMainView.qml index 0442844691..57d4cccd57 100644 --- a/ui/app/AppLayouts/Onboarding/views/KeysMainView.qml +++ b/ui/app/AppLayouts/Onboarding/views/KeysMainView.qml @@ -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 { diff --git a/ui/app/AppLayouts/Onboarding/views/TouchIDAuthView.qml b/ui/app/AppLayouts/Onboarding/views/TouchIDAuthView.qml index dc04037e3b..ab2cc50d5a 100644 --- a/ui/app/AppLayouts/Onboarding/views/TouchIDAuthView.qml +++ b/ui/app/AppLayouts/Onboarding/views/TouchIDAuthView.qml @@ -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 diff --git a/ui/app/AppLayouts/Onboarding/views/WelcomeView.qml b/ui/app/AppLayouts/Onboarding/views/WelcomeView.qml index b209fb63b1..c6afd39d2b 100644 --- a/ui/app/AppLayouts/Onboarding/views/WelcomeView.qml +++ b/ui/app/AppLayouts/Onboarding/views/WelcomeView.qml @@ -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 {