Index: sources/gui/qml/pages/UserConfirmation.qml =================================================================== diff -u -rc9f8f8cf3c6c37fc6460d8675c62c9442c4d4263 -r09a43d162e61ae02c73364e050d90957d736f322 --- sources/gui/qml/pages/UserConfirmation.qml (.../UserConfirmation.qml) (revision c9f8f8cf3c6c37fc6460d8675c62c9442c4d4263) +++ sources/gui/qml/pages/UserConfirmation.qml (.../UserConfirmation.qml) (revision 09a43d162e61ae02c73364e050d90957d736f322) @@ -29,9 +29,16 @@ SettingsBase { id: _root objectName : "UserConfirmation" // SquishQt testability - property bool isPassword: false - readonly property string password: _password.textInput.text - property alias message : _message.text + property bool isPassword : false + property bool showPasswordReEntryField : false + readonly property string password : _password.textInput.text + readonly property string passwordReEntry : _passwordReEntryField.textInput.text + property alias message : _message.text + + function clearPasswordReEntry() { + _passwordReEntryField.textInput.text = "" + } + function clearPassword() { _password.textInput.text = "" } @@ -43,7 +50,14 @@ textInput .width : 450 anchors { top : parent.top - topMargin : topMarginContent + 120 // moved a little down to be more on center and close to keyboard top edge. + topMargin : { + if(_root.showPasswordReEntryField) { + return topMarginContent + 120 - _passwordReEntryField.height + } else { + return topMarginContent + 120 // moved a little down to be more on center and close to keyboard top edge. + } + } + horizontalCenter: parent.horizontalCenter } textInput.inputMethodHints : Qt.ImhNone @@ -67,6 +81,36 @@ onReleased : _password.textInput.echoMode = TextInput.Password } + TextEntry { id : _passwordReEntryField + clip : true + visible : _root.showPasswordReEntryField + textInput .width : 450 + anchors { + top : _password.bottom + topMargin : height/2 // moved a little down to be more on center and close to keyboard top edge. + horizontalCenter: _password.horizontalCenter + } + textInput.inputMethodHints : Qt.ImhNone + textInput.echoMode : TextInput.Password + } + + Image { id : _showPasswordReEntryImage + visible : _passwordReEntryField.visible + anchors.left : _passwordReEntryField.right + anchors.leftMargin : Variables.minVGap + anchors.verticalCenter : _passwordReEntryField.verticalCenter + width : Variables.iconsDiameter + height : Variables.iconsDiameter + source : "qrc:/images/iEye" + } + + MouseArea { + anchors.fill: _showPasswordReEntryImage + anchors.margins: -20 + onPressed : _passwordReEntryField.textInput.echoMode = TextInput.Normal + onReleased : _passwordReEntryField.textInput.echoMode = TextInput.Password + } + Text { id : _message visible : ! _root.isPassword text : "Do you ... ?" Index: sources/gui/qml/pages/settings/SettingsStack.qml =================================================================== diff -u -rf2656247b7f73e4c2494605af2f7bdbbd26f776f -r09a43d162e61ae02c73364e050d90957d736f322 --- sources/gui/qml/pages/settings/SettingsStack.qml (.../SettingsStack.qml) (revision f2656247b7f73e4c2494605af2f7bdbbd26f776f) +++ sources/gui/qml/pages/settings/SettingsStack.qml (.../SettingsStack.qml) (revision 09a43d162e61ae02c73364e050d90957d736f322) @@ -237,38 +237,56 @@ } UserConfirmation { id: _servicePassword + property bool isDefaultPasswordSet : (vSettings.servicePass != "") + itemIndex : SettingsStack.Services title : qsTr("Service Password") isPassword: true + showPasswordReEntryField: !isDefaultPasswordSet onVisibleChanged: { - // TODO check for if password is set already if (visible) { - // check password with cpp. Open file and check + if (!isDefaultPasswordSet) { + _servicePassword.title = qsTr("Default Service Password") + } } } onBackClicked : { clearPassword() + if(!isDefaultPasswordSet){ + clearPasswordReEntry() + } _settingsHome.notificationText = "" } onConfirmClicked: { - // DEBUG console.log(vSettings.isPasswordConforming(password)) - if ( vSettings.servicePass === "" ) { - _settingsHome.notificationText = qsTr("No service password defined") - } - else { - if ( password === vSettings.servicePass ) { + if ( !isDefaultPasswordSet ) { + let password = _servicePassword.password + let passwordReEntry = _servicePassword.passwordReEntry + if (password == passwordReEntry) { + if(vSettings.isPasswordConforming(password)) { + vSettings.servicePass = vSettings.encryptString(password) + } else { + _servicePassword.title = qsTr("Malformed Password Entry") + } + } else { + _servicePassword.title = qsTr("Mismatched Password Entry") + } + clearPassword() + clearPasswordReEntry() + } else { + if ( vSettings.encryptString(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) } + clearPassword() + clearPasswordReEntry() + pop() } else { _settingsHome.notificationText = qsTr("Incorrect service password") } } - clearPassword() - pop() } } Index: sources/view/settings/VSettings.cpp =================================================================== diff -u -rf2656247b7f73e4c2494605af2f7bdbbd26f776f -r09a43d162e61ae02c73364e050d90957d736f322 --- sources/view/settings/VSettings.cpp (.../VSettings.cpp) (revision f2656247b7f73e4c2494605af2f7bdbbd26f776f) +++ sources/view/settings/VSettings.cpp (.../VSettings.cpp) (revision 09a43d162e61ae02c73364e050d90957d736f322) @@ -234,3 +234,8 @@ return hasCapitalized && hasNumeric && hasSymbol; } +// TODO this is a mock, need to add real encrypted string +QString VSettings::encryptString(const QString vString) { + return vString; +} + Index: sources/view/settings/VSettings.h =================================================================== diff -u -rf2656247b7f73e4c2494605af2f7bdbbd26f776f -r09a43d162e61ae02c73364e050d90957d736f322 --- sources/view/settings/VSettings.h (.../VSettings.h) (revision f2656247b7f73e4c2494605af2f7bdbbd26f776f) +++ sources/view/settings/VSettings.h (.../VSettings.h) (revision 09a43d162e61ae02c73364e050d90957d736f322) @@ -63,9 +63,9 @@ PROPERTY(QStringList , categorys , {} ) PROPERTY(QVariantMap , instructions , {} ) - SETTINGS(QString , servicePass ,"123" , Storage::Settings_Category_SettingsSystem , "Service" , "Password" ) - SETTINGS(quint8 , alarmVolume , 100 , Storage::Settings_Category_SettingsSystem , "Alarm" , "Volume" ) - SETTINGS(bool , noCANBus , false , Storage::Settings_Category_NoCANBus , "Navigation" , "Create Treatment To Patient ID" ) + SETTINGS(QString , servicePass , QString() , Storage::Settings_Category_SettingsSystem , "Service" , "Password" ) + SETTINGS(quint8 , alarmVolume , 100 , Storage::Settings_Category_SettingsSystem , "Alarm" , "Volume" ) + SETTINGS(bool , noCANBus , false , Storage::Settings_Category_NoCANBus , "Navigation" , "Create Treatment To Patient ID" ) VIEW_DEC(VSettings, SettingsData) @@ -75,7 +75,8 @@ void updateInstructions ( const QString &vGroup ); public slots: - bool isPasswordConforming(const QString vPassword); // TODO rename to be something more generic + bool isPasswordConforming(const QString vPassword); + QString encryptString (const QString vString ); private slots: void onActionReceive (GuiActionType vAction, const QVariantList &vData);