aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMahmoud Badri <mahmoud.badri@qt.io>2022-06-07 21:19:44 +0300
committerMahmoud Badri <mahmoud.badri@qt.io>2022-06-16 14:05:10 +0000
commit568004e12182458b44222cc53a545611992eba02 (patch)
treea96638fd3ebbe6c656a536c7e106bcfde7bd2d3e
parent221376aa3823df2d36dedaf2e1ab97231c0ffbde (diff)
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: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
-rw-r--r--src/plugins/qmldesigner/components/materialeditor/materialeditorview.cpp7
-rw-r--r--src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.cpp5
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<QObject *>();
PropertyEditorValue *propEditorVal = qobject_cast<PropertyEditorValue *>(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