Index: sources/gui/qml/pages/treatment/adjustments/TreatmentAdjustmentDuration.qml =================================================================== diff -u -ra5760947d3ed0d2748ba023a1c25e3c6aa0b1de1 -r601289deb20f7059b3af5bb19e16f53974262ceb --- sources/gui/qml/pages/treatment/adjustments/TreatmentAdjustmentDuration.qml (.../TreatmentAdjustmentDuration.qml) (revision a5760947d3ed0d2748ba023a1c25e3c6aa0b1de1) +++ sources/gui/qml/pages/treatment/adjustments/TreatmentAdjustmentDuration.qml (.../TreatmentAdjustmentDuration.qml) (revision 601289deb20f7059b3af5bb19e16f53974262ceb) @@ -15,6 +15,7 @@ // Qt import QtQuick 2.12 +import QtQuick.Controls 2.12 // StackView // Project @@ -27,78 +28,95 @@ * To adjust the treatment duration */ TreatmentAdjustmentBase { id: _root - contentItem.objectName: "TreatmentAdjustmentDuration" //SquishQt testability + objectName : "_TreatmentAdjustmentDuration" // SquishQt testability - readonly property real durationValue : _durationSlider.value - readonly property alias durationMinimum : _durationSlider.minimum - readonly property alias durationMaximum : _durationSlider.maximum - readonly property alias durationStep : _durationSlider.step + closeVisible : true + confirmVisible : false + backVisible : _treatmentDurationStack.stackView.depth > 1 - readonly property alias currentTime : _currentTimeText.seconds - readonly property alias durationTime : _durationText.seconds + onAboutToShow : { + _treatmentAdjustmentDurationEdit.reset() + _treatmentDurationStack.reset() + } + onClosed : { _treatmentDurationStack.reset() } + onBackClicked : { _treatmentDurationStack.pop() } - property int textWidth : 200 + StackItem { id: _treatmentDurationStack + objectName : "_treatmentDurationStack" + anchors { + top : parent.top + bottom : notification.top + left : parent.left + right : parent.right + } + visible : true + stackView { + initialItem : _treatmentAdjustmentDurationEdit + popEnter : null + popExit : null + pushEnter : null + pushExit : null + } - // Due to how the slider is set up, a setter function is needed to set the slider value - function setDurationValue(value) { - _durationSlider.reset(value) - } + TreatmentAdjustmentDurationEdit { id: _treatmentAdjustmentDurationEdit + objectName : "_treatmentAdjustmentDurationEdit" + visible : false - titleText: qsTr("TREATMENT DURATION") + StackView.onActivating : { + _root.titleText = qsTr("Edit Treatment Duration") + _root.notificationText = "" + } - Item { id : _container - readonly property int sideMarginSize: Variables.headerButtonsMargin + Variables.confirmButtonWidth/2 - _durationSliderArrows.width/2 // Centers on the confirmButton - width : _root.width - height : 200 - anchors.centerIn: parent + onContinueClicked : function(vNewTreatmentDuration) { + // send new duration to TD and wait + // if accepted moves to confirm screen, otherwise show error in notification + vTreatmentAdjustmentDurationEdit.doAdjustment(vNewTreatmentDuration) + } + } - TimeText { id: _currentTimeText - seconds: vTreatmentTime.time_Elapsed - secondsVisible: true - textPixelSize: Fonts.fontPixelDurationCurTime - anchors.horizontalCenter: parent.horizontalCenter - anchors.top: _container.top - anchors.bottom: _durationSlider.top - anchors.bottomMargin: 65 + TreatmentAdjustmentDurationConfirm { id: _treatmentAdjustmentDurationConfirm + objectName : "_treatmentAdjustmentDurationConfirm" + visible : false + + StackView.onActivating : { + _root.titleText = qsTr("Confirm Treatment Duration") + _root.notificationText = "" + } + + onConfirmClicked : function(vNewTreatmentDuration) { + // send new duration to TD and wait + // if accepted moves to confirm screen, otherwise show error in notification + vTreatmentAdjustmentDurationConfirm.doConfirm(vNewTreatmentDuration) + } } - Slider { id : _durationSlider - // The distance from parent's right side to the rightmost of slider - with slider arrows and spacings considered - readonly property int sliderAndArrowSpacing : Variables.sliderAdjustButtonSpacing + _durationSlider.handler.width/2 - readonly property int distanceFromSide : _durationSlider.sliderAndArrowSpacing + _durationSliderArrows.width + _container.sideMarginSize - width : _container.width - (distanceFromSide * 2) // determine the size of slider to center - minimum : vTreatmentRanges.treatmentRanges_Duration_Min // in Minutes - maximum : vTreatmentRanges.treatmentRanges_Duration_Max // in Minutes - step : Variables.durationResolution - stepSnap : true - minText.visible : false - maxText.visible : false - ticks : true - anchors.right : _durationSliderArrows.left - anchors.rightMargin : _durationSlider.sliderAndArrowSpacing - anchors.bottom : _container.bottom + Connections { target: vTreatmentAdjustmentDurationEdit + function onAdjustmentTriggered ( vValue ) { + if (vTreatmentAdjustmentDurationEdit.adjustment_Accepted) { + notification.text = "" - TimeText { id: _durationText - seconds: 60 * _durationSlider.value // in Minutes => to Seconds - secondsVisible: false - textPixelSize: Fonts.fontPixelDurationAdjTime - textWeight: Font.Medium - anchors { - top : _durationSlider.handler.bottom - topMargin : 10 - horizontalCenter: _durationSlider.handler.horizontalCenter + _treatmentAdjustmentDurationConfirm.newTreatmentDuration = vTreatmentAdjustmentDurationEdit.duration + _treatmentAdjustmentDurationConfirm.ufVolumeGoal = vTreatmentAdjustmentDurationEdit.ufVolumeGoal + _treatmentAdjustmentDurationConfirm.ufRate = vTreatmentAdjustmentDurationEdit.ufRate + + _treatmentDurationStack.page(_treatmentAdjustmentDurationConfirm) } + else { + notification.text = vTreatmentAdjustmentDurationEdit.adjustment_ReasonText + } } } - SliderArrows{ id: _durationSliderArrows - visible : true - anchors.verticalCenter : _durationSlider.verticalCenter - anchors.right : _container.right - anchors.rightMargin : _container.sideMarginSize - onIncrementValue : _durationSlider.incrementValue(true) - onDecrementValue : _durationSlider.decrementValue(true) + Connections { target: vTreatmentAdjustmentDurationConfirm + function onAdjustmentTriggered ( vValue ) { + if (vTreatmentAdjustmentDurationConfirm.adjustment_Accepted) { + notification.text = "" + close() + } + else { + notification.text = vTreatmentAdjustmentDurationConfirm.adjustment_ReasonText + } + } } } - }