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()
|
||||
|
||||
onDropEnter: (drag) => {
|
||||
drag.accepted = categoryTitle === "Textures"
|
||||
&& drag.formats[0] === "application/vnd.qtdesignstudio.assets"
|
||||
drag.accepted = (categoryTitle === "Textures" && drag.formats[0] === "application/vnd.qtdesignstudio.assets")
|
||||
|| (categoryTitle === "Materials" && drag.formats[0] === "application/vnd.qtdesignstudio.material")
|
||||
|
||||
section.highlight = drag.accepted
|
||||
}
|
||||
@@ -128,9 +128,13 @@ Item {
|
||||
|
||||
onDrop: (drag) => {
|
||||
section.highlight = false
|
||||
ContentLibraryBackend.rootView.acceptTexturesDrop(drag.urls)
|
||||
drag.accept()
|
||||
section.expandSection()
|
||||
|
||||
if (categoryTitle === "Textures")
|
||||
ContentLibraryBackend.rootView.acceptTexturesDrop(drag.urls)
|
||||
else if (categoryTitle === "Materials")
|
||||
ContentLibraryBackend.rootView.acceptMaterialDrop(drag.getDataAsString(drag.formats[0]))
|
||||
}
|
||||
|
||||
Grid {
|
||||
|
@@ -130,7 +130,6 @@ StudioControls.Menu {
|
||||
|
||||
StudioControls.MenuItem {
|
||||
text: qsTr("Add to Content Library")
|
||||
enabled: !materialBrowserModel.selectedMaterialIsComponent
|
||||
|
||||
onTriggered: MaterialBrowserBackend.rootView.addMaterialToContentLibrary()
|
||||
}
|
||||
|
@@ -100,6 +100,13 @@ WidgetInfo ContentLibraryView::widgetInfo()
|
||||
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,
|
||||
&ContentLibraryWidget::addTextureRequested,
|
||||
this,
|
||||
|
@@ -125,6 +125,7 @@ signals:
|
||||
void importBundle();
|
||||
void requestTab(int tabIndex);
|
||||
void acceptTexturesDrop(const QList<QUrl> &urls);
|
||||
void acceptMaterialDrop(const QString &internalId);
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *obj, QEvent *event) override;
|
||||
|
Reference in New Issue
Block a user