Index: sources/gui/qml/pages/settings/SettingsStack.qml =================================================================== diff -u -r944eb07705486e6c76221e6d3ff00c7f33613ec5 -r78b3d1f4e6675e6a8c5ae3801d134e2d7a49ad06 --- sources/gui/qml/pages/settings/SettingsStack.qml (.../SettingsStack.qml) (revision 944eb07705486e6c76221e6d3ff00c7f33613ec5) +++ sources/gui/qml/pages/settings/SettingsStack.qml (.../SettingsStack.qml) (revision 78b3d1f4e6675e6a8c5ae3801d134e2d7a49ad06) @@ -1,21 +1,20 @@ /*! * - * Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. + * Copyright (c) 2021-2024 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) 03-Apr-2023 + * \author (last) Dara Navaei + * \date (last) 24-Oct-2024 * \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,79 +39,151 @@ property bool serviceMode : false + readonly property bool normalMode : ! ( _GuiView.manufactSetup || _GuiView.updateSetup ) + readonly property bool setupMode : _GuiView.manufactSetup || _GuiView.updateSetup + readonly property bool onlyManufacturing : _GuiView.manufactMode && ! _GuiView.updateMode // <...>Mode is true if the POST passes + readonly property bool onlyUpdating : ! _GuiView.manufactMode && _GuiView.updateMode // <...>Mode is true if the POST passes + readonly property bool loggedIn : serviceMode + + + readonly property bool visibleLanguage : false + readonly property bool visibleSWUpdate : false + readonly property bool visibleDGScheduling : false + readonly property bool visibleCalibration : false + + readonly property bool visibleInformation : true + readonly property bool visibleVolumeBrightness : ! onlyUpdating // same as service password, on application execution in updating, on mount files will be moved. + readonly property bool visibleWiFi : true + readonly property bool visibleBluetooth : true + readonly property bool visibleExportLogs : true + + // during the update we cannot enable the servce menu since the current set password is in ~denali folder + // not the ~root which is the working folder during update. + //TODO in case is required we need to copy from denali to root for the update and copy back again, + // if works it is a better approach better. + readonly property bool visibleServicePassword : ( normalMode && ! loggedIn ) // || ( onlyUpdating && ! loggedIn ) + readonly property bool visibleDGCleaning : normalMode + readonly property bool visibleRoInput : normalMode + readonly property bool visibleRootSSHAccess : loggedIn + readonly property bool visibleFactoryReset : loggedIn + readonly property bool visibleDecommission : loggedIn + readonly property bool visibleSetDateTime : loggedIn || onlyUpdating + readonly property bool visibleDeviceConfiguration : onlyManufacturing && loggedIn + readonly property bool visibleDeviceRegistration : onlyManufacturing && loggedIn + readonly property bool visibleInstitutionalRecord : true + + enum ItemsIndex { - Information , - VolumeBrightness, - WiFi , - Bluetooth , - DGSettings , - Services , - SetDateTime , - ExportLogs , - RoInput , - Language , - Calibration , - SWUpdate , - FactoryReset + Information , + VolumeBrightness , + WiFi , + Bluetooth , + DGCleaning , + DGScheduling , + ServicePassword , + SetDateTime , + ExportLogs , + Language , + RoInput , + Calibration , + DeviceConfiguration , + DeviceRegistration , + SWUpdate , + RootSSHAccess , + FactoryReset , + Decommission , + InstitutionalRecord } property var itemsText : [ qsTr("Information" ), // Information qsTr("Volume And Brightness" ), // VolumeBrightness qsTr("Wi-Fi" ), // WiFi qsTr("Bluetooth Cuff" ), // Bluetooth - qsTr("DG Cleaning" ), // DGSettings - qsTr("Service" ), // Service - qsTr("Set Date And Time" ), // SetDateTime + qsTr("DG Cleaning" ), // DGCleaning + qsTr("DG Scheduling" ), // DGScheduling + qsTr("Service" ), // servicePassword + qsTr("Set Date and Time" ), // SetDateTime qsTr("Export Logs" ), // ExportLogs - qsTr("Water Input Mode" ), // RoInput qsTr("Set Language" ), // Language - qsTr("Calibration " ), // Calibration + qsTr("Water Input Mode" ), // RoInput + qsTr("Calibration" ), // Calibration + qsTr("Device Configuration" ), // Device Configuration + qsTr("Device Registration" ), // DeviceRegistration qsTr("Software Update" ), // SWUpdate + qsTr("Enable Root SSH" ), // RootSSHAccess qsTr("Factory Reset" ), // FactoryReset + qsTr("Decommissioning" ), // Decommission + qsTr("Institutional Configurations" ), // Institutional Configurations ] - property var itemsEnabled : [ - true , // Information - true , // VolumeBrightness - true , // WiFi - true , // Bluetooth - true , // DGSettings - true , // Services - true , // SetDateTime - true , // ExportLogs - true , // RoInput - false , // Language - false , // Calibration - false , // SWUpdate - false , // FactoryReset + property var itemsEnabled : [ + true , // Information + true , // VolumeBrightness + true , // WiFi + true , // Bluetooth + true , // DGCleaning + true , // DGScheduling + true , // ServicePassword + true , // SetDateTime + true , // ExportLogs + true , // Language + true , // RoInput + true , // Calibration + true , // Device Configuration + true , // DeviceRegistration + true , // SWUpdate + true , // RootSSHAccess + true , // FactoryReset + true , // Decommission + true , // Institutional Record ] property var itemsVisible : [ - true , // Information - true , // VolumeBrightness - true , // WiFi - true , // Bluetooth - true , // DGSettings - ! serviceMode , // Services - serviceMode , // SetDateTime - true , // ExportLogs - true , // RoInput - false /* serviceMode phase 1 */ , // Language - false /* serviceMode phase 1 */ , // Calibration - false /* serviceMode phase 1 */ , // SWUpdate - false /* serviceMode phase 1 */ , // FactoryReset + visibleInformation , // Information + visibleVolumeBrightness , // VolumeBrightness + visibleWiFi , // WiFi + visibleBluetooth , // Bluetooth + visibleDGCleaning , // DGCleaning + visibleDGScheduling , // DGScheduling + visibleServicePassword , // ServicePassword + visibleSetDateTime , // SetDateTime + visibleExportLogs , // ExportLogs + visibleLanguage , // Language + visibleRoInput , // RoInput + visibleCalibration , // Calibration + visibleDeviceConfiguration , // Device Configuration + visibleDeviceRegistration , // DeviceRegistration + visibleSWUpdate , // SWUpdate + visibleRootSSHAccess , // RootSSHAccess + visibleFactoryReset , // FactoryReset + visibleDecommission , // Decommission + visibleInstitutionalRecord , // Institutional Record ] SettingsHome { id : _settingsHome - title : serviceMode ? qsTr("Service") : qsTr("Device Settings") + title : _GuiView.manufactSetup ? qsTr("Manufacturing Setup") : serviceMode ? qsTr("Service") : _GuiView.updateSetup ? qsTr("Software Update") : qsTr("Device Settings") backVisible : false - confirmVisible : serviceMode - confirmText.text: qsTr("SHUTDOWN") - onConfirmClicked: _GuiView.doActionTransmit(GuiActions.ID_PowerOff, GuiActions.NoData) + //TODO on graceful shutdown, the applicaiton quit shall be used for any applicaiton termination + // and needs to be distinguished between the QUIT or SHUTDOWN touch, + // to know whether to run the lockdown scropt or just quit the app. + confirmVisible : serviceMode || _GuiView.updateMode + confirmText.text: _GuiView.manufactMode || _GuiView.updateMode ? qsTr("COMPLETE") : qsTr("SHUTDOWN") + onConfirmClicked: { + if ( _GuiView.manufactSetup || _GuiView.updateSetup ) { + _GuiView.doQuitApplication() + } + else { + _GuiView.doActionTransmit(GuiActions.ID_PowerOff, GuiActions.NoData) + } + } itemsText : _root.itemsText itemsEnabled : _root.itemsEnabled itemsVisible : _root.itemsVisible onItemClicked : { + vDevice.status = "" switch (vIndex) { case SettingsStack.Information: + vAdjustmentVersions .doAdjustment() + vAdjustmentServiceDates .doAdjustment() + vHDUsageInfo .doAdjustment() push(_settingsInformation) break @@ -131,11 +202,15 @@ push( _settingsBluetooth ) break - case SettingsStack.DGSettings: - push( _settingsDGSettings ) + case SettingsStack.DGCleaning: + push( _settingsDGCleaning ) break - case SettingsStack.Services: + case SettingsStack.DGScheduling: + push( _settingsDGScheduling ) + break + + case SettingsStack.ServicePassword: push(_servicePassword) _servicePassword.setFocus() break @@ -154,215 +229,65 @@ push( _settingsRoInput ) break - default: - console.debug("Unknown Index", vIndex) + case SettingsStack.DeviceConfiguration: + push( _settingsDeviceConfiguration ) break - } - } - } - SettingsBase { id: _settingsInformation - itemIndex : SettingsStack.Information - confirmVisible : false - onVisibleChanged: { - if ( visible ) { - vAdjustmentVersions .doAdjustment() - vAdjustmentServiceDates .doAdjustment() - } - } + case SettingsStack.DeviceRegistration: + push( _settingsDeviceRegistration ) + break - TouchGrid { - anchors.centerIn: parent - colCount : 2 - colSpacing : 50 - rowCount : 8 - rowSpacing : 0 - itemHeight : 50 - itemWidth : 550 - touchable : false - itemsHasLine: [ - 0, // title C1 - 1,1,1,1,1,1,1, - 0, // title C2 - 1,1,1,1, - ] - itemsValueLeftMargin: 300 - itemsValue : [ - "" , - Qt .application.version, - vAdjustmentVersions .hdVerDevice , - vAdjustmentVersions .hdVerFPGA , - vAdjustmentVersions .hdSerial , - vAdjustmentVersions .dgVerDevice , - vAdjustmentVersions .dgVerFPGA , - vAdjustmentVersions .dgSerial , - "", - vAdjustmentServiceDates .hdLastServiceDate , - vAdjustmentServiceDates .hdNextServiceDate , - vAdjustmentServiceDates .dgLastServiceDate , - vAdjustmentServiceDates .dgNextServiceDate , - ] - itemsText : [ - qsTr("Versions" ), // col1 title - qsTr("UI Version" ), - qsTr("HD Version" ), - qsTr("HD FPGA Version" ), - qsTr("HD Serial Number" ), - qsTr("DG Version" ), - qsTr("DG FPGA Version" ), - qsTr("DG Serial Number" ), + case SettingsStack.RootSSHAccess: + vDevice.doInitRootSSHAccess() + push( _SettingsRootSSHAccess) + break - qsTr("Service" ), // col2 title - qsTr("HD Last Service Date" ), - qsTr("HD Next Service Date" ), - qsTr("DG Last Service Date" ), - qsTr("DG Next Service Date" ), + case SettingsStack.FactoryReset: + push( _serviceFactoryReset ) + break - ] - } - } + case SettingsStack.Decommission: + push( _serviceDecommission ) + break - SettingsVolumeBrightness { id: _settingsVolumeBrightness - itemIndex : SettingsStack.VolumeBrightness - } + case SettingsStack.InstitutionalRecord: + vAdjustmentInstitutionalRecord.doAdjustment() + push( _settingsInstitutionalRecord ) + break - SettingsDateTime { id: _settingsDateTime - itemIndex : SettingsStack.SetDateTime - } - - SettingsWiFi { id: _settingsWiFi - itemIndex : SettingsStack.WiFi - } - - SettingsBluetoothCuff { id: _settingsBluetooth - } - - SettingsDG { id: _settingsDGSettings - 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 + default: + console.debug("Unknown Index", vIndex) + break } - - 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 onClicked() { - 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 - } - } } - UserConfirmation { id: _servicePassword - property bool isPassword_Accepted : false - property bool isDefaultPasswordSet : (vSettings.servicePass != "") + SettingsInformation { id: _settingsInformation } + SettingsVolumeBrightness { id: _settingsVolumeBrightness } + SettingsWiFi { id: _settingsWiFi } + SettingsBluetoothCuff { id: _settingsBluetooth } + SettingsDGCleaning { id: _settingsDGCleaning } + SettingsDGScheduling { id: _settingsDGScheduling } + SettingsServicePassword { id: _servicePassword } + SettingsDateTime { id: _settingsDateTime } + SettingsExportLogs { id: _settingsExportLogs } + SettingsROInput { id: _settingsRoInput } + SettingsManufacturingSetup { id: _settingsDeviceConfiguration } + SettingsDeviceRegistration { id: _settingsDeviceRegistration } + SettingsRootSSHAccess { id: _SettingsRootSSHAccess } + SettingsFactoryReset { id: _serviceFactoryReset } + SettingsDecommission { id: _serviceDecommission } + SettingsInstitutionalRecord { id: _settingsInstitutionalRecord } - itemIndex : SettingsStack.Services - title : isDefaultPasswordSet ? qsTr("Service Password") : qsTr("Set Service Password") - isPassword: true - showPasswordReEntryField: !isDefaultPasswordSet - onBackClicked : { - clearPassword() - if(!isDefaultPasswordSet){ - clearPasswordReEntry() - } - _settingsHome.notificationText = "" - } - onConfirmClicked: { - 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) - } - } - clearPassword() - pop() // pop back to settings screen and wait for the HD-OpMode change to Service_Mode to update the settings screen. - } + function gotoServiceMode( vservice ) { + //DEBUG console.log (" 0 ---------- ", _GuiView.manufactMode, _GuiView.manufactSetup, vservice, stackView.initialItem, stackView.currentItem, stackView.depth) + if ( ! _servicePassword.isPassword_Accepted ) return + serviceMode = vservice + if ( vservice ) + _mainMenu.hidden = true + else + if ( _settingsHome.visible ) + _mainMenu.hidden = false } Connections { target: vAdjustmentServiceMode @@ -376,25 +301,54 @@ } } - function gotoServiceMode( vservice ) { - if ( ! _servicePassword.isPassword_Accepted ) return - serviceMode = vservice - if ( vservice ) - _mainMenu.hidden = true - else - if ( _settingsHome.visible ) - _mainMenu.hidden = false + Connections { target: vAdjustmentInstitutionalRecord + function onAdjustmentTriggered ( vValue ) { + if ( vAdjustmentInstitutionalRecord.adjustment_Accepted ) { + _settingsHome.notificationText = "" + } + else { + _settingsHome.notificationText = vAdjustmentInstitutionalRecord.text() + } + } } - Connections { target: vHDOperationMode function onServiceChanged ( vValue ) { gotoServiceMode( vValue )} function onStandbyWaitDisinfectChanged ( vValue ) { page( _settingsHome , vValue )} } + Connections { target: _GuiView + function onManufactModeChanged( vPass ) { + if ( _GuiView.manufactMode ) { + vSettings.checkServicePasswordSet() + stackView.initialItem = _servicePassword + } + else { + stackView.initialItem = _settingsHome + } + push(stackView.initialItem) + + //DEBUG console.log (" 1 ---------- ", _GuiView.manufactMode, _GuiView.manufactSetup, vPass, stackView.initialItem, stackView.currentItem, stackView.depth) + if ( _GuiView.manufactSetup ) { + _settingsHome.notificationText = vPass ? "" : qsTr("Application POST Failed, please shutdown and retry") + } + } + function onUpdateModeChanged( vPass ) { + if ( _GuiView.UpdateMode ) { + stackView.initialItem = _settingsHome + } + push(stackView.initialItem) + + //DEBUG console.log (" 1 ---------- ", _GuiView.manufactMode, _GuiView.manufactSetup, vPass, stackView.initialItem, stackView.currentItem, stackView.depth) + if ( _GuiView.updateSetup ) { + _settingsHome.notificationText = vPass ? "" : qsTr("Application POST Failed, please shutdown and retry") + } + } + } + onVisibleChanged: { if (visible) { - _mainMenu.hidden = serviceMode + _mainMenu.hidden = serviceMode || _GuiView.manufactSetup } else { stackView.initialItem = null