Merge remote-tracking branch 'origin/8.0' into 9.0

Change-Id: Icd606068e77d6845cbbda5d48eda477cb21a312f
This commit is contained in:
Eike Ziller
2022-10-21 10:03:56 +02:00
3 changed files with 30 additions and 2 deletions

View File

@@ -165,6 +165,21 @@ Item {
width: root.width width: root.width
caption: qsTr("Materials") caption: qsTr("Materials")
hideHeader: !materialBrowserBundleModel.matBundleExists hideHeader: !materialBrowserBundleModel.matBundleExists
dropEnabled: true
onDropEnter: (drag) => {
drag.accepted = rootView.draggedBundleMaterial
userMaterialsSection.highlight = rootView.draggedBundleMaterial
}
onDropExit: {
userMaterialsSection.highlight = false
}
onDrop: {
userMaterialsSection.highlight = false
materialBrowserBundleModel.addToProject(rootView.draggedBundleMaterial)
}
Grid { Grid {
id: grid id: grid

View File

@@ -117,14 +117,24 @@ bool MaterialBrowserWidget::eventFilter(QObject *obj, QEvent *event)
mimeData->setData(Constants::MIME_TYPE_BUNDLE_MATERIAL, data); mimeData->setData(Constants::MIME_TYPE_BUNDLE_MATERIAL, data);
mimeData->removeFormat("text/plain"); mimeData->removeFormat("text/plain");
if (!m_draggedBundleMaterial) {
m_draggedBundleMaterial = m_bundleMaterialToDrag;
emit draggedBundleMaterialChanged();
}
emit bundleMaterialDragStarted(m_bundleMaterialToDrag); emit bundleMaterialDragStarted(m_bundleMaterialToDrag);
model->startDrag(mimeData, m_bundleMaterialToDrag->icon().toLocalFile()); model->startDrag(mimeData, m_bundleMaterialToDrag->icon().toLocalFile());
m_bundleMaterialToDrag = {}; m_bundleMaterialToDrag = nullptr;
} }
} }
} else if (event->type() == QMouseEvent::MouseButtonRelease) { } else if (event->type() == QMouseEvent::MouseButtonRelease) {
m_materialToDrag = {}; m_materialToDrag = {};
m_bundleMaterialToDrag = {}; m_bundleMaterialToDrag = nullptr;
if (m_draggedBundleMaterial) {
m_draggedBundleMaterial = nullptr;
emit draggedBundleMaterialChanged();
}
} }
return QObject::eventFilter(obj, event); return QObject::eventFilter(obj, event);

View File

@@ -36,6 +36,7 @@ class PreviewImageProvider;
class MaterialBrowserWidget : public QFrame class MaterialBrowserWidget : public QFrame
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(BundleMaterial *draggedBundleMaterial MEMBER m_draggedBundleMaterial NOTIFY draggedBundleMaterialChanged)
public: public:
MaterialBrowserWidget(MaterialBrowserView *view); MaterialBrowserWidget(MaterialBrowserView *view);
@@ -59,6 +60,7 @@ public:
signals: signals:
void bundleMaterialDragStarted(QmlDesigner::BundleMaterial *bundleMat); void bundleMaterialDragStarted(QmlDesigner::BundleMaterial *bundleMat);
void draggedBundleMaterialChanged();
protected: protected:
bool eventFilter(QObject *obj, QEvent *event) override; bool eventFilter(QObject *obj, QEvent *event) override;
@@ -80,6 +82,7 @@ private:
ModelNode m_materialToDrag; ModelNode m_materialToDrag;
BundleMaterial *m_bundleMaterialToDrag = nullptr; BundleMaterial *m_bundleMaterialToDrag = nullptr;
BundleMaterial *m_draggedBundleMaterial = nullptr;
QPoint m_dragStartPoint; QPoint m_dragStartPoint;
}; };