Implement drag-and-drop from Assets View to Texture Editor

The asset (i.e. image) can now be dragged to the "Source" property of
the Texture Editor.

Task-number: QDS-8341
Change-Id: I2d30bdf245a8328a864c116c727d3faaaad347cc
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Samuel Ghinet
2022-11-24 14:54:22 +02:00
parent 3321261cf3
commit 45c7a6b8e6
3 changed files with 30 additions and 1 deletions

View File

@@ -821,10 +821,15 @@ void QmlDesigner::TextureEditorView::highlightSupportedProperties(bool highlight
QTC_ASSERT(metaInfo.isValid(), return);
for (const QString &propName : propNames) {
if (metaInfo.property(propName.toUtf8()).propertyType().isQtQuick3DTexture()) { // TODO: support dropping to texture source
if (metaInfo.property(propName.toUtf8()).propertyType().isQtQuick3DTexture()) {
QObject *propEditorValObj = propMap.value(propName).value<QObject *>();
PropertyEditorValue *propEditorVal = qobject_cast<PropertyEditorValue *>(propEditorValObj);
propEditorVal->setHasActiveDrag(highlight);
} else if (metaInfo.property(propName.toUtf8()).propertyType().isUrl()) {
QObject *propEditorValObj = propMap.value(propName).value<QObject *>();
PropertyEditorValue *propEditorVal = qobject_cast<PropertyEditorValue *>(propEditorValObj);
if (propEditorVal)
propEditorVal->setHasActiveDrag(highlight);
}
}
}
@@ -841,6 +846,9 @@ void TextureEditorView::dragStarted(QMimeData *mimeData)
return;
highlightSupportedProperties();
const QString suffix = "*." + assetPath.split('.').last().toLower();
m_qmlBackEnd->contextObject()->setActiveDragSuffix(suffix);
}
void TextureEditorView::dragEnded()