From 7baecce079000ef85e251892fc3de1510a023592 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann <Thomas.Hartmann@nokia.com> Date: Wed, 13 Jan 2010 13:54:02 +0100 Subject: [PATCH] Qml Designer.PropertyEditor: fixing crash bug See: BAUHAUS-288 Fixes some indentation --- .../propertyeditor/Qt/DoubleSpinBox.qml | 51 +++++++++++-------- .../qmldesigner/propertyeditor/Qt/SpinBox.qml | 22 +++++--- 2 files changed, 44 insertions(+), 29 deletions(-) diff --git a/share/qtcreator/qmldesigner/propertyeditor/Qt/DoubleSpinBox.qml b/share/qtcreator/qmldesigner/propertyeditor/Qt/DoubleSpinBox.qml index 9827d7e58a1..4d78e86ddda 100644 --- a/share/qtcreator/qmldesigner/propertyeditor/Qt/DoubleSpinBox.qml +++ b/share/qtcreator/qmldesigner/propertyeditor/Qt/DoubleSpinBox.qml @@ -26,15 +26,15 @@ QWidget { //This is a special DoubleSpinBox that does color coding for states function evaluate() { if (baseStateFlag) { if (backendValue != null && backendValue.isInModel) - DoubleSpinBox.setStyleSheet("color: white;"); + DoubleSpinBox.setStyleSheet("color: white;"); else - DoubleSpinBox.setStyleSheet("color: gray;"); - } else { - if (backendValue != null && backendValue.isInSubState) + DoubleSpinBox.setStyleSheet("color: gray;"); + } else { + if (backendValue != null && backendValue.isInSubState) DoubleSpinBox.setStyleSheet("color: #7799FF;"); - else + else DoubleSpinBox.setStyleSheet("color: gray;"); - } + } } } @@ -50,19 +50,26 @@ QWidget { //This is a special DoubleSpinBox that does color coding for states decimals: 2; keyboardTracking: false; enabled: (backendValue == null || backendValue.complexNode == null) ? false : !backendValue.isBound && !backendValue.complexNode.exists - value: DoubleSpinBox.backendValue == null ? .0 : DoubleSpinBox.backendValue.value; - onValueChanged: { - if (DoubleSpinBox.backendValue != null) + property bool readingFromBackend: false; + property real valueFromBackend: DoubleSpinBox.backendValue == null ? .0 : DoubleSpinBox.backendValue.value; + onValueFromBackendChanged: { + readingFromBackend = true; + value = valueFromBackend + readingFromBackend = false; + } + + onValueChanged: { + if (DoubleSpinBox.backendValue != null && readingFromBackend == false) DoubleSpinBox.backendValue.value = value; - } - onFocusChanged: { - //extendedSwitches.active = focus; - //extendedSwitches.backendValue = backendValue; - } - - onMouseOverChanged: { - //extendedButton.active = mouseOver; - } + } + onFocusChanged: { + //extendedSwitches.active = focus; + //extendedSwitches.backendValue = backendValue; + } + + onMouseOverChanged: { + //extendedButton.active = mouseOver; + } } } @@ -80,10 +87,10 @@ QWidget { //This is a special DoubleSpinBox that does color coding for states opacity: Behavior { NumberAnimation { - easing: "easeInSine" - duration: 200 - } + easing: "easeInSine" + duration: 200 } + } onPressed: { @@ -103,7 +110,7 @@ QWidget { //This is a special DoubleSpinBox that does color coding for states } } } - } + } onMouseOverChanged: { if (mouseOver) { diff --git a/share/qtcreator/qmldesigner/propertyeditor/Qt/SpinBox.qml b/share/qtcreator/qmldesigner/propertyeditor/Qt/SpinBox.qml index 5ecefa96a2d..5965a373c80 100644 --- a/share/qtcreator/qmldesigner/propertyeditor/Qt/SpinBox.qml +++ b/share/qtcreator/qmldesigner/propertyeditor/Qt/SpinBox.qml @@ -28,10 +28,10 @@ QWidget { //This is a special SpinBox that does color coding for states else SpinBox.setStyleSheet("color: gray;"); } else { - if (backendValue != null && backendValue.isInSubState) - SpinBox.setStyleSheet("color: #7799FF;"); - else - SpinBox.setStyleSheet("color: gray;"); + if (backendValue != null && backendValue.isInSubState) + SpinBox.setStyleSheet("color: #7799FF;"); + else + SpinBox.setStyleSheet("color: gray;"); } } } @@ -49,9 +49,17 @@ QWidget { //This is a special SpinBox that does color coding for states keyboardTracking: false; id: box; enabled: backendValue === undefined || backendValue.isBound === undefined || backendValue.isBound === null ? false : !backendValue.isBound - value: backendValue == undefined || backendValue.value == undefined || backendValue.value === null ? 0 : backendValue.value; + property bool readingFromBackend: false; + property int valueFromBackend: SpinBox.backendValue == null ? .0 : SpinBox.backendValue.value; + + onValueFromBackendChanged: { + readingFromBackend = true; + value = valueFromBackend + readingFromBackend = false; + } + onValueChanged: { - if (backendValue != undefined && backendValue != null) + if (SpinBox.backendValue != null && readingFromBackend == false) backendValue.value = value; } onFocusChanged: { @@ -61,7 +69,7 @@ QWidget { //This is a special SpinBox that does color coding for states } } - QToolButton { + QToolButton { visible: false; width: 10; height: 10; -- GitLab