Index: sources/gui/qml/pages/settings/SettingsStack.qml =================================================================== diff -u -rf68b226e67eb500758ee94fe015df48931240013 -r559dc64d12cf7647ec8c29ccbf4ca90f90e5e3a2 --- sources/gui/qml/pages/settings/SettingsStack.qml (.../SettingsStack.qml) (revision f68b226e67eb500758ee94fe015df48931240013) +++ sources/gui/qml/pages/settings/SettingsStack.qml (.../SettingsStack.qml) (revision 559dc64d12cf7647ec8c29ccbf4ca90f90e5e3a2) @@ -1,20 +1,21 @@ /*! * - * Copyright (c) 2021-2022 Diality Inc. - All Rights Reserved. + * Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. * \copyright * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * * \file SettingsStack.qml * \author (last) Behrouz NematiPour - * \date (last) 28-Sep-2022 + * \date (last) 03-Apr-2023 * \author (original) Behrouz NematiPour * \date (original) 16-Apr-2021 * */ // Qt import QtQuick 2.12 +import QtQuick.Controls 2.12 // Switch // Project import Gui.Actions 0.1 @@ -40,17 +41,19 @@ property bool serviceMode : false enum ItemsIndex { - Information , - VolumeBrightness, - WiFi , - Bluetooth , - DGSettings , - Services , - SetDateTime , - ExportLogs , - Language , - Calibration , - SWUpdate , + Information , + VolumeBrightness , + WiFi , + Bluetooth , + DGSettings , + Services , + SetDateTime , + ExportLogs , + RoInput , + Language , + Calibration , + DeviceRegistration , + SWUpdate , FactoryReset } property var itemsText : [ @@ -62,8 +65,10 @@ qsTr("Service" ), // Service qsTr("Set Date And Time" ), // SetDateTime qsTr("Export Logs" ), // ExportLogs + qsTr("Water Input Mode" ), // RoInput qsTr("Set Language" ), // Language qsTr("Calibration " ), // Calibration + qsTr("Device Registeration" ), // DeviceRegistration qsTr("Software Update" ), // SWUpdate qsTr("Factory Reset" ), // FactoryReset ] @@ -76,8 +81,10 @@ true , // Services true , // SetDateTime true , // ExportLogs + true , // RoInput false , // Language false , // Calibration + true , // DeviceRegistration false , // SWUpdate false , // FactoryReset ] @@ -90,8 +97,10 @@ ! serviceMode , // Services serviceMode , // SetDateTime true , // ExportLogs + true , // RoInput false /* serviceMode phase 1 */ , // Language false /* serviceMode phase 1 */ , // Calibration + true /* serviceMode */ , // DeviceRegistration // FIXME: On the normal setting menu for now for development. false /* serviceMode phase 1 */ , // SWUpdate false /* serviceMode phase 1 */ , // FactoryReset ] @@ -145,6 +154,14 @@ push( _settingsExportLogs ) break + case SettingsStack.RoInput: + push( _settingsRoInput ) + break + + case SettingsStack.DeviceRegistration: + push( _settingsDeviceRegistration ) + break + default: console.debug("Unknown Index", vIndex) break @@ -236,39 +253,132 @@ itemIndex : SettingsStack.ExportLogs } + SettingsBase { id: _settingsRoInput + confirmVisible : false + itemIndex : SettingsStack.RoInput + + + Row { id: _settingsRoInputRow + anchors.centerIn: parent + + Text { id : _settingsRoInputLabel + text : qsTr("Pure Water Mode") + width : 300 + height : _settingsRoInputSwitch.height + color : Colors.white + font.pixelSize: Fonts.fontPixelButton + verticalAlignment : Text.AlignVCenter + horizontalAlignment : Text.AlignLeft + } + + Switch { id: _settingsRoInputSwitch + property bool active: true + + checked : vDuetRoWaterDG.status + + width : 85 + height : 85 + + indicator: Rectangle { + implicitWidth : Variables.sliderCircleDiameter * 1.7 + implicitHeight : Variables.sliderCircleDiameter - ( Variables.progressbarHandlerBorderWidth * 2 ) + radius : implicitHeight + anchors.centerIn: parent + color : _settingsRoInputSwitch.checked ? Colors.backgroundButtonSelect : Colors.createTreatmentInactive + border.color : _settingsRoInputSwitch.checked ? Colors.borderButton : Colors.createTreatmentInactive + Rectangle { + property real diameter : Variables.sliderCircleDiameter + x: _settingsRoInputSwitch.checked ? parent.width - width : 0 + anchors.verticalCenter: parent.verticalCenter + width : diameter + height : diameter + radius : diameter + color : _settingsRoInputSwitch.active ? Colors.highlightProgressBar : Colors.createTreatmentInactive + border { + width: Variables.progressbarHandlerBorderWidth + color: Colors.textMain + } + } + } + + contentItem: Text { + width : parent.width + height : parent.height + text : _settingsRoInputSwitch.checked ? qsTr("ON") : qsTr("OFF") + font.pixelSize: Fonts.fontPixelButton + color : _settingsRoInputSwitch.active ? Colors.textMain : Colors.textDisableButton + verticalAlignment : Text.AlignTop + horizontalAlignment : Text.AlignHCenter + } + } + } + + Connections { target: _settingsRoInputSwitch + function onCheckedChanged() { + vDuetRoWaterDG.doAdjustment ( _settingsRoInputSwitch.checked ) + } + } + Connections { target: vDuetRoWaterDG + function onAdjustmentTriggered(vValue) { + if ( vDuetRoWaterDG.adjustment_Accepted ) { + _settingsRoInput.notificationText = "" + } + else { + _settingsRoInput.notificationText = vDuetRoWaterDG.notification // adjustment_ReasonText + } + vSettings.roWaterMode = vDuetRoWaterDG.status + } + } + } + + SettingsDeviceRegistration { id: _settingsDeviceRegistration } + 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 +387,7 @@ } function gotoServiceMode( vservice ) { -// push( _settingsHome , vservice ) + if ( ! _servicePassword.isPassword_Accepted ) return serviceMode = vservice if ( vservice ) _mainMenu.hidden = true