forked from qt-creator/qt-creator
QmlDesigner: Fix value types in property editor
Currently the value types of e.g. layer.textureSize and layer.sourceRect are only resolved for QML Item, but not QML Control. This patch increases the recursion depth while collecting the attributes of values types in order to be able to set layer.textureSize.width or layer.sourceRect.x. It also adds those attributes to be able to read the values. Change-Id: I61ba1468d1443953f0a5b6ab2241114dc441bb79 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
committed by
Henning Gründl
parent
6fba34f5a7
commit
65567b4717
@@ -409,7 +409,7 @@ QVector<PropertyInfo> getQmlTypes(const CppComponentValue *objectValue, const Co
|
||||
if (objectValue->className().isEmpty())
|
||||
return propertyList;
|
||||
|
||||
if (rec > 2)
|
||||
if (rec > 4)
|
||||
return propertyList;
|
||||
|
||||
PropertyMemberProcessor processor(context);
|
||||
@@ -431,9 +431,14 @@ QVector<PropertyInfo> getQmlTypes(const CppComponentValue *objectValue, const Co
|
||||
}
|
||||
}
|
||||
if (isValueType(objectValue->propertyType(nameAsString))) {
|
||||
const ObjectValue *dotObjectValue = value_cast<ObjectValue>(objectValue->lookupMember(nameAsString, context));
|
||||
const ObjectValue *dotObjectValue = value_cast<ObjectValue>(
|
||||
objectValue->lookupMember(nameAsString, context));
|
||||
|
||||
if (dotObjectValue) {
|
||||
const QVector<PropertyInfo> dotProperties = getObjectTypes(dotObjectValue, context, false, rec + 1);
|
||||
const QVector<PropertyInfo> dotProperties = getObjectTypes(dotObjectValue,
|
||||
context,
|
||||
false,
|
||||
rec + 1);
|
||||
for (const PropertyInfo &propertyInfo : dotProperties) {
|
||||
const PropertyName dotName = name + '.' + propertyInfo.first;
|
||||
const TypeName type = propertyInfo.second;
|
||||
@@ -525,7 +530,7 @@ QVector<PropertyInfo> getObjectTypes(const ObjectValue *objectValue, const Conte
|
||||
if (objectValue->className().isEmpty())
|
||||
return propertyList;
|
||||
|
||||
if (rec > 2)
|
||||
if (rec > 4)
|
||||
return propertyList;
|
||||
|
||||
PropertyMemberProcessor processor(context);
|
||||
@@ -539,6 +544,7 @@ QVector<PropertyInfo> getObjectTypes(const ObjectValue *objectValue, const Conte
|
||||
|
||||
if (isValueType(property.second)) {
|
||||
const Value *dotValue = objectValue->lookupMember(nameAsString, context);
|
||||
|
||||
if (!dotValue)
|
||||
continue;
|
||||
|
||||
@@ -546,7 +552,10 @@ QVector<PropertyInfo> getObjectTypes(const ObjectValue *objectValue, const Conte
|
||||
dotValue = context->lookupReference(ref);
|
||||
|
||||
if (const ObjectValue *dotObjectValue = dotValue->asObjectValue()) {
|
||||
const QVector<PropertyInfo> dotProperties = getObjectTypes(dotObjectValue, context, false, rec + 1);
|
||||
const QVector<PropertyInfo> dotProperties = getObjectTypes(dotObjectValue,
|
||||
context,
|
||||
false,
|
||||
rec + 1);
|
||||
for (const PropertyInfo &propertyInfo : dotProperties) {
|
||||
const PropertyName dotName = name + '.' + propertyInfo.first;
|
||||
const TypeName type = propertyInfo.second;
|
||||
|
@@ -567,6 +567,15 @@ void ObjectNodeInstance::doResetProperty(const PropertyName &propertyName)
|
||||
QmlPrivateGate::doResetProperty(object(), context(), propertyName);
|
||||
}
|
||||
|
||||
static bool isPropertyBlackListed(const PropertyName &propertyName)
|
||||
{
|
||||
if (propertyName.contains(".") && propertyName.contains("__"))
|
||||
return true;
|
||||
if (propertyName.count(".") > 2)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
QVariant ObjectNodeInstance::property(const PropertyName &name) const
|
||||
{
|
||||
if (ignoredProperties().contains(name))
|
||||
@@ -574,7 +583,7 @@ QVariant ObjectNodeInstance::property(const PropertyName &name) const
|
||||
|
||||
// TODO: handle model nodes
|
||||
|
||||
if (QmlPrivateGate::isPropertyBlackListed(name))
|
||||
if (isPropertyBlackListed(name))
|
||||
return QVariant();
|
||||
|
||||
QQmlProperty property(object(), QString::fromUtf8(name), context());
|
||||
@@ -612,6 +621,37 @@ void ObjectNodeInstance::ensureVector3DDotProperties(PropertyNameList &list) con
|
||||
}
|
||||
}
|
||||
|
||||
void ObjectNodeInstance::ensureValueTypeProperties(PropertyNameList &list) const
|
||||
{
|
||||
const PropertyNameList pointDotProperties = {"x", "y"};
|
||||
const PropertyNameList sizeDotProperties = {"width", "height"};
|
||||
const PropertyNameList rectDotProperties = {"x", "y", "width", "height"};
|
||||
|
||||
PropertyNameList valueTypeProperties;
|
||||
|
||||
for (const auto &property : list) {
|
||||
const QString name = instanceType(property);
|
||||
PropertyNameList dotProperties;
|
||||
|
||||
if (name == "QPoint" || name == "QPointF")
|
||||
dotProperties = pointDotProperties;
|
||||
|
||||
if (name == "QSize" || name == "QSizeF")
|
||||
dotProperties = sizeDotProperties;
|
||||
|
||||
if (name == "QRect" || name == "QRectF")
|
||||
dotProperties = rectDotProperties;
|
||||
|
||||
for (const auto &dotProperty : dotProperties)
|
||||
valueTypeProperties.append(property + "." + dotProperty);
|
||||
}
|
||||
|
||||
for (const auto &valueTypeProperty : valueTypeProperties) {
|
||||
if (!list.contains(valueTypeProperty))
|
||||
list.append(valueTypeProperty);
|
||||
}
|
||||
}
|
||||
|
||||
PropertyNameList ObjectNodeInstance::propertyNames() const
|
||||
{
|
||||
PropertyNameList list;
|
||||
@@ -619,13 +659,14 @@ PropertyNameList ObjectNodeInstance::propertyNames() const
|
||||
list = QmlPrivateGate::allPropertyNames(object());
|
||||
|
||||
ensureVector3DDotProperties(list);
|
||||
ensureValueTypeProperties(list);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
QString ObjectNodeInstance::instanceType(const PropertyName &name) const
|
||||
{
|
||||
if (QmlPrivateGate::isPropertyBlackListed(name))
|
||||
if (isPropertyBlackListed(name))
|
||||
return QLatin1String("undefined");
|
||||
|
||||
QQmlProperty property(object(), QString::fromUtf8(name), context());
|
||||
|
@@ -199,6 +199,7 @@ protected:
|
||||
|
||||
void initializePropertyWatcher(const ObjectNodeInstance::Pointer &objectNodeInstance);
|
||||
void ensureVector3DDotProperties(PropertyNameList &list) const;
|
||||
void ensureValueTypeProperties(PropertyNameList &list) const;
|
||||
|
||||
private:
|
||||
QString m_id;
|
||||
|
Reference in New Issue
Block a user