QmlDesigner: Use correct Enumeration type for instance values

Puppet used to return just string for enumeration types.
Now it will use Enumeration type properly.

Change-Id: I602891e34c03cb659ee0a8e4571b39b6e24f9e1c
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io>
This commit is contained in:
Miikka Heikkinen
2024-05-20 12:32:36 +03:00
parent 5f23a07ba7
commit fd2c7db691
2 changed files with 5 additions and 3 deletions

View File

@@ -1187,8 +1187,9 @@ InformationChangedCommand NodeInstanceServer::createAllInformationChangedCommand
static bool supportedVariantType(int type)
{
return type < int(QVariant::UserType) && type != QMetaType::QObjectStar
&& type != QMetaType::QModelIndex && type != QMetaType::VoidStar;
return (type < int(QVariant::UserType) && type != QMetaType::QObjectStar
&& type != QMetaType::QModelIndex && type != QMetaType::VoidStar)
|| type == QMetaType::fromType<Enumeration>().id();
}
ValuesChangedCommand NodeInstanceServer::createValuesChangedCommand(const QList<ServerNodeInstance> &instanceList) const

View File

@@ -619,7 +619,8 @@ QVariant ObjectNodeInstance::property(const PropertyName &name) const
QQmlProperty property(object(), QString::fromUtf8(name), context());
if (property.property().isEnumType()) {
QVariant value = property.read();
return property.property().enumerator().valueToKey(value.toInt());
QMetaEnum me = property.property().enumerator();
return QVariant::fromValue<Enumeration>(Enumeration(me.scope(), me.valueToKey(value.toInt())));
}
if (property.propertyType() == QVariant::Url) {