Index: sources/gui/qml/pages/settings/SettingsStack.qml =================================================================== diff -u -r13d6a4fae2f910ab6e289ac9280258a94f734405 -r559dc64d12cf7647ec8c29ccbf4ca90f90e5e3a2 --- sources/gui/qml/pages/settings/SettingsStack.qml (.../SettingsStack.qml) (revision 13d6a4fae2f910ab6e289ac9280258a94f734405) +++ sources/gui/qml/pages/settings/SettingsStack.qml (.../SettingsStack.qml) (revision 559dc64d12cf7647ec8c29ccbf4ca90f90e5e3a2) @@ -1,25 +1,27 @@ /*! * - * Copyright (c) 2019-2020 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) 01-Mar-2021 + * \date (last) 03-Apr-2023 * \author (original) Behrouz NematiPour - * \date (original) 21-Oct-2019 + * \date (original) 16-Apr-2021 * */ // Qt -import QtQuick 2.12 +import QtQuick 2.12 +import QtQuick.Controls 2.12 // Switch // Project import Gui.Actions 0.1 // Qml imports +import "qrc:/" import "qrc:/globals" import "qrc:/components" import "qrc:/compounds" @@ -39,41 +41,50 @@ property bool serviceMode : false enum ItemsIndex { - Information , - VolumeBrightness, - WiFi , - Bluetooth , - DGSettings , - Services , - SetDateTime , - Language , - Calibration , - SWUpdate , + Information , + VolumeBrightness , + WiFi , + Bluetooth , + DGSettings , + Services , + SetDateTime , + ExportLogs , + RoInput , + Language , + Calibration , + DeviceRegistration , + SWUpdate , FactoryReset } property var itemsText : [ qsTr("Information" ), // Information qsTr("Volume And Brightness" ), // VolumeBrightness qsTr("Wi-Fi" ), // WiFi - qsTr("Bluetooth" ), // Bluetooth - qsTr("Dialysate Generator Settings" ), // DGSettings - qsTr("Services" ), // Services + qsTr("Bluetooth Cuff" ), // Bluetooth + qsTr("DG Cleaning" ), // DGSettings + 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 ] property var itemsEnabled : [ true , // Information true , // VolumeBrightness true , // WiFi - false , // Bluetooth + true , // Bluetooth true , // DGSettings true , // Services true , // SetDateTime + true , // ExportLogs + true , // RoInput false , // Language false , // Calibration + true , // DeviceRegistration false , // SWUpdate false , // FactoryReset ] @@ -85,19 +96,86 @@ true , // DGSettings ! serviceMode , // Services serviceMode , // SetDateTime - serviceMode , // Language - serviceMode , // Calibration - serviceMode , // SWUpdate - serviceMode , // FactoryReset + 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 ] + SettingsHome { id : _settingsHome + title : serviceMode ? qsTr("Service") : qsTr("Device Settings") + backVisible : false + confirmVisible : serviceMode + confirmText.text: qsTr("SHUTDOWN") + onConfirmClicked: _GuiView.doActionTransmit(GuiActions.ID_PowerOff, GuiActions.NoData) + itemsText : _root.itemsText + itemsEnabled : _root.itemsEnabled + itemsVisible : _root.itemsVisible + onItemClicked : { + switch (vIndex) { + case SettingsStack.Information: + push(_settingsInformation) + break + + case SettingsStack.VolumeBrightness: + vDevice.doInitBrightness() + push(_settingsVolumeBrightness) + break + + case SettingsStack.WiFi: + vNetwork.doInit() + push( _settingsWiFi ) + // _settingsWiFi.setFocus() // No keyboard popup. + break + + case SettingsStack.Bluetooth: + push( _settingsBluetooth ) + break + + case SettingsStack.DGSettings: + push( _settingsDGSettings ) + break + + case SettingsStack.Services: + push(_servicePassword) + _servicePassword.setFocus() + break + + case SettingsStack.SetDateTime: + vDateTime.doInit() + push( _settingsDateTime ) + _settingsDateTime.setFocus() + break + + case SettingsStack.ExportLogs: + push( _settingsExportLogs ) + break + + case SettingsStack.RoInput: + push( _settingsRoInput ) + break + + case SettingsStack.DeviceRegistration: + push( _settingsDeviceRegistration ) + break + + default: + console.debug("Unknown Index", vIndex) + break + } + } + } + SettingsBase { id: _settingsInformation itemIndex : SettingsStack.Information confirmVisible : false onVisibleChanged: { if ( visible ) { - vAdjustmentVersions.doAdjustment() - vAdjustmentService .doAdjustment() + vAdjustmentVersions .doAdjustment() + vAdjustmentServiceDates .doAdjustment() } } @@ -116,21 +194,21 @@ 0, // title C2 1,1,1,1, ] - itemsValueLeftMargin: 350 + itemsValueLeftMargin: 300 itemsValue : [ - "" , - Qt.application.version , - vAdjustmentVersions.hdVerDevice , - vAdjustmentVersions.hdVerFPGA , - vAdjustmentVersions.hdSerial , - vAdjustmentVersions.dgVerDevice , - vAdjustmentVersions.dgVerFPGA , - vAdjustmentVersions.dgSerial , + "" , + Qt .application.version, + vAdjustmentVersions .hdVerDevice , + vAdjustmentVersions .hdVerFPGA , + vAdjustmentVersions .hdSerial , + vAdjustmentVersions .dgVerDevice , + vAdjustmentVersions .dgVerFPGA , + vAdjustmentVersions .dgSerial , "", - vAdjustmentService.hdLastServiceDate , - vAdjustmentService.hdNextServiceDate , - vAdjustmentService.dgLastServiceDate , - vAdjustmentService.dgNextServiceDate , + vAdjustmentServiceDates .hdLastServiceDate , + vAdjustmentServiceDates .hdNextServiceDate , + vAdjustmentServiceDates .dgLastServiceDate , + vAdjustmentServiceDates .dgNextServiceDate , ] itemsText : [ qsTr("Versions" ), // col1 title @@ -142,7 +220,7 @@ qsTr("DG FPGA Version" ), qsTr("DG Serial Number" ), - qsTr("Services" ), // col2 title + qsTr("Service" ), // col2 title qsTr("HD Last Service Date" ), qsTr("HD Next Service Date" ), qsTr("DG Last Service Date" ), @@ -153,105 +231,180 @@ } SettingsVolumeBrightness { id: _settingsVolumeBrightness - itemIndex : SettingsStack.VolumeBrightness + itemIndex : SettingsStack.VolumeBrightness } SettingsDateTime { id: _settingsDateTime - itemIndex : SettingsStack.SetDateTime + itemIndex : SettingsStack.SetDateTime } SettingsWiFi { id: _settingsWiFi - itemIndex : SettingsStack.WiFi + itemIndex : SettingsStack.WiFi } - SettingsBase { id: _settingsBluetooth - itemIndex : SettingsStack.Bluetooth + SettingsBluetoothCuff { id: _settingsBluetooth } SettingsDG { id: _settingsDGSettings - itemIndex : SettingsStack.DGSettings + itemIndex : SettingsStack.DGSettings } + SettingsExportLogs { id: _settingsExportLogs + 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("Please Enter The 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.settings["Service Password"] === undefined ) { - _settingsHome.notificationText = qsTr("No service password defined") - } - else { - if ( password === vSettings.settings["Service Password"].keys[0] ) { - _settingsHome.notificationText = "" - serviceMode = 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. } } - SettingsHome { id : _settingsHome - backVisible : false - confirmVisible : serviceMode - confirmText.text: qsTr("SHUTDOWN") - onConfirmClicked: _GuiView.doActionTransmit(GuiActions.ID_PowerOff, GuiActions.NoData) - itemsText : _root.itemsText - itemsEnabled : _root.itemsEnabled - itemsVisible : _root.itemsVisible - onItemClicked : { - switch (vIndex) { - case SettingsStack.Information: - push(_settingsInformation) - break + Connections { target: vAdjustmentServiceMode + function onAdjustmentTriggered ( vValue ) { + if ( vAdjustmentServiceMode.adjustment_Accepted ) { + _settingsHome.notificationText = "" + } + else { + _settingsHome.notificationText = vAdjustmentServiceMode.text() + } + } + } - case SettingsStack.VolumeBrightness: - vDevice.doInitBrightness() - push(_settingsVolumeBrightness) - break + function gotoServiceMode( vservice ) { + if ( ! _servicePassword.isPassword_Accepted ) return + serviceMode = vservice + if ( vservice ) + _mainMenu.hidden = true + else + if ( _settingsHome.visible ) + _mainMenu.hidden = false + } - case SettingsStack.SetDateTime: - vDateTime.doInit() - push( _settingsDateTime ) - _settingsDateTime.setFocus() - break - case SettingsStack.WiFi: - vNetwork.doInit() - push( _settingsWiFi ) - // _settingsWiFi.setFocus() // No keyboard popup. - break - - case SettingsStack.Bluetooth: - push( _settingsBluetooth ) - break - - case SettingsStack.DGSettings: - push( _settingsDGSettings ) - break - - case SettingsStack.Services: - push(_servicePassword) - _servicePassword.setFocus() - break - - default: - console.debug("Unknown Index", vIndex) - break - } - } + Connections { target: vHDOperationMode + function onServiceChanged ( vValue ) { gotoServiceMode( vValue )} + function onStandbyWaitDisinfectChanged ( vValue ) { page( _settingsHome , vValue )} } onVisibleChanged: { if (visible) { - _mainMenu.hidden = false + _mainMenu.hidden = serviceMode } else { stackView.initialItem = null