QmlDesigner: End drag properly in assets and material browser views

If drag is accepted but drag ending is not notified to model, other
views will not know the drag has ended.

Fixes: QDS-9254
Change-Id: I1446bd4b52ce67afc37194c98e5c60e169fb57b9
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
(cherry picked from commit d3d621a7b3)
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Miikka Heikkinen
2023-02-23 16:31:07 +02:00
committed by Tim Jenssen
parent 878a5db73e
commit f8911f56fc
4 changed files with 13 additions and 1 deletions

View File

@@ -74,6 +74,11 @@ WidgetInfo AssetsLibraryView::widgetInfo()
m_widget->setHasMaterialLibrary(model() && materialLibraryNode().isValid()
&& model()->hasImport("QtQuick3D"));
});
connect(m_widget, &AssetsLibraryWidget::endDrag, this, [&]() {
if (model())
model()->endDrag();
});
}
return createWidgetInfo(m_widget.data(), "Assets", WidgetInfo::LeftPane, 0, tr("Assets"));

View File

@@ -311,6 +311,8 @@ void AssetsLibraryWidget::handleExtFilesDrop(const QList<QUrl> &simpleFilePaths,
if (!complexFilePathStrings.empty())
addResources(complexFilePathStrings);
emit endDrag();
}
QSet<QString> AssetsLibraryWidget::supportedAssetSuffixes(bool complex)

View File

@@ -108,6 +108,7 @@ signals:
void hasMaterialLibraryUpdateRequested();
void hasMaterialLibraryChanged();
void isDraggingChanged();
void endDrag();
protected:
bool eventFilter(QObject *obj, QEvent *event) override;

View File

@@ -267,11 +267,15 @@ void MaterialBrowserWidget::startDragTexture(int index, const QPointF &mousePos)
void MaterialBrowserWidget::acceptBundleMaterialDrop()
{
m_materialBrowserView->emitCustomNotification("drop_bundle_material", {}, {}); // To ContentLibraryView
if (m_materialBrowserView->model())
m_materialBrowserView->model()->endDrag();
}
void MaterialBrowserWidget::acceptBundleTextureDrop()
{
m_materialBrowserView->emitCustomNotification("drop_bundle_texture", {}, {}); // To ContentLibraryView
if (m_materialBrowserView->model())
m_materialBrowserView->model()->endDrag();
}
void MaterialBrowserWidget::acceptTextureDropOnMaterial(int matIndex, const QString &texId)