diff options
Diffstat (limited to 'src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.cpp')
-rw-r--r-- | src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.cpp | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.cpp b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.cpp index 8be49060e6..a479dfeba0 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.cpp @@ -98,13 +98,22 @@ PropertyEditorContextObject::PropertyEditorContextObject(QObject *parent) : } -QString PropertyEditorContextObject::convertColorToString(const QColor &color) -{ - QString colorString = color.name(); +QString PropertyEditorContextObject::convertColorToString(const QVariant &color) +{ + QString colorString; + QColor theColor; + if (color.canConvert(QVariant::Color)) { + theColor = color.value<QColor>(); + } else if (color.canConvert(QVariant::Vector3D)) { + auto vec = color.value<QVector3D>(); + theColor = QColor::fromRgbF(vec.x(), vec.y(), vec.z()); + } - if (color.alpha() != 255) { - QString hexAlpha = QString("%1").arg(color.alpha(), 2, 16, QLatin1Char('0')); - colorString.remove(0,1); + colorString = theColor.name(); + + if (theColor.alpha() != 255) { + QString hexAlpha = QString("%1").arg(theColor.alpha(), 2, 16, QLatin1Char('0')); + colorString.remove(0, 1); colorString.prepend(hexAlpha); colorString.prepend(QStringLiteral("#")); } @@ -426,6 +435,17 @@ QStringList PropertyEditorContextObject::styleNamesForFamily(const QString &fami return dataBase.styles(family); } +QStringList PropertyEditorContextObject::allStatesForId(const QString &id) +{ + if (m_model && m_model->rewriterView()) { + const QmlObjectNode node = m_model->rewriterView()->modelNodeForId(id); + if (node.isValid()) + return node.allStateNames(); + } + + return {}; +} + void EasingCurveEditor::registerDeclarativeType() { qmlRegisterType<EasingCurveEditor>("HelperWidgets", 2, 0, "EasingCurveEditor"); |