Index: sources/gui/qml/pages/settings/SettingsStack.qml =================================================================== diff -u -rc9f8f8cf3c6c37fc6460d8675c62c9442c4d4263 -r4012b0f98277c73f6afb4ee4ccf5e876f062b4ad --- sources/gui/qml/pages/settings/SettingsStack.qml (.../SettingsStack.qml) (revision c9f8f8cf3c6c37fc6460d8675c62c9442c4d4263) +++ sources/gui/qml/pages/settings/SettingsStack.qml (.../SettingsStack.qml) (revision 4012b0f98277c73f6afb4ee4ccf5e876f062b4ad) @@ -237,38 +237,51 @@ } UserConfirmation { id: _servicePassword + property bool isPassword_Accepted : false + property bool isDefaultPasswordSet : (vSettings.servicePass != "") + itemIndex : SettingsStack.Services - title : qsTr("Service Password") + title : isDefaultPasswordSet ? qsTr("Service Password") : qsTr("Set Service Password") isPassword: true + showPasswordReEntryField: !isDefaultPasswordSet onBackClicked : { clearPassword() + if(!isDefaultPasswordSet){ + clearPasswordReEntry() + } _settingsHome.notificationText = "" } onConfirmClicked: { - if ( vSettings.servicePass === "" ) { - _settingsHome.notificationText = qsTr("No service password defined") - } - else { - if ( password === vSettings.servicePass ) { - _settingsHome.notificationText = "" - vAdjustmentServiceMode.doAdjustment() - if ( vSettings.noCANBus ) { // if NoCANBus is set don't wait for HD and go to service mode. - gotoServiceMode(true) - } + isPassword_Accepted = false + let password = _servicePassword.password + if ( !isDefaultPasswordSet ) { + let passwordReEntry = _servicePassword.passwordReEntry + if ( password != passwordReEntry ) { _servicePassword.notificationText = qsTr("Mismatched Password Entry"); return } + if (!vSettings.isPasswordValid(password)) { _servicePassword.notificationText = qsTr("Malformed Password Entry" ); return } + + vSettings.updatePassword(password) + _servicePassword.isPassword_Accepted = true + _servicePassword.notificationText = "" + clearPasswordReEntry() + } else { + if (!vSettings.isPasswordMatch(password)) { _servicePassword.notificationText = qsTr("Incorrect service password"); return } + + _servicePassword.isPassword_Accepted = true + _servicePassword.notificationText = "" + vAdjustmentServiceMode.doAdjustment() + if ( vSettings.noCANBus ) { // if NoCANBus is set don't wait for HD and go to service mode. + gotoServiceMode(true) } - else { - _settingsHome.notificationText = qsTr("Incorrect service password") - } } clearPassword() - pop() + pop() // pop back to settings screen and wait for the HD-OpMode change to Service_Mode to update the settings screen. } } Connections { target: vAdjustmentServiceMode function onAdjustmentTriggered ( vValue ) { - if ( vAdjustmentServiceMode.adjustment_Accepted ) { - _settingsHome.notificationText = "" + if ( vAdjustmentServiceMode.adjustment_Accepted ) { + _settingsHome.notificationText = "" } else { _settingsHome.notificationText = vAdjustmentServiceMode.text() @@ -277,7 +290,7 @@ } function gotoServiceMode( vservice ) { -// push( _settingsHome , vservice ) + if ( ! _servicePassword.isPassword_Accepted ) return serviceMode = vservice if ( vservice ) _mainMenu.hidden = true