Index: sources/gui/qml/compounds/NumPad.qml =================================================================== diff -u -r3e682c5afdadcf4dd2006e3d975fbee58e48619e -rbecdb453874007323459a9afe9fe581b6c158902 --- sources/gui/qml/compounds/NumPad.qml (.../NumPad.qml) (revision 3e682c5afdadcf4dd2006e3d975fbee58e48619e) +++ sources/gui/qml/compounds/NumPad.qml (.../NumPad.qml) (revision becdb453874007323459a9afe9fe581b6c158902) @@ -13,7 +13,7 @@ * */ -import QtQuick 2.12 +import QtQuick 2.15 import QtQuick.Controls 2.12 import "qrc:/components" @@ -23,17 +23,20 @@ property var settingValue : undefined property alias unit : _unitText.text property alias range : _range.text + property alias showRange : _range.visible property alias title : _title.text property alias displayValue : _valueLabel.text property int precision : 0 property var getter : null property var setter : null - property var validator : null - readonly property bool isValueValid : validator ? validator(valueInt) : true - readonly property var valueInt : isNaN(parseInt(_valueLabel.text)) ? undefined : parseInt(_valueLabel.text) + property real validatorMin : 0 + property real validatorMax : 99999 readonly property string backSpace : "qrc:/images/iBackspace" property bool isOpened : false + property bool allowDecimal : false + property bool showSliderButton : true + property int numCharacters : 3 width : Variables.numPadWidth height : Variables.numPadHeight @@ -66,7 +69,8 @@ .arg(max) _root.getter = entry.text _root.setter = function (value) { entry.text = value } - _root.validator = function (value) { return value >= min && value <= max } + _root.validatorMin = min + _root.validatorMax = max } function show() { @@ -102,6 +106,7 @@ radius : height border.color : Colors.transparent backgroundColor : Colors.backgroundButtonSelect + visible : _root.showSliderButton onPressed : isOpened ? hide() : show() Image { id : _iconImage @@ -155,14 +160,19 @@ radius : 10 color : "#324867" - Text { id: _valueLabel + TextInput { id: _valueLabel anchors.centerIn: parent font { pixelSize : 65 weight : Font.DemiBold } - color : isValueValid ? Colors.offWhite : Colors.red - text : "" + color : _valueLabel.acceptableInput ? Colors.offWhite : Colors.red + + validator: DoubleValidator { id: _validator + bottom : _root.validatorMin + top : _root.validatorMax + decimals: _root.allowDecimal ? 3 : 0 + } } } @@ -217,7 +227,7 @@ icon.source : modelData === backSpace ? modelData : "" icon.height : 45 icon.width : 45 - enabled : modelData === "." ? precision > 0 : true + enabled : _root.allowDecimal ? true : modelData === "." ? precision > 0 : true contentItem: Rectangle { anchors.fill : parent @@ -238,7 +248,7 @@ color : enabled ? Colors.offWhite : "dimgrey" } } - + onPressed: { if (modelData === backSpace ) { _numPadGrid.replaceValueText = false @@ -249,7 +259,7 @@ _valueLabel.text = _keyButton.text _numPadGrid.replaceValueText = false } - else if (_valueLabel.text.length < 3) { + else if (_valueLabel.text.length < _root.numCharacters) { _valueLabel.text += _keyButton.text } }