diff --git a/ui/app/AppLayouts/Onboarding/views/ConfirmPasswordView.qml b/ui/app/AppLayouts/Onboarding/views/ConfirmPasswordView.qml index 6158a2ac67..60254253a6 100644 --- a/ui/app/AppLayouts/Onboarding/views/ConfirmPasswordView.qml +++ b/ui/app/AppLayouts/Onboarding/views/ConfirmPasswordView.qml @@ -23,6 +23,41 @@ OnboardingBasePage { property string displayName function forcePswInputFocus() { confPswInput.forceActiveFocus(Qt.MouseFocusReason)} + QtObject { + id: d + + function checkPasswordMatches() { + if (confPswInput.text !== root.password) { + errorTxt.text = qsTr("Passwords don't match") + return false + } + return true + } + + function submit() { + if (!checkPasswordMatches()) { + return + } + + if (OnboardingStore.accountCreated) { + if (root.password !== root.tmpPass) { + OnboardingStore.changePassword(root.tmpPass, root.password) + root.tmpPass = root.password + } + else { + submitBtn.loading = false + root.exit(); + } + } + else { + root.tmpPass = root.password + submitBtn.loading = true + OnboardingStore.setCurrentAccountAndDisplayName(root.displayName) + pause.start() + } + } + } + Column { id: view spacing: 4 * Style.current.padding @@ -81,9 +116,8 @@ OnboardingBasePage { textField.validator: RegExpValidator { regExp: /^[!-~]{0,64}$/ } // That incudes NOT extended ASCII printable characters less space and a maximum of 64 characters allowed keepHeight: true textField.rightPadding: showHideCurrentIcon.width + showHideCurrentIcon.anchors.rightMargin + Style.current.padding / 2 - onTextChanged: { - errorTxt.text = "" - } + onTextChanged: { errorTxt.text = "" } + Keys.onReturnPressed: { if(submitBtn.enabled) d.submit()} StatusFlatRoundButton { id: showHideCurrentIcon @@ -134,22 +168,7 @@ OnboardingBasePage { } } - onClicked: { - if (OnboardingStore.accountCreated) { - if (root.password !== root.tmpPass) { - OnboardingStore.changePassword(root.tmpPass, root.password); - root.tmpPass = root.password; - } else { - submitBtn.loading = false - root.exit(); - } - } else { - root.tmpPass = root.password; - submitBtn.loading = true - OnboardingStore.setCurrentAccountAndDisplayName(root.displayName); - pause.start(); - } - } + onClicked: { d.submit() } Connections { target: onboardingModule diff --git a/ui/app/AppLayouts/Onboarding/views/CreatePasswordView.qml b/ui/app/AppLayouts/Onboarding/views/CreatePasswordView.qml index 136368c491..6cd55824a9 100644 --- a/ui/app/AppLayouts/Onboarding/views/CreatePasswordView.qml +++ b/ui/app/AppLayouts/Onboarding/views/CreatePasswordView.qml @@ -20,6 +20,12 @@ OnboardingBasePage { id: d readonly property int zBehind: 1 readonly property int zFront: 100 + + function submit() { + root.newPassword = view.newPswText + root.confirmationPassword = view.confirmationPswText + root.exit() + } } Column { @@ -31,6 +37,7 @@ OnboardingBasePage { onboarding: true newPswText: root.newPassword confirmationPswText: root.confirmationPassword + onReturnPressed: { if(view.ready) d.submit() } } StatusButton { id: submitBtn @@ -38,11 +45,7 @@ OnboardingBasePage { anchors.horizontalCenter: parent.horizontalCenter text: qsTr("Create password") enabled: view.ready - onClicked: { - root.newPassword = view.newPswText - root.confirmationPassword = view.confirmationPswText - root.exit() - } + onClicked: { d.submit() } } } diff --git a/ui/app/AppLayouts/Profile/popups/ChangePasswordModal.qml b/ui/app/AppLayouts/Profile/popups/ChangePasswordModal.qml index ac84f8379a..9144005c66 100644 --- a/ui/app/AppLayouts/Profile/popups/ChangePasswordModal.qml +++ b/ui/app/AppLayouts/Profile/popups/ChangePasswordModal.qml @@ -33,6 +33,17 @@ StatusModal { submitBtn.loading = false } + QtObject { + id: d + + function submit() { + submitBtn.loading = true + // ChangePassword operation blocks the UI so loading = true; will never have any affect until changePassword/createPassword is done. + // Getting around it with a small pause (timer) in order to get the desired behavior + pause.start() + } + } + Connections { target: root.privacyStore.privacyModule onPasswordChanged: onChangePasswordResponse(success, errorMsg) @@ -52,6 +63,7 @@ StatusModal { titleVisible: false introText: qsTr("Change password used to unlock Status on this device & sign transactions.") createNewPsw: false + onReturnPressed: if(submitBtn.enabled) d.submit() } rightButtons: [ @@ -69,12 +81,7 @@ StatusModal { } } - onClicked: { - submitBtn.loading = true; - // ChangePassword operation blocks the UI so loading = true; will never have any affect until changePassword/createPassword is done. - // Getting around it with a small pause (timer) in order to get the desired behavior - pause.start(); - } + onClicked: { d.submit() } } ] diff --git a/ui/imports/shared/views/PasswordView.qml b/ui/imports/shared/views/PasswordView.qml index a06f17b162..e2948b8dc1 100644 --- a/ui/imports/shared/views/PasswordView.qml +++ b/ui/imports/shared/views/PasswordView.qml @@ -32,6 +32,8 @@ Column { property alias confirmationPswText: confirmPswInput.text property alias errorMsgText: errorTxt.text + signal returnPressed() + function forceNewPswInputFocus() { newPswInput.forceActiveFocus(Qt.MouseFocusReason) } function reset() { @@ -176,6 +178,7 @@ Column { textField.validator: d.validator keepHeight: true textField.rightPadding: showHideCurrentIcon.width + showHideCurrentIcon.anchors.rightMargin + Style.current.padding / 2 + Keys.onReturnPressed: { root.returnPressed() } StatusFlatRoundButton { id: showHideCurrentIcon @@ -220,6 +223,7 @@ Column { // Update strength indicator: strengthInditactor.strength = d.convertStrength(RootStore.getPasswordStrengthScore(newPswInput.text, root.onboarding)) } + Keys.onReturnPressed: { root.returnPressed() } StatusFlatRoundButton { id: showHideNewIcon @@ -322,6 +326,7 @@ Column { root.checkPasswordMatches(false) } } + Keys.onReturnPressed: { root.returnPressed() } StatusFlatRoundButton { id: showHideConfirmIcon