QmlDesigner: Add workaround for QVector3D

For some reason the Qt meta system does not work reliable
for QVector3D. It does work "rotation", but not for "pivot",
despite the fact that both properties are defined in exactly the
same way.
This patch works around the main issue.
There are still a few issues left, but at least the default is
correct now.

Task-number: QDS-1355
Change-Id: I75e2d3adff6967e89c6ce031d744baa12b5e8061
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Thomas Hartmann
2019-12-16 10:11:02 +01:00
committed by Tim Jenssen
parent e5d4224fe4
commit 2f2787c4a8
2 changed files with 22 additions and 2 deletions

View File

@@ -571,11 +571,30 @@ QVariant ObjectNodeInstance::property(const PropertyName &name) const
return property.read(); return property.read();
} }
void ObjectNodeInstance::ensureVector3DDotProperties(PropertyNameList &list) const
{
const PropertyNameList properties = { "rotation", "scale", "pivot" };
for (const auto &property : properties) {
if (list.contains(property) && instanceType(property) == "QVector3D") {
const PropertyNameList dotProperties = { "x", "y", "z" };
for (const auto &dotProperty : dotProperties) {
const PropertyName dotPropertyName = property + "." + dotProperty;
if (!list.contains(dotPropertyName))
list.append(dotPropertyName);
}
}
}
}
PropertyNameList ObjectNodeInstance::propertyNames() const PropertyNameList ObjectNodeInstance::propertyNames() const
{ {
PropertyNameList list;
if (isValid()) if (isValid())
return QmlPrivateGate::allPropertyNames(object()); list = QmlPrivateGate::allPropertyNames(object());
return PropertyNameList();
ensureVector3DDotProperties(list);
return list;
} }
QString ObjectNodeInstance::instanceType(const PropertyName &name) const QString ObjectNodeInstance::instanceType(const PropertyName &name) const

View File

@@ -209,6 +209,7 @@ protected:
static QVariant enumationValue(const Enumeration &enumeration); static QVariant enumationValue(const Enumeration &enumeration);
void initializePropertyWatcher(const ObjectNodeInstance::Pointer &objectNodeInstance); void initializePropertyWatcher(const ObjectNodeInstance::Pointer &objectNodeInstance);
void ensureVector3DDotProperties(PropertyNameList &list) const;
private: private:
QString m_id; QString m_id;