Index: sources/gui/qml/compounds/NumPad.qml =================================================================== diff -u -rfd09b0ee6e41d75755e0572008d4f932b0bddf2b -r969fb65fb9857c0a6a84cb9f7d591d16de40e898 --- sources/gui/qml/compounds/NumPad.qml (.../NumPad.qml) (revision fd09b0ee6e41d75755e0572008d4f932b0bddf2b) +++ sources/gui/qml/compounds/NumPad.qml (.../NumPad.qml) (revision 969fb65fb9857c0a6a84cb9f7d591d16de40e898) @@ -13,7 +13,7 @@ * */ -import QtQuick 2.12 +import QtQuick 2.15 import QtQuick.Controls 2.12 import QtGraphicalEffects 1.12 @@ -24,17 +24,21 @@ 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 + property bool isFloat : false width : Variables.numPadWidth height : Variables.numPadHeight @@ -67,9 +71,24 @@ .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 openNoRange(entry, title) { +// reset() +// setupOpenInput(entry, title) +// _keyboard.setVisible(false) +// show() +// } + +// function setupOpenInput(entry, title) { +//// _root.settingValue = Qt.binding(function () { return entry.text }) +// _root.title = title +// _root.getter = entry.text +// _root.setter = function (value) { entry.text = value } +// } + function show() { if ( ! isOpened ) { x = x + _root.width @@ -103,6 +122,7 @@ radius : height border.color : Colors.transparent backgroundColor : Colors.backgroundButtonSelect + visible : _root.showSliderButton onPressed : isOpened ? hide() : show() Image { id : _iconImage @@ -156,14 +176,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.isFloat ? 3 : 0 + } } } @@ -218,7 +243,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 @@ -250,7 +275,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 } }