Index: sources/gui/qml/compounds/ValueAdjusterCustom.qml =================================================================== diff -u -re49c956894f999f6539b0c404dd1c9b18a76bb4b -rbea36be2766046e63c4e82539a630b5cee7ce1c6 --- sources/gui/qml/compounds/ValueAdjusterCustom.qml (.../ValueAdjusterCustom.qml) (revision e49c956894f999f6539b0c404dd1c9b18a76bb4b) +++ sources/gui/qml/compounds/ValueAdjusterCustom.qml (.../ValueAdjusterCustom.qml) (revision bea36be2766046e63c4e82539a630b5cee7ce1c6) @@ -24,13 +24,40 @@ property var model : [] property int currentIndex : 0 property int length : model.length === 0 ? 0 : model.length - readonly property bool canIncrement : _root.currentIndex < _root.length - 1 - readonly property bool canDecrement : _root.currentIndex > 0 + readonly property bool canIncrement : isActive ? _root.currentIndex < _root.length - 1 : true + readonly property bool canDecrement : isActive ? _root.currentIndex > 0 : true property bool grabbed : false property bool canOff : false property bool editable : true - property int textWidth : 230 + property bool isActive : true + property bool canRefresh : false + property int defaultValue : 0 + property int value : 0 + signal didChange (real vValue) + signal didActiveChange (bool vState) + + onValueChanged : currentIndex = value + + onIsActiveChanged : { + if ( canRefresh ) { canRefresh = false; return } + + if ( isActive ) { didChange(_root.defaultValue) } + } + + function refresh() { canRefresh = true } + + function clear() { didActiveChange(false) } + + Text { id: _currentItem + anchors.centerIn : parent + text : _root.model[_root.currentIndex] !== undefined ? + _root.isActive ? _root.canOff ? _root.currentIndex === 0 ? qsTr("OFF") : _root.model[_root.currentIndex] : + _root.model[_root.currentIndex] : Variables.emptyEntry : "" + color : Colors.offWhite + font.pixelSize : Fonts.fontPixelValueControl + } + Slider { id: _slider property real pos : 0 @@ -76,6 +103,8 @@ drag.axis : Drag.XAxis // only horizontal onClicked: { + if ( _root.editable ) { didActiveChange(true); focus = true } + _slider.opacity = 0 } @@ -85,6 +114,8 @@ } onPressAndHold: { + if ( _root.editable ) { didActiveChange(true); focus = true } + _root.grabbed = true } @@ -95,8 +126,8 @@ _slider.pos = Math.max(0, Math.min(1, mouse.x / parent.width)) let raw = _slider.from + _slider.pos * (_slider.to - _slider.from) let stepped = Math.round((raw - _slider.from) / _slider.stepSize) * _slider.stepSize + _slider.from - _root.currentIndex = stepped + didChange(stepped) } } @@ -119,39 +150,37 @@ Behavior on opacity { NumberAnimation { duration: 200 } } } - Row { - spacing : Variables.defaultMargin // spacing between items to match others - anchors.centerIn : parent - - IconButton { id: _leftArrow - iconSize : Variables.circleButtonDefaultDiameter - enabled : _root.canDecrement - visible : _root.editable - iconImageSource : enabled ? "qrc:/images/iArrowLeft" : - "qrc:/images/iArrowLeftDisabled" - onClicked : _root.currentIndex -= 1 + IconButton { id: _leftArrow + anchors { + verticalCenter : _root.verticalCenter + left : _root.left + leftMargin : Variables.defaultMargin } - - // Display current item - Text { id: _currentItem - text : _root.model[_root.currentIndex] !== undefined ? - _root.canOff ? _root.currentIndex === 0 ? qsTr("OFF") : _root.model[_root.currentIndex] : - _root.model[_root.currentIndex] : "" - color : Colors.offWhite - font.pixelSize : Fonts.fontPixelValueControl - horizontalAlignment : Text.AlignHCenter - verticalAlignment : Text.AlignVCenter - height : parent.height - width : _root.editable ? _root.textWidth : parent.width + iconSize : Variables.circleButtonDefaultDiameter + enabled : _root.canDecrement + visible : _root.editable + iconImageSource : enabled ? "qrc:/images/iArrowLeft" : + "qrc:/images/iArrowLeftDisabled" + onClicked : { + if ( ! isActive ) { didActiveChange(true); return } + didChange(_root.currentIndex -= 1) } + } - IconButton { id: _rightArrow - iconSize : Variables.circleButtonDefaultDiameter - enabled : _root.canIncrement - visible : _root.editable - iconImageSource : enabled ? "qrc:/images/iArrowRight" : - "qrc:/images/iArrowRightDisabled" - onClicked : _root.currentIndex += 1 + IconButton { id: _rightArrow + anchors { + verticalCenter : _root.verticalCenter + right : _root.right + rightMargin : Variables.defaultMargin } + iconSize : Variables.circleButtonDefaultDiameter + enabled : _root.canIncrement + visible : _root.editable + iconImageSource : enabled ? "qrc:/images/iArrowRight" : + "qrc:/images/iArrowRightDisabled" + onClicked : { + if ( ! isActive ) { didActiveChange(true); return } + didChange(_root.currentIndex += 1) + } } }