Index: sources/gui/qml/compounds/ValueAdjuster.qml =================================================================== diff -u -rb16fd955f65d83321decdc54bd3d5695fc81c32c -ra42e662e05949b63abd4c1e51b814ce476c107d4 --- sources/gui/qml/compounds/ValueAdjuster.qml (.../ValueAdjuster.qml) (revision b16fd955f65d83321decdc54bd3d5695fc81c32c) +++ sources/gui/qml/compounds/ValueAdjuster.qml (.../ValueAdjuster.qml) (revision a42e662e05949b63abd4c1e51b814ce476c107d4) @@ -80,7 +80,7 @@ let fixedStep = _private.fixedValue(_private.stepVal) let fixedDelta = fixedStep - (fixedVal % fixedStep) tValue = (fixedVal + fixedDelta) / _private.multiplier - tValue = Math.min(_private.maxVal, tValue) + tValue = Math.max(_private.minVal, Math.min(_private.maxVal, tValue)) } didChange(tValue) @@ -98,7 +98,7 @@ let fixedStep = _private.fixedValue(_private.stepVal) let fixedDelta = fixedVal % fixedStep tValue = (fixedVal - (fixedDelta > 0 ? fixedDelta : fixedStep)) / _private.multiplier - tValue = Math.max(_private.minVal, tValue) + tValue = Math.min(_private.maxVal, Math.max(_private.minVal, tValue)) } didChange(tValue) Index: sources/gui/qml/pages/treatment/TreatmentHome.qml =================================================================== diff -u -r0fc6d1c6c65ba935d7e5f0bc56130e99deada039 -ra42e662e05949b63abd4c1e51b814ce476c107d4 --- sources/gui/qml/pages/treatment/TreatmentHome.qml (.../TreatmentHome.qml) (revision 0fc6d1c6c65ba935d7e5f0bc56130e99deada039) +++ sources/gui/qml/pages/treatment/TreatmentHome.qml (.../TreatmentHome.qml) (revision a42e662e05949b63abd4c1e51b814ce476c107d4) @@ -126,6 +126,76 @@ } } + NotificationBarSmall { id: _notification + objectName : "_notification" + anchors.bottom : parent.bottom + height : 60 + visible : ! _alarmBar.visible && text + + property int source: -1 + + onTextChanged: { + if (text === "") { + source = -1 + } + } + + CloseButton { id: _dismissButton + objectName: "_dismissButton" + anchors { + top: parent.top + bottom: parent.bottom + right: parent.right + margins: 20 + } + width: height + visible: true + onClicked: { _notification.text = "" } + } + } + + Connections { target: vTreatmentAdjustmentBloodFlowRate + function onAdjustmentTriggered ( vValue ) { + if (vTreatmentAdjustmentBloodFlowRate.adjustment_Accepted) { + if (_notification.source === 0) { + _notification.text = "" + } + } + else { + _notification.text = vTreatmentAdjustmentBloodFlowRate.adjustment_ReasonText + _notification.source = 0 + } + } + } + + Connections { target: vTreatmentAdjustmentDialysateFlowRate + function onAdjustmentTriggered ( vValue ) { + if (vTreatmentAdjustmentDialysateFlowRate.adjustment_Accepted) { + if (_notification.source === 1) { + _notification.text = "" + } + } + else { + _notification.text = vTreatmentAdjustmentDialysateFlowRate.adjustment_ReasonText + _notification.source = 1 + } + } + } + + Connections { target: vTreatmentAdjustmentDialysateTemperature + function onAdjustmentTriggered ( vValue ) { + if (vTreatmentAdjustmentDialysateTemperature.adjustment_Accepted) { + if (_notification.source === 2) { + _notification.text = "" + } + } + else { + _notification.text = vTreatmentAdjustmentDialysateTemperature.adjustment_ReasonText + _notification.source = 2 + } + } + } + onVisibleChanged: { if (visible) { _mainMenu.hidden = true Index: sources/gui/qml/pages/treatment/sections/TreatmentFlows.qml =================================================================== diff -u -r493c6653bc98492d200bfd82abd6abf9af8d29ca -ra42e662e05949b63abd4c1e51b814ce476c107d4 --- sources/gui/qml/pages/treatment/sections/TreatmentFlows.qml (.../TreatmentFlows.qml) (revision 493c6653bc98492d200bfd82abd6abf9af8d29ca) +++ sources/gui/qml/pages/treatment/sections/TreatmentFlows.qml (.../TreatmentFlows.qml) (revision a42e662e05949b63abd4c1e51b814ce476c107d4) @@ -46,41 +46,53 @@ title : qsTr("Blood Flow") height : _row.cellHeight width : _row.cellWidth - value : Variables.notSetVariable(vTreatmentParametersSetPoint.bloodFlow.toFixed(Variables.bloodFlowPrecision)) + value : vTreatmentParametersSetPoint.bloodFlow + precision : Variables.bloodFlowPrecision + minimum : vTreatmentRanges.bloodFlowRateMin + maximum : vTreatmentRanges.bloodFlowRateMax + step : vTreatmentRanges.bloodFlowRateRes unitText : Variables.unitTextFlowRate buttonsEnabled : editEnabled - onIncrement : print(" increment blood flow") - onDecrement : print(" decrement blood flow") + onIncrement : function(newValue) { vTreatmentAdjustmentBloodFlowRate.doAdjustment(newValue) } + onDecrement : function(newValue) { vTreatmentAdjustmentBloodFlowRate.doAdjustment(newValue) } } TreatmentFlowsComponent { id: _dialysateFlow objectName : "dialysateFlowComponent" title : qsTr("Dialysate Flow") height : _row.cellHeight width : _row.cellWidth - value : vTreatmentParametersSetPoint.dialysateFlow.toFixed(Variables.dialysateFlowPrecision) // Need to show 0 value + value : vTreatmentParametersSetPoint.dialysateFlow + precision : Variables.dialysateFlowPrecision + minimum : vTreatmentRanges.dialysateFlowRateMin + maximum : vTreatmentRanges.dialysateFlowRateMax + step : vTreatmentRanges.dialysateFlowRateRes unitText : Variables.unitTextFlowRate buttonsEnabled : editEnabled extraText : vTreatmentParametersSetPoint.dialysateFlow === 0 ? qsTr("OFF") : ! vDDGenDialysate.isDialGood ? qsTr("Bypass") : "" - onIncrement : print(" increment dial flow") - onDecrement : print(" decrement dial flow") + onIncrement : function(newValue) { vTreatmentAdjustmentDialysateFlowRate.doAdjustment(newValue) } + onDecrement : function(newValue) { vTreatmentAdjustmentDialysateFlowRate.doAdjustment(newValue) } } TreatmentFlowsComponent { id: _dialysateTemp objectName : "dialysateTempComponent" title : qsTr("Dialysate Temp.") height : _row.cellHeight width : _row.cellWidth - value : Variables.notSetVariable(vTreatmentParametersSetPoint.dialysateTemp.toFixed(Variables.dialysateTempPrecision)) + value : vTreatmentParametersSetPoint.dialysateTemp + precision : Variables.dialysateTempPrecision + minimum : vTreatmentRanges.dialysateTempMin + maximum : vTreatmentRanges.dialysateTempMax + step : vTreatmentRanges.dialysateTempRes unitText : Variables.unitTextTemperature buttonsEnabled : editEnabled - onIncrement : print(" increment dial temp") - onDecrement : print(" decrement dial temp") + onIncrement : function(newValue) { vTreatmentAdjustmentDialysateTemperature.doAdjustment(newValue) } + onDecrement : function(newValue) { vTreatmentAdjustmentDialysateTemperature.doAdjustment(newValue) } } TreatmentFlowsComponent { id: _dialysateCond @@ -92,9 +104,6 @@ unitText : Variables.unitTextDialCond showButtons : false dropShadowEnabled : false - - onIncrement : print(" increment dial cond") - onDecrement : print(" decrement dial cond") } } } Index: sources/gui/qml/pages/treatment/sections/TreatmentFlowsComponent.qml =================================================================== diff -u -re36852d9548379bd861d4b0838761d2aa5243dad -ra42e662e05949b63abd4c1e51b814ce476c107d4 --- sources/gui/qml/pages/treatment/sections/TreatmentFlowsComponent.qml (.../TreatmentFlowsComponent.qml) (revision e36852d9548379bd861d4b0838761d2aa5243dad) +++ sources/gui/qml/pages/treatment/sections/TreatmentFlowsComponent.qml (.../TreatmentFlowsComponent.qml) (revision a42e662e05949b63abd4c1e51b814ce476c107d4) @@ -11,29 +11,87 @@ import "qrc:/pages/treatment" Rectangle { id: _root + objectName: "_TreatmentFlowsComponent" - property string title : "" - property string value : "" - property string unitText : "" - property string extraText : "" - property alias value : _value.topText + property string title : "" + property string unitText : "" + property string extraText : "" + property real value : undefined + property real precision : 0 + property real minimum : value + property real maximum : value + property real step : 1 + property bool showButtons : true + property bool buttonsEnabled : true + property bool dropShadowEnabled : true - property bool showButtons : true - property bool buttonsEnabled : true - property bool dropShadowEnabled : true - color : Colors.mainTreatmentLighterBlue radius : 5 - signal increment() - signal decrement() + signal increment(real newValue) + signal decrement(real newValue) + QtObject { id: _private + // fix floating-point precision issue + readonly property int multiplier : Math.pow(10, precision) + readonly property real stepVal : calculatePrecisionValue(step) + readonly property real minVal : minimum !== undefined ? calculatePrecisionValue(minimum) : 0 + readonly property real maxVal : maximum !== undefined ? calculatePrecisionValue(maximum) : 0 + readonly property real val : value !== undefined ? calculatePrecisionValue(value) : 0 + + readonly property bool canDecrement : val > calculateMinimum() + readonly property bool canIncrement : val < calculateMaximum() + + // round the value based on the given precision (not step) + function calculatePrecisionValue(value) { + return Math.round(value * _private.multiplier) / _private.multiplier + } + + // calculate the minimum value rounded up to the next higher step size + function calculateMinimum() { + let fixedMin = _private.fixedValue(_private.minVal) + let fixedStep = _private.fixedValue(_private.stepVal) + return (Math.ceil(fixedMin / fixedStep) * fixedStep) / _private.multiplier + } + + // calculate the maximum value rounded down to the next higher step size + function calculateMaximum() { + let fixedMax = _private.fixedValue(_private.maxVal) + let fixedStep = _private.fixedValue(_private.stepVal) + return (Math.floor(fixedMax / fixedStep) * fixedStep) / _private.multiplier + } + + // return a fixed point int from the inputted float (using the set precision) + function fixedValue(value) { + return Math.round(value * _private.multiplier) + } + + function incrementedValue() { + let fixedVal = _private.fixedValue(_private.val) + let fixedStep = _private.fixedValue(_private.stepVal) + let fixedDelta = fixedStep - (fixedVal % fixedStep) + return Math.max( + _private.minVal, + Math.min(_private.maxVal, (fixedVal + fixedDelta) / _private.multiplier) + ) + } + + function decrementedValue() { + let fixedVal = _private.fixedValue(_private.val) + let fixedStep = _private.fixedValue(_private.stepVal) + let fixedDelta = fixedVal % fixedStep + return Math.min( + _private.maxVal, + Math.max(_private.minVal, (fixedVal - (fixedDelta > 0 ? fixedDelta : fixedStep)) / _private.multiplier) + ) + } + } + Text { id: _title objectName: "title" anchors { horizontalCenter : _root.horizontalCenter - horizontalCenterOffset : Variables.defaultMargin * 1.5 top : parent.top topMargin : Variables.defaultMargin } @@ -47,7 +105,7 @@ height : Variables.contentHeight text : _root.title color : Colors.pressuresText - horizontalAlignment : Text.AlignLeft + horizontalAlignment : Text.AlignHCenter } Row { id: _row @@ -67,7 +125,7 @@ } height : Variables.contentHeight width : Variables.treatmentFlowsComponentWidth - topText : value + topText : value !== undefined ? _root.value.toFixed(_root.precision) : "--" topTextFont.pixelSize : 60 topTextFont.weight : Font.Medium bottomText : _root.unitText @@ -105,17 +163,17 @@ ArrowButton {id : _upArrowIcon objectName : "upArrowIcon" upArrow : true - enabled : buttonsEnabled + enabled : buttonsEnabled && _private.canIncrement - onClicked : _root.increment() + onClicked : { _root.increment(_private.incrementedValue()) } } ArrowButton {id : _downArrowIcon objectName : "downArrowIcon" downArrow : true - enabled : buttonsEnabled + enabled : buttonsEnabled && _private.canDecrement - onClicked : _root.decrement() + onClicked : { _root.decrement(_private.decrementedValue()) } } } }