From 568004e12182458b44222cc53a545611992eba02 Mon Sep 17 00:00:00 2001 From: Mahmoud Badri Date: Tue, 7 Jun 2022 21:19:44 +0300 Subject: QmlDesigner: Detect asset drag'n'drop support based on property type Handle property support for asset drag based on property type rather than name in order to support properties with any name (like lightProbe). Change-Id: I20fd422119db96aebd505b47888c97f0d94bf7f9 Reviewed-by: Reviewed-by: Miikka Heikkinen Reviewed-by: Thomas Hartmann --- .../qmldesigner/components/materialeditor/materialeditorview.cpp | 7 ++++++- .../qmldesigner/components/propertyeditor/propertyeditorvalue.cpp | 5 +++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/plugins/qmldesigner/components/materialeditor/materialeditorview.cpp b/src/plugins/qmldesigner/components/materialeditor/materialeditorview.cpp index 28c17d7561..ca76d45966 100644 --- a/src/plugins/qmldesigner/components/materialeditor/materialeditorview.cpp +++ b/src/plugins/qmldesigner/components/materialeditor/materialeditorview.cpp @@ -767,11 +767,16 @@ void MaterialEditorView::customNotification(const AbstractView *view, const QStr void QmlDesigner::MaterialEditorView::highlightSupportedProperties(bool highlight) { + if (!m_selectedMaterial.isValid()) + return; + DesignerPropertyMap &propMap = m_qmlBackEnd->backendValuesPropertyMap(); const QStringList propNames = propMap.keys(); + NodeMetaInfo metaInfo = m_selectedMaterial.metaInfo(); + QTC_ASSERT(metaInfo.isValid(), return); for (const QString &propName : propNames) { - if (propName.endsWith("Map")) { + if (metaInfo.propertyTypeName(propName.toLatin1()) == "QtQuick3D.Texture") { QObject *propEditorValObj = propMap.value(propName).value(); PropertyEditorValue *propEditorVal = qobject_cast(propEditorValObj); propEditorVal->setHasActiveDrag(highlight); diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.cpp b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.cpp index 867fd9bd65..fd568911ab 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.cpp @@ -518,14 +518,15 @@ bool PropertyEditorValue::idListReplace(int idx, const QString &value) void PropertyEditorValue::commitDrop(const QString &path) { - if (m_modelNode.isSubclassOf("QtQuick3D.Material") && nameAsQString().endsWith("Map")) { + if (m_modelNode.isSubclassOf("QtQuick3D.Material") + && m_modelNode.metaInfo().propertyTypeName(m_name) == "QtQuick3D.Texture") { // create a texture node QmlDesigner::NodeMetaInfo metaInfo = m_modelNode.view()->model()->metaInfo("QtQuick3D.Texture"); QmlDesigner::ModelNode texture = m_modelNode.view()->createModelNode("QtQuick3D.Texture", metaInfo.majorVersion(), metaInfo.minorVersion()); texture.validId(); - modelNode().view()->rootModelNode().defaultNodeListProperty().reparentHere(texture); + m_modelNode.view()->rootModelNode().defaultNodeListProperty().reparentHere(texture); // TODO: group textures under 1 node (just like materials) // set texture source -- cgit v1.2.3