Index: sources/gui/qml/PowerItem.qml =================================================================== diff -u -rc15ce613e372838316d42c40a86953e6f0aa05d3 -r2ef03b2ce51b4dc507f66e9671953a8e0824bde9 --- sources/gui/qml/PowerItem.qml (.../PowerItem.qml) (revision c15ce613e372838316d42c40a86953e6f0aa05d3) +++ sources/gui/qml/PowerItem.qml (.../PowerItem.qml) (revision 2ef03b2ce51b4dc507f66e9671953a8e0824bde9) @@ -1,15 +1,15 @@ /*! * - * Copyright (c) 2019-2020 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 PowerItem.qml * \author (last) Behrouz NematiPour - * \date (last) 28-Feb-2021 + * \date (last) 30-Aug-2023 * \author (original) Behrouz NematiPour - * \date (original) 28-Feb-2021 + * \date (original) 01-Mar-2021 * */ @@ -20,7 +20,6 @@ // C++ imports import Gui.View 0.1 import Gui.Actions 0.1 -import VPowerOff 0.1 // Qml imports import "qrc:/globals" @@ -34,15 +33,75 @@ Item { id: _root anchors.fill: parent - VPowerOff { id: vPowerOff } + property bool isOpen: false AutoHideInfo { id: _autoHideInfo } + ConfirmDialog { id: _powerOffDialog + idText : vConfirm.id + titleText : vConfirm.title + messageText : vConfirm.message + confirmText : vConfirm.confirm + cancelText : vConfirm.cancel + confirmVisible : ! vConfirm.isReject + notificationText: vConfirm.adjustment_ReasonText + autoClose : vConfirm.isPowerOff || vConfirm.isReject + + onVisibleChanged: { + _root.isOpen = visible + if (visible) _alarmItem.alarmHide() + else _alarmItem.alarmMaximize() + } + onAccepted: { + if ( vConfirm.isPowerOff ) { + _GuiView.doActionTransmit(GuiActions.ID_PowerOff, GuiActions.Accepted) + } + else { + if ( ! vConfirm.isReject ) vConfirm.doConfirm( true ) + } + } + onRejected: { + if ( vConfirm.isPowerOff ) { + _GuiView.doActionTransmit(GuiActions.ID_PowerOff, GuiActions.Rejected) + } + else { + if ( ! vConfirm.isReject ) vConfirm.doConfirm( false ) + } + } + } + + function open() { + _root.isOpen = true + _powerOffDialog.open() + _confirmDialog.close() // close the user confirmation dialog if the power off is requested + _alarmItem.alarmMinimize() + } + + function close() { + _root.isOpen = false + _powerOffDialog.close() + _alarmItem.alarmMaximize() + } + + function cancel() { + _root.isOpen = false + _powerOffDialog.close() + if ( vConfirm.needConfirm ) vConfirm.doConfirm( false ) + } + + function reject() { // the power off is the only confirm has separate reject dialog, because the button is not only on UI and is HW as well. + _autoHideInfo.showDialog( + qsTr("Cannot shutdown during 'Treatment'"), // '%1').arg() + 2000 // notifies user and hides the dialog + ) + } + + // ---- Connections Connections { target: _GuiView - onDidActionReceive: { + function onDidActionReceive( vAction, vData ) { switch(vAction) { case GuiActions.ID_ShuttingDown: - _autoHideInfo.showDialog( + _autoHideInfo.showDialog ( qsTr("System is shutting down"), 5000 // if any error happens and shutdown is not successful then after 5 seconds dialog hides. ) @@ -51,34 +110,32 @@ } } - PowerOff { id: _powerOffDialog - onAccepted: { - _GuiView.doActionTransmit(GuiActions.ID_PowerOff, GuiActions.Accepted) + Connections { target: vConfirm + function onIsRejectChanged ( vValue ) { + _powerOffDialog.footerUpdate() } - onRejected: { - _GuiView.doActionTransmit(GuiActions.ID_PowerOff, GuiActions.Rejected) + + function onVisibleChanged ( vValue ) { + if ( vValue ) open () + else close () } - } - Connections { target: vPowerOff - onPoweroffTriggered: { - switch (vpoweroff) { - case GuiActions.Command: - _powerOffDialog.open() - break; - - case GuiActions.Timeout: - _powerOffDialog.close() - break; - - case GuiActions.Rejected: - _autoHideInfo.showDialog( - qsTr("Cannot shutdown during 'Treatment'"), // '%1').arg() - 2000 // notifies user and hides the dialog - ) - break; + function onPoweroffTriggered ( vValue ) { + switch ( vValue ) { + case GuiActions.Command : open (); break; + case GuiActions.Timeout : close (); break; + case GuiActions.Rejected: reject(); break; } } + function onAdjustmentTriggered ( vValue ) { + // DEBUG: + // console.debug('\n' + + // 'id : ' + vConfirm.id + '\n' + + // 'command : ' + vConfirm.command + '\n' + + // 'title : ' + vConfirm.title + '\n' + + // 'message : ' + vConfirm.message + '\n' + + // 'adjustment_ReasonText : ' + vConfirm.adjustment_ReasonText + // ) + } } - }