From 89488d1cf1c49958f0805f4a74db3a55d7647803 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Fri, 15 Jul 2022 16:26:40 +0200 Subject: [PATCH] QmlDesigner: Further reduce the direct dependecy on GradientLine MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I1c7d9b87f2b2c16393bd672fe80356aca8b6e2d3 Reviewed-by: Reviewed-by: Henning Gründl --- .../imports/HelperWidgets/ColorEditor.qml | 6 ++--- .../HelperWidgets/ColorEditorPopup.qml | 22 ++++++++++++------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ColorEditor.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ColorEditor.qml index 1f3245a9ec0..b3a7c1e9fb0 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ColorEditor.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ColorEditor.qml @@ -109,14 +109,12 @@ SecondColumnLayout { if (colorEditor.supportGradient && cePopup.gradientModel.hasGradient) { var hexColor = convertColorToString(colorEditor.color) hexTextField.text = hexColor - cePopup.popupHexTextField.text = hexColor - cePopup.gradientLine.currentColor = colorEditor.color + cePopup.commitGradientColor() } // Delay setting the color to keep ui responsive if (cePopup.isNotInGradientMode()) - colorEditorTimer.restart( - ) + colorEditorTimer.restart() } Spacer { diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ColorEditorPopup.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ColorEditorPopup.qml index 500995d2dd9..6a015a7c08a 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ColorEditorPopup.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ColorEditorPopup.qml @@ -37,13 +37,19 @@ T.Popup { property alias gradientLine: gradientLine property alias popupHexTextField: popupHexTextField - property alias gradientPropertyName: cePopup.gradientLine.gradientPropertyName + property alias gradientPropertyName: cePopup.gradientModel.gradientPropertyName property alias gradientOrientation: gradientOrientation property alias gradientModel: gradientModel property bool isInValidState: false + function commitGradientColor() { + var hexColor = convertColorToString(colorEditor.color) + cePopup.popupHexTextField.text = hexColor + cePopup.gradientLine.currentColor = colorEditor.color + } + function isNotInGradientMode() { return ceMode.currentValue === "Solid" } @@ -123,7 +129,7 @@ T.Popup { === Gradient.Horizontal ? "Gradient.Horizontal" : "Gradient.Vertical" gradientString += "orientation: " + orientation + ";" - for (var i = 0; i < cePopup.gradientLine.model.count; i++) + for (var i = 0; i < gradientModel.count; i++) gradientString += "GradientStop {}" gradientString += "}" @@ -132,10 +138,10 @@ T.Popup { gradientString, colorEditor.gradientThumbnail, "dynamicGradient") - for (i = 0; i < cePopup.gradientLine.model.count; i++) { - gradientObject.stops[i].color = cePopup.gradientLine.model.getColor( + for (i = 0; i < gradientModel.count; i++) { + gradientObject.stops[i].color = gradientModel.getColor( i) - gradientObject.stops[i].position = cePopup.gradientLine.model.getPosition( + gradientObject.stops[i].position = gradientModel.getPosition( i) } @@ -166,10 +172,10 @@ T.Popup { gradientStr, colorEditor.shapeGradientThumbnail, "dynamicShapeGradient") - for (j = 0; j < cePopup.gradientLine.model.count; j++) { - gradientObj.stops[j].color = cePopup.gradientLine.model.getColor( + for (j = 0; j < gradientModel.count; j++) { + gradientObj.stops[j].color = gradientModel.getColor( j) - gradientObj.stops[j].position = cePopup.gradientLine.model.getPosition( + gradientObj.stops[j].position = gradientModel.getPosition( j) }