From fb87aa97bd162b482a9eb67fe24c7059d5c13bfd Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Fri, 15 Aug 2014 13:52:39 +0200 Subject: [PATCH] QmlDesigner.PropertyEditor: Commit color string if selection changes The LineEdit in the ColorEditor is not binded to a backendvalue and we react manually to isAccepted (writeValueManually is set to true). Because of this (and the famous focus bugs), we do not set the color, if the selection is changed or the user enters edit mode without pressing enter. This patch adds the signal onCommitData to LineEdit and we react to the signal. Because the the change of the backendvalue is delayed by a timer we set the color immediately on the backend if we are not in gradient editing mode. Task-number: QTCREATORBUG-12841 Change-Id: Ic98640398c2c46b5e529780b4a9638c90760063f Reviewed-by: Tim Jenssen --- .../HelperWidgets/ColorEditor.qml | 12 +++++++++++- .../HelperWidgets/LineEdit.qml | 5 +++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/HelperWidgets/ColorEditor.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/HelperWidgets/ColorEditor.qml index aa4b76edfe5..6fe7636fad5 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/HelperWidgets/ColorEditor.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/HelperWidgets/ColorEditor.qml @@ -50,6 +50,10 @@ Column { property alias gradientPropertyName: gradientLine.gradientPropertyName + function isNotInGradientMode() { + return (buttonRow.checkedIndex !== 1) + } + onValueChanged: { colorEditor.color = colorEditor.value } @@ -78,7 +82,7 @@ Column { gradientLine.currentColor = color } - if (buttonRow.checkedIndex !== 1) { + if (isNotInGradientMode()) { //Delay setting the color to keep ui responsive colorEditorTimer.restart() } @@ -170,6 +174,12 @@ Column { colorEditor.color = colorFromString(textField.text) } + onCommitData: { + colorEditor.color = colorFromString(textField.text) + if (isNotInGradientMode()) + backendendValue.value = colorEditor.color + } + Layout.fillWidth: true } ColorCheckButton { diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/HelperWidgets/LineEdit.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/HelperWidgets/LineEdit.qml index 9cea91a9e5c..1f5dd2aad78 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/HelperWidgets/LineEdit.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/HelperWidgets/LineEdit.qml @@ -53,6 +53,8 @@ Controls.TextField { property bool showExtendedFunctionButton: true + signal commitData + ExtendedFunctionButton { x: 2 y: 4 @@ -82,7 +84,10 @@ Controls.TextField { onSelectionToBeChanged: { if (__dirty && !writeValueManually) { lineEdit.backendValue.value = text + } else if (__dirty) { + commitData() } + __dirty = false } }