forked from qt-creator/qt-creator
QmlDesigner: Allow dropping bundle materials to Navigator
Fixes: QDS-7844 Change-Id: If3c58f82797beabe76baf99ea2dddc59032729df Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
This commit is contained in:
@@ -481,7 +481,6 @@ void MaterialBrowserView::customNotification(const AbstractView *view, const QSt
|
|||||||
} else if (identifier == "drop_bundle_material") {
|
} else if (identifier == "drop_bundle_material") {
|
||||||
m_bundleMaterialDropTarget = nodeList.first();
|
m_bundleMaterialDropTarget = nodeList.first();
|
||||||
|
|
||||||
|
|
||||||
ModelNode defaultMat = getBundleMaterialDefaultInstance(m_draggedBundleMaterial->type());
|
ModelNode defaultMat = getBundleMaterialDefaultInstance(m_draggedBundleMaterial->type());
|
||||||
if (defaultMat.isValid())
|
if (defaultMat.isValid())
|
||||||
applyBundleMaterialToDropTarget(defaultMat);
|
applyBundleMaterialToDropTarget(defaultMat);
|
||||||
|
@@ -132,12 +132,15 @@ bool MaterialBrowserWidget::eventFilter(QObject *obj, QEvent *event)
|
|||||||
} else if (m_bundleMaterialToDrag != nullptr) {
|
} else if (m_bundleMaterialToDrag != nullptr) {
|
||||||
QMouseEvent *me = static_cast<QMouseEvent *>(event);
|
QMouseEvent *me = static_cast<QMouseEvent *>(event);
|
||||||
if ((me->globalPos() - m_dragStartPoint).manhattanLength() > 20) {
|
if ((me->globalPos() - m_dragStartPoint).manhattanLength() > 20) {
|
||||||
|
QByteArray data;
|
||||||
QMimeData *mimeData = new QMimeData;
|
QMimeData *mimeData = new QMimeData;
|
||||||
mimeData->setData(Constants::MIME_TYPE_BUNDLE_MATERIAL, {});
|
QDataStream stream(&data, QIODevice::WriteOnly);
|
||||||
|
stream << m_bundleMaterialToDrag->type();
|
||||||
|
mimeData->setData(Constants::MIME_TYPE_BUNDLE_MATERIAL, data);
|
||||||
mimeData->removeFormat("text/plain");
|
mimeData->removeFormat("text/plain");
|
||||||
|
|
||||||
model->startDrag(mimeData, m_bundleMaterialToDrag->icon().toLocalFile());
|
|
||||||
emit bundleMaterialDragStarted(m_bundleMaterialToDrag);
|
emit bundleMaterialDragStarted(m_bundleMaterialToDrag);
|
||||||
|
model->startDrag(mimeData, m_bundleMaterialToDrag->icon().toLocalFile());
|
||||||
m_bundleMaterialToDrag = {};
|
m_bundleMaterialToDrag = {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -58,6 +58,8 @@ ChooseFromPropertyListFilter::ChooseFromPropertyListFilter(const NodeMetaInfo &i
|
|||||||
// -> Attractor3D
|
// -> Attractor3D
|
||||||
// Material
|
// Material
|
||||||
// -> Model
|
// -> Model
|
||||||
|
// BundleMaterial
|
||||||
|
// -> Model
|
||||||
|
|
||||||
const TypeName textureType = "QtQuick3D.Texture";
|
const TypeName textureType = "QtQuick3D.Texture";
|
||||||
if (insertInfo.isSubclassOf(textureType)) {
|
if (insertInfo.isSubclassOf(textureType)) {
|
||||||
@@ -107,7 +109,10 @@ ChooseFromPropertyListFilter::ChooseFromPropertyListFilter(const NodeMetaInfo &i
|
|||||||
|| parentInfo.isSubclassOf("QtQuick3D.Particles3D.Attractor3D"))
|
|| parentInfo.isSubclassOf("QtQuick3D.Particles3D.Attractor3D"))
|
||||||
propertyList.append("shape");
|
propertyList.append("shape");
|
||||||
} else if (insertInfo.isSubclassOf("QtQuick3D.Material")) {
|
} else if (insertInfo.isSubclassOf("QtQuick3D.Material")) {
|
||||||
if (parentInfo.isSubclassOf("QtQuick3D.Particles3D.Model"))
|
if (parentInfo.isSubclassOf("QtQuick3D.Model"))
|
||||||
|
propertyList.append("materials");
|
||||||
|
} else if (insertInfo.typeName().startsWith("ComponentBundles.MaterialBundle")) {
|
||||||
|
if (parentInfo.isSubclassOf("QtQuick3D.Model"))
|
||||||
propertyList.append("materials");
|
propertyList.append("materials");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -465,6 +465,7 @@ QStringList NavigatorTreeModel::mimeTypes() const
|
|||||||
const static QStringList types({Constants::MIME_TYPE_MODELNODE_LIST,
|
const static QStringList types({Constants::MIME_TYPE_MODELNODE_LIST,
|
||||||
Constants::MIME_TYPE_ITEM_LIBRARY_INFO,
|
Constants::MIME_TYPE_ITEM_LIBRARY_INFO,
|
||||||
Constants::MIME_TYPE_MATERIAL,
|
Constants::MIME_TYPE_MATERIAL,
|
||||||
|
Constants::MIME_TYPE_BUNDLE_MATERIAL,
|
||||||
Constants::MIME_TYPE_ASSETS});
|
Constants::MIME_TYPE_ASSETS});
|
||||||
|
|
||||||
return types;
|
return types;
|
||||||
@@ -562,6 +563,10 @@ bool NavigatorTreeModel::dropMimeData(const QMimeData *mimeData,
|
|||||||
handleItemLibraryItemDrop(mimeData, rowNumber, dropModelIndex);
|
handleItemLibraryItemDrop(mimeData, rowNumber, dropModelIndex);
|
||||||
} else if (mimeData->hasFormat(Constants::MIME_TYPE_MATERIAL)) {
|
} else if (mimeData->hasFormat(Constants::MIME_TYPE_MATERIAL)) {
|
||||||
handleMaterialDrop(mimeData, rowNumber, dropModelIndex);
|
handleMaterialDrop(mimeData, rowNumber, dropModelIndex);
|
||||||
|
} else if (mimeData->hasFormat(Constants::MIME_TYPE_BUNDLE_MATERIAL)) {
|
||||||
|
ModelNode targetNode(modelNodeForIndex(dropModelIndex));
|
||||||
|
if (targetNode.isValid())
|
||||||
|
m_view->emitCustomNotification("drop_bundle_material", {targetNode}); // To MaterialBrowserView
|
||||||
} else if (mimeData->hasFormat(Constants::MIME_TYPE_ASSETS)) {
|
} else if (mimeData->hasFormat(Constants::MIME_TYPE_ASSETS)) {
|
||||||
const QStringList assetsPaths = QString::fromUtf8(mimeData->data(Constants::MIME_TYPE_ASSETS)).split(',');
|
const QStringList assetsPaths = QString::fromUtf8(mimeData->data(Constants::MIME_TYPE_ASSETS)).split(',');
|
||||||
NodeAbstractProperty targetProperty;
|
NodeAbstractProperty targetProperty;
|
||||||
|
@@ -284,6 +284,14 @@ void NavigatorView::dragStarted(QMimeData *mimeData)
|
|||||||
|
|
||||||
m_widget->setDragType(matNode.metaInfo().typeName());
|
m_widget->setDragType(matNode.metaInfo().typeName());
|
||||||
m_widget->update();
|
m_widget->update();
|
||||||
|
} else if (mimeData->hasFormat(Constants::MIME_TYPE_BUNDLE_MATERIAL)) {
|
||||||
|
QByteArray data = mimeData->data(Constants::MIME_TYPE_BUNDLE_MATERIAL);
|
||||||
|
QDataStream stream(data);
|
||||||
|
TypeName bundleMatType;
|
||||||
|
stream >> bundleMatType;
|
||||||
|
|
||||||
|
m_widget->setDragType(bundleMatType);
|
||||||
|
m_widget->update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user