forked from qt-creator/qt-creator
Merge "Merge remote-tracking branch 'origin/8.0' into 9.0" into 9.0
This commit is contained in:
@@ -165,6 +165,21 @@ Item {
|
||||
width: root.width
|
||||
caption: qsTr("Materials")
|
||||
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 {
|
||||
id: grid
|
||||
|
@@ -117,14 +117,24 @@ bool MaterialBrowserWidget::eventFilter(QObject *obj, QEvent *event)
|
||||
mimeData->setData(Constants::MIME_TYPE_BUNDLE_MATERIAL, data);
|
||||
mimeData->removeFormat("text/plain");
|
||||
|
||||
if (!m_draggedBundleMaterial) {
|
||||
m_draggedBundleMaterial = m_bundleMaterialToDrag;
|
||||
emit draggedBundleMaterialChanged();
|
||||
}
|
||||
|
||||
emit bundleMaterialDragStarted(m_bundleMaterialToDrag);
|
||||
model->startDrag(mimeData, m_bundleMaterialToDrag->icon().toLocalFile());
|
||||
m_bundleMaterialToDrag = {};
|
||||
m_bundleMaterialToDrag = nullptr;
|
||||
}
|
||||
}
|
||||
} else if (event->type() == QMouseEvent::MouseButtonRelease) {
|
||||
m_materialToDrag = {};
|
||||
m_bundleMaterialToDrag = {};
|
||||
m_bundleMaterialToDrag = nullptr;
|
||||
|
||||
if (m_draggedBundleMaterial) {
|
||||
m_draggedBundleMaterial = nullptr;
|
||||
emit draggedBundleMaterialChanged();
|
||||
}
|
||||
}
|
||||
|
||||
return QObject::eventFilter(obj, event);
|
||||
|
@@ -36,6 +36,7 @@ class PreviewImageProvider;
|
||||
class MaterialBrowserWidget : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(BundleMaterial *draggedBundleMaterial MEMBER m_draggedBundleMaterial NOTIFY draggedBundleMaterialChanged)
|
||||
|
||||
public:
|
||||
MaterialBrowserWidget(MaterialBrowserView *view);
|
||||
@@ -59,6 +60,7 @@ public:
|
||||
|
||||
signals:
|
||||
void bundleMaterialDragStarted(QmlDesigner::BundleMaterial *bundleMat);
|
||||
void draggedBundleMaterialChanged();
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *obj, QEvent *event) override;
|
||||
@@ -80,6 +82,7 @@ private:
|
||||
|
||||
ModelNode m_materialToDrag;
|
||||
BundleMaterial *m_bundleMaterialToDrag = nullptr;
|
||||
BundleMaterial *m_draggedBundleMaterial = nullptr;
|
||||
QPoint m_dragStartPoint;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user