aboutsummaryrefslogtreecommitdiffstats
path: root/share/qtcreator
diff options
context:
space:
mode:
authorAli Kianian <ali.kianian@qt.io>2024-04-08 10:48:18 +0300
committerAli Kianian <ali.kianian@qt.io>2024-04-09 09:00:32 +0000
commit3494f37b18be3ccb04db38c2c9c2ead6ec3da17e (patch)
tree540f674aa574eaa236298a4406e1fed2a3a4adaa /share/qtcreator
parentbc5628afca0c0716642cd69679d6b51acfa60316 (diff)
QmlDesigner: Set the color data by the first commit in Model Editor
The color didn't use to be saved by the first commit. The problem was that the ColorEditorPopup uses a backendValue, which usually is provided by the property editor items. Here this backendValue is faked, to be used by the internal modules. Fixes: QDS-12018 Change-Id: I77bd0e2992f31f2fa4da7b1d7a5f0667f6923085 Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: Shrief Gabr <shrief.gabr@qt.io> Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io>
Diffstat (limited to 'share/qtcreator')
-rw-r--r--share/qtcreator/qmldesigner/collectionEditorQmlSource/ColorViewDelegate.qml54
1 files changed, 27 insertions, 27 deletions
diff --git a/share/qtcreator/qmldesigner/collectionEditorQmlSource/ColorViewDelegate.qml b/share/qtcreator/qmldesigner/collectionEditorQmlSource/ColorViewDelegate.qml
index 6bb1b60159..16e55acfb4 100644
--- a/share/qtcreator/qmldesigner/collectionEditorQmlSource/ColorViewDelegate.qml
+++ b/share/qtcreator/qmldesigner/collectionEditorQmlSource/ColorViewDelegate.qml
@@ -16,19 +16,33 @@ Row {
property color color
property bool supportGradient: false
- readonly property color __editColor: edit
+
+ property QtObject backendValue: QtObject {
+ property color value: edit
+ readonly property color editColor: edit
+
+ function resetValue() {
+ if (value)
+ value = ""
+ }
+
+ onValueChanged: {
+ if (editColor !== value)
+ edit = value
+ }
+ }
property variant value: {
- if (!edit)
+ if (!colorEditor.backendValue || !colorEditor.backendValue.value)
return "white" // default color for Rectangle
if (colorEditor.isVector3D) {
- return Qt.rgba(__editColor.x,
- __editColor.y,
- __editColor.z, 1)
+ return Qt.rgba(colorEditor.backendValue.value.x,
+ colorEditor.backendValue.value.y,
+ colorEditor.backendValue.value.z, 1)
}
- return __editColor
+ return colorEditor.backendValue.value
}
property alias gradientPropertyName: popupDialog.gradientPropertyName
@@ -42,31 +56,17 @@ Row {
property bool __block: false
- function getColorFromEditValue() {
- if (!edit)
- return "white" // default color for Rectangle
-
- if (colorEditor.isVector3D) {
- return Qt.rgba(__editColor.x,
- __editColor.y,
- __editColor.z, 1)
- }
-
- return __editColor
- }
-
function resetShapeColor() {
- if (edit)
- edit = ""
+ colorEditor.backendValue.resetValue()
}
function writeColor() {
if (colorEditor.isVector3D) {
- edit = Qt.vector3d(colorEditor.color.r,
+ colorEditor.backendValue.value = Qt.vector3d(colorEditor.color.r,
colorEditor.color.g,
colorEditor.color.b)
} else {
- edit = colorEditor.color
+ colorEditor.backendValue.value = colorEditor.color
}
}
@@ -77,7 +77,7 @@ Row {
// Syncing color from backend to frontend and block reflection
function syncColor() {
colorEditor.__block = true
- colorEditor.color = colorEditor.getColorFromEditValue()
+ colorEditor.color = colorEditor.value
hexTextField.syncColor()
colorEditor.__block = false
}
@@ -92,7 +92,7 @@ Row {
colorEditor.syncColor()
}
- function on__EditColorChanged() {
+ function onBackendValueChanged() {
if (popupDialog.isSolid())
colorEditor.syncColor()
}
@@ -208,7 +208,7 @@ Row {
if (colorEditor.supportGradient && popupDialog.loaderItem.gradientModel.hasGradient) {
var hexColor = convertColorToString(colorEditor.color)
hexTextField.text = hexColor
- edit = hexColor
+ colorEditor.backendValue.value = hexColor
popupDialog.loaderItem.commitGradientColor()
}
}
@@ -292,5 +292,5 @@ Row {
Component.onCompleted: popupDialog.determineActiveColorMode()
- on__EditColorChanged: popupDialog.determineActiveColorMode()
+ onBackendValueChanged: popupDialog.determineActiveColorMode()
}