summaryrefslogtreecommitdiff
path: root/src/plugins/qmldesigner/components/edit3d/edit3dviewconfig.h
diff options
context:
space:
mode:
authorSamuel Ghinet <samuel.ghinet@qt.io>2022-12-15 16:38:38 +0200
committerSamuel Ghinet <samuel.ghinet@qt.io>2022-12-16 13:59:25 +0000
commit965fa9450c3e3424e5e9e4a1bec3612a66594059 (patch)
tree201ae4f2f91fe8241fa6763d576dd3f0db051f19 /src/plugins/qmldesigner/components/edit3d/edit3dviewconfig.h
parentbb37d782ca9fa4ccb56957a6273822ae393fbebd (diff)
downloadqt-creator-965fa9450c3e3424e5e9e4a1bec3612a66594059.tar.gz
QmlDesigner: Fix cancel button not reverting background color
In the 3D view, when the user experiments with different background colors, but then decides to cancel, upon pressing the Cancel button and closing the dialog, the last color picked remained set. This happened on Qt6.4 and not on Qt6.3. The reason for this was the usage of Array.isArray() on an object exposed from C++ to QML of type QVariant that could hold either a QList<QColor> or a a QColor. It looks like there is no supported way from qml/js to see if a variable is a list / sequence or a scalar. So the best way would be to always work with QList<QColor> even though in most cases only one single QColor is being used. Task-number: QDS-8143 Change-Id: Ia7e8e1facad24439ad244305c213bb12e286105b Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Diffstat (limited to 'src/plugins/qmldesigner/components/edit3d/edit3dviewconfig.h')
-rw-r--r--src/plugins/qmldesigner/components/edit3d/edit3dviewconfig.h21
1 files changed, 4 insertions, 17 deletions
diff --git a/src/plugins/qmldesigner/components/edit3d/edit3dviewconfig.h b/src/plugins/qmldesigner/components/edit3d/edit3dviewconfig.h
index 267e27042c..e0eba1115c 100644
--- a/src/plugins/qmldesigner/components/edit3d/edit3dviewconfig.h
+++ b/src/plugins/qmldesigner/components/edit3d/edit3dviewconfig.h
@@ -28,17 +28,9 @@ public:
});
}
- static void setColor(AbstractView *view, View3DActionType type, const QList<QColor> &colorConfig)
+ static void setColors(AbstractView *view, View3DActionType type, const QList<QColor> &colorConfig)
{
- if (colorConfig.size() == 1)
- setColor(view, type, colorConfig.at(0));
- else
- setVariant(view, type, QVariant::fromValue(colorConfig));
- }
-
- static void setColor(AbstractView *view, View3DActionType type, const QColor &color)
- {
- setVariant(view, type, QVariant::fromValue(color));
+ setVariant(view, type, QVariant::fromValue(colorConfig));
}
template <typename T>
@@ -47,7 +39,7 @@ public:
setVariant(view, type, QVariant::fromValue(value));
}
- static void saveColor(const QByteArray &key, const QList<QColor> &colorConfig)
+ static void saveColors(const QByteArray &key, const QList<QColor> &colorConfig)
{
QStringList colorNames = Utils::transform(colorConfig, [](const QColor &color) {
return color.name();
@@ -56,12 +48,7 @@ public:
saveVariant(key, QVariant::fromValue(colorNames));
}
- static void saveColor(const QByteArray &key, const QColor &color)
- {
- saveVariant(key, QVariant::fromValue(color.name()));
- }
-
- static bool isColorValid(const QList<QColor> &colorConfig) { return !colorConfig.isEmpty(); }
+ static bool colorsValid(const QList<QColor> &colorConfig) { return !colorConfig.isEmpty(); }
private:
static void setVariant(AbstractView *view, View3DActionType type, const QVariant &colorConfig)