Index: sources/gui/qml/pages/settings/SettingsServicePassword.qml =================================================================== diff -u -r7ec98d237f871e5d1206809d309da6d57a086d28 -rbba70435ebe0bbbc9bf5b4282f7d0906a8b49b1a --- sources/gui/qml/pages/settings/SettingsServicePassword.qml (.../SettingsServicePassword.qml) (revision 7ec98d237f871e5d1206809d309da6d57a086d28) +++ sources/gui/qml/pages/settings/SettingsServicePassword.qml (.../SettingsServicePassword.qml) (revision bba70435ebe0bbbc9bf5b4282f7d0906a8b49b1a) @@ -30,42 +30,48 @@ property bool isPassword_Accepted : false property bool isDefaultPasswordSet : vSettings.isPasswordSet - onIsDefaultPasswordSetChanged: console.log(isDefaultPasswordSet) + backVisible : ! _GuiView.manufactSetup + title : isDefaultPasswordSet ? qsTr("Service Password") : qsTr("Set Service Password") + isPassword : true + passwordChangeMode : ! isDefaultPasswordSet - backVisible : ! _GuiView.manufactSetup - title : isDefaultPasswordSet ? qsTr("Service Password") : qsTr("Set Service Password") - isPassword : true - showPasswordReEntryField: !isDefaultPasswordSet - onBackClicked : { - clearPassword() - if(!isDefaultPasswordSet){ - clearPasswordReEntry() - } + onBackClicked : { + clearPasswords() _settingsHome.notificationText = "" } + onConfirmClicked: { - isPassword_Accepted = false - let password = _root.password - if ( !isDefaultPasswordSet ) { - let passwordReEntry = _root.passwordReEntry - if ( password != passwordReEntry ) { _root.notificationText = qsTr("Mismatched Password Entry"); return } - if (!vSettings.isPasswordValid(password)) { _root.notificationText = qsTr("Malformed Password Entry" ); return } + // check for password(s), and check the accpeted flag + isPassword_Accepted = checkPassword() - vSettings.updatePassword(password) - _root.isPassword_Accepted = true - _root.notificationText = "" - clearPasswordReEntry() - } else { - if (!vSettings.isPasswordMatch(password)) { _root.notificationText = qsTr("Incorrect service password"); return } + // if not accepted return + if ( ! isPassword_Accepted ) return - _root.isPassword_Accepted = true - _root.notificationText = "" - if ( vSettings.noCANBus ) { // if NoCANBus is set don't wait for HD and go to service mode. - gotoServiceMode(true) - } - } + // of accepted save the password + if ( passwordChangeMode ) vSettings.updatePassword(passwordUpdated) + + // ask HD to go to service mode vAdjustmentServiceMode.doAdjustment() - clearPassword() + + // clear the screen + _root.notificationText = "" + clearPasswords() + + // go back to the settings home/menu screen page(_settingsHome) + + // if NoCANBus is set don't wait for HD and go to service mode. + if ( vSettings.noCANBus ) gotoServiceMode(true) } + + function checkPassword() { + if ( ! vSettings.isPasswordMatch(passwordCurrent ) ) { _root.notificationText = qsTr("Incorrect password" ); return false } + + if ( ! passwordChangeMode ) { _root.notificationText = "" ; return true } + + if ( passwordConfirm != passwordUpdated ) { _root.notificationText = qsTr("Mismatch Passwords" ); return false } + if ( ! vSettings.isPasswordValid(passwordUpdated ) ) { _root.notificationText = qsTr("Invalid Password" ); return false } + + _root.notificationText = "" ; return true + } }