Index: sources/gui/qml/PowerItem.qml =================================================================== diff -u -r27cc308ff5113a9386899d3c8f8b29962a8498e1 -rb5afbc61af03dd2e84acf8439cb6be1f022a2921 --- sources/gui/qml/PowerItem.qml (.../PowerItem.qml) (revision 27cc308ff5113a9386899d3c8f8b29962a8498e1) +++ sources/gui/qml/PowerItem.qml (.../PowerItem.qml) (revision b5afbc61af03dd2e84acf8439cb6be1f022a2921) @@ -20,8 +20,10 @@ // C++ imports import Gui.View 0.1 import Gui.Actions 0.1 -import VPowerOff 0.1 +// Confirm +import VConfirm 0.1 + // Qml imports import "qrc:/globals" import "qrc:/components" @@ -34,15 +36,63 @@ Item { id: _root anchors.fill: parent - VPowerOff { id: vPowerOff } - + VConfirm { id: vConfirm } AutoHideInfo { id: _autoHideInfo } + PowerOff { id: _powerOffDialog + visible : vConfirm.visible + titleText : vConfirm.title + messageText : vConfirm.message + confirmText : vConfirm.confirm + confirmVisible : ! vConfirm.isReject + cancelText : vConfirm.cancel + notificationText: vConfirm.adjustment_ReasonText + + onVisibleChanged: { + 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() { + _powerOffDialog.open() + _alarmItem.alarmMinimize() + } + + function close() { + _powerOffDialog.close() + _alarmItem.alarmMaximize() + } + + 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: { 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,40 +101,32 @@ } } - PowerOff { id: _powerOffDialog + Connections { target: vConfirm + onIsRejectChanged: { + _powerOffDialog.footerUpdate() + } + onVisibleChanged: { - if (visible) _alarmItem.alarmHide() - else _alarmItem.alarmMaximize() + if ( vvisible ) open () + else close () } - onAccepted: { - _GuiView.doActionTransmit(GuiActions.ID_PowerOff, GuiActions.Accepted) - } - onRejected: { - _GuiView.doActionTransmit(GuiActions.ID_PowerOff, GuiActions.Rejected) - } - } - Connections { target: vPowerOff onPoweroffTriggered: { switch (vpoweroff) { - case GuiActions.Command: - _powerOffDialog.open() - _alarmItem.alarmHide() - break; - - case GuiActions.Timeout: - _powerOffDialog.close() - _alarmItem.alarmMaximize() - break; - - case GuiActions.Rejected: - _autoHideInfo.showDialog( - qsTr("Cannot shutdown during 'Treatment'"), // '%1').arg() - 2000 // notifies user and hides the dialog - ) - break; + case GuiActions.Command : open (); break; + case GuiActions.Timeout : close (); break; + case GuiActions.Rejected: reject(); break; } } + onAdjustmentTriggered: { + // 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 + // ) + } } - }