aboutsummaryrefslogtreecommitdiffstats
path: root/share
diff options
context:
space:
mode:
authorThomas Hartmann <thomas.hartmann@qt.io>2019-06-06 16:00:35 +0200
committerThomas Hartmann <thomas.hartmann@qt.io>2019-06-06 15:27:00 +0000
commit9f0a0cd8c6debb707b44e84dc66a542f9d779854 (patch)
tree21268897eb273257d81bd1cd9ff22ff1bab109a5 /share
parent6b82dd201feeab41add8b4cd99c399beeb7e8278 (diff)
QmlDesigner: Add wrapper pattern to DoubleSpinBox
This is unfortunately required for step size. We need real in the API while QQC2 has int. Change-Id: I162c13a3edc24c34271a1dbf8e19f55b9fe2d034 Reviewed-by: Henning Gründl <henning.gruendl@qt.io> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Diffstat (limited to 'share')
-rw-r--r--share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/DoubleSpinBox.qml76
1 files changed, 55 insertions, 21 deletions
diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/DoubleSpinBox.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/DoubleSpinBox.qml
index b8b536799d..f64b4fc6fd 100644
--- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/DoubleSpinBox.qml
+++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/DoubleSpinBox.qml
@@ -27,35 +27,69 @@ import QtQuick 2.1
import QtQuickDesignerTheme 1.0
import StudioControls 1.0 as StudioControls
-StudioControls.SpinBox {
- id: spinBox
- width: 76
- decimals: 2
+Item {
+ id: wrapper
+
+ property alias decimals: spinBox.decimals
+ property alias hasSlider: spinBox.hasSlider
property real minimumValue: 0.0
property real maximumValue: 1.0
- stepSize: 0.1
+ property real stepSize: 0.1
- actionIndicatorVisible: false
+ property alias sliderIndicatorVisible: spinBox.sliderIndicatorVisible
- property bool __initialized: false
+ property real value
- Component.onCompleted: {
- spinBox.__initialized = true
+ onValueChanged: spinBox.value = wrapper.value * spinBox.factor
- convert("stepSize", stepSize)
- convert("from", minimumValue)
- convert("to", maximumValue)
- }
+ signal compressedValueModified
+ signal valueModified
- onStepSizeChanged: convert("stepSize", stepSize)
- onMinimumValueChanged: convert("from", minimumValue)
- onMaximumValueChanged: convert("to", maximumValue)
+ width: 90
+ implicitHeight: spinBox.height
- function convert(target, value) {
- if (!spinBox.__initialized)
- return
- spinBox[target] = Math.round(value * spinBox.factor)
- }
+ onStepSizeChanged: spinBox.convert("stepSize", wrapper.stepSize)
+ onMinimumValueChanged: spinBox.convert("from", wrapper.minimumValue)
+ onMaximumValueChanged: spinBox.convert("to", wrapper.maximumValue)
+
+ StudioControls.SpinBox {
+ id: spinBox
+
+ onValueModified: wrapper.valueModified()
+ onCompressedValueModified: wrapper.compressedValueModified()
+
+ onValueChanged: {
+ if (spinBox.__initialized)
+ wrapper.value = spinBox.value / spinBox.factor
+ }
+
+ width: wrapper.width
+ decimals: 2
+
+ actionIndicatorVisible: false
+ property bool __initialized: false
+
+ property bool hasSlider: spinBox.sliderIndicatorVisible
+
+ Component.onCompleted: {
+ spinBox.__initialized = true
+
+ spinBox.convert("stepSize", wrapper.stepSize)
+ spinBox.convert("from", wrapper.minimumValue)
+ spinBox.convert("to", wrapper.maximumValue)
+
+ spinBox.value = wrapper.value * spinBox.factor
+
+ print("complete " + spinBox.value)
+ }
+
+ function convert(target, value) {
+ if (!spinBox.__initialized)
+ return
+ spinBox[target] = Math.round(value * spinBox.factor)
+ }
+
+ }
}