Index: sources/gui/qml/components/SliderCreateTreatment.qml =================================================================== diff -u -r18c39727da06312b90d15751e6a27e03c7b6742a -r83b9d737cd495b34a7b42f5409962a9442f3b8f4 --- sources/gui/qml/components/SliderCreateTreatment.qml (.../SliderCreateTreatment.qml) (revision 18c39727da06312b90d15751e6a27e03c7b6742a) +++ sources/gui/qml/components/SliderCreateTreatment.qml (.../SliderCreateTreatment.qml) (revision 83b9d737cd495b34a7b42f5409962a9442f3b8f4) @@ -1,13 +1,13 @@ /*! * - * Copyright (c) 2020-2023 Diality Inc. - All Rights Reserved. + * Copyright (c) 2020-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 SliderCreateTreatment.qml * \author (last) Behrouz NematiPour - * \date (last) 14-Mar-2023 + * \date (last) 26-Jan-2024 * \author (original) Peter Lucia * \date (original) 07-Jul-2020 * @@ -27,12 +27,15 @@ Rectangle { id: _root property Flickable flickable: null + property var toggleSwich : null // it is the treatment slider custom Switch bu it will be defined outside of this component and the var type would suffice. + property bool adjustable : true property alias label : _label.text property alias decimal : _slider.decimal property alias minimum : _slider.minimum property alias maximum : _slider.maximum property alias value : _slider.value + property alias defaultValue : _slider.defaultValue property alias step : _slider.step property alias inActiveZero: _slider.inActiveZero @@ -53,19 +56,26 @@ anchors.horizontalCenter: parent.horizontalCenter - function setColor() { - let color = Colors.textDisableButton - if ( _root.active ) { - if ( _root.valid ) { - color = Colors.textMain - } - else { - color = Colors.createTreatmentInvalidParam - } + function clear() { + reset(defaultValue) + if ( toggleSwich ) { + toggleSwich.checked = false + toggleSwich.active = false } - return color + _root.active = false } + function reset(vValue) { + _slider.reset(vValue) + } + + function setColor() { + let color = Colors.textMain + if ( ! _root.valid ) { color = Colors.createTreatmentInvalidParam ; return color } + if ( ! _root.active ) { color = Colors.textDisableButton ; return color } + return color + } + function setValue() { // The slider is not adjustable, implying it won't have a value change if ( !adjustable && zeroLabel !== "") { @@ -91,7 +101,7 @@ } function setActiveValid() { - _root.active = _root.valid = true + _root.active = true } Text { id: _label @@ -136,18 +146,31 @@ anchors.left : _slider.right anchors.leftMargin : Variables.sliderAdjustButtonLeftMargin + // NOTE: @inActiveZero + // the slider which use inActiveZero are the once, with OFF button. + // these sliders have 0 as defalut to indicate OFF. + // when activated the first value they get is still the 0 ( OFF ). + // in that case we decrement once to get the correct minimum value. + // as example heparin dispensing after gets ON, firsrt decrement shows OFF ( 0 ). + // NOTE: if 0=defaultValue is in range (minimum < defaultValue < maximum), we still have problem, and needs more investigation onIncrementValue : { if ( _slider.isActive) { _slider.incrementValue(true) } else { setActiveValid() + if ( inActiveZero ) { // NOTE: @inActiveZero + _slider.decrementValue() + } } } onDecrementValue : { if ( _slider.isActive) { _slider.decrementValue(true) } else { setActiveValid() + if ( inActiveZero ) { // NOTE: @inActiveZero + _slider.decrementValue() + } } } }