forked from qt-creator/qt-creator
QmlDesigner: Allow dropping materials on User Assets
Fixes: QDS-14444 Change-Id: Ic3dd93709497cbb9c14eba2ff784ef00d9b975d7 Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
@@ -116,8 +116,8 @@ Item {
|
|||||||
onCountChanged: root.assignMaxCount()
|
onCountChanged: root.assignMaxCount()
|
||||||
|
|
||||||
onDropEnter: (drag) => {
|
onDropEnter: (drag) => {
|
||||||
drag.accepted = categoryTitle === "Textures"
|
drag.accepted = (categoryTitle === "Textures" && drag.formats[0] === "application/vnd.qtdesignstudio.assets")
|
||||||
&& drag.formats[0] === "application/vnd.qtdesignstudio.assets"
|
|| (categoryTitle === "Materials" && drag.formats[0] === "application/vnd.qtdesignstudio.material")
|
||||||
|
|
||||||
section.highlight = drag.accepted
|
section.highlight = drag.accepted
|
||||||
}
|
}
|
||||||
@@ -128,9 +128,13 @@ Item {
|
|||||||
|
|
||||||
onDrop: (drag) => {
|
onDrop: (drag) => {
|
||||||
section.highlight = false
|
section.highlight = false
|
||||||
ContentLibraryBackend.rootView.acceptTexturesDrop(drag.urls)
|
|
||||||
drag.accept()
|
drag.accept()
|
||||||
section.expandSection()
|
section.expandSection()
|
||||||
|
|
||||||
|
if (categoryTitle === "Textures")
|
||||||
|
ContentLibraryBackend.rootView.acceptTexturesDrop(drag.urls)
|
||||||
|
else if (categoryTitle === "Materials")
|
||||||
|
ContentLibraryBackend.rootView.acceptMaterialDrop(drag.getDataAsString(drag.formats[0]))
|
||||||
}
|
}
|
||||||
|
|
||||||
Grid {
|
Grid {
|
||||||
|
@@ -130,7 +130,6 @@ StudioControls.Menu {
|
|||||||
|
|
||||||
StudioControls.MenuItem {
|
StudioControls.MenuItem {
|
||||||
text: qsTr("Add to Content Library")
|
text: qsTr("Add to Content Library")
|
||||||
enabled: !materialBrowserModel.selectedMaterialIsComponent
|
|
||||||
|
|
||||||
onTriggered: MaterialBrowserBackend.rootView.addMaterialToContentLibrary()
|
onTriggered: MaterialBrowserBackend.rootView.addMaterialToContentLibrary()
|
||||||
}
|
}
|
||||||
|
@@ -100,6 +100,13 @@ WidgetInfo ContentLibraryView::widgetInfo()
|
|||||||
addLibAssets(paths);
|
addLibAssets(paths);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
connect(m_widget, &ContentLibraryWidget::acceptMaterialDrop, this,
|
||||||
|
[this](const QString &internalId) {
|
||||||
|
ModelNode matNode = QmlDesignerPlugin::instance()->viewManager()
|
||||||
|
.view()->modelNodeForInternalId(internalId.toInt());
|
||||||
|
addLibItem(matNode);
|
||||||
|
});
|
||||||
|
|
||||||
connect(m_widget,
|
connect(m_widget,
|
||||||
&ContentLibraryWidget::addTextureRequested,
|
&ContentLibraryWidget::addTextureRequested,
|
||||||
this,
|
this,
|
||||||
|
@@ -125,6 +125,7 @@ signals:
|
|||||||
void importBundle();
|
void importBundle();
|
||||||
void requestTab(int tabIndex);
|
void requestTab(int tabIndex);
|
||||||
void acceptTexturesDrop(const QList<QUrl> &urls);
|
void acceptTexturesDrop(const QList<QUrl> &urls);
|
||||||
|
void acceptMaterialDrop(const QString &internalId);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool eventFilter(QObject *obj, QEvent *event) override;
|
bool eventFilter(QObject *obj, QEvent *event) override;
|
||||||
|
Reference in New Issue
Block a user