forked from qt-creator/qt-creator
QmlDesigner: Add 'import' action to material browser context menu
Change-Id: I68577899841d8884d96446c762e7d228a1b03dc5 Reviewed-by: Shrief Gabr <shrief.gabr@qt.io> Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
This commit is contained in:
@@ -135,6 +135,12 @@ StudioControls.Menu {
|
||||
onTriggered: MaterialBrowserBackend.rootView.addMaterialToContentLibrary()
|
||||
}
|
||||
|
||||
StudioControls.MenuItem {
|
||||
text: qsTr("Import Material")
|
||||
|
||||
onTriggered: MaterialBrowserBackend.rootView.importMaterial()
|
||||
}
|
||||
|
||||
StudioControls.MenuItem {
|
||||
text: qsTr("Export Material")
|
||||
enabled: !materialBrowserModel.selectedMaterialIsComponent // TODO: support component materials
|
||||
|
@@ -388,7 +388,7 @@ void ContentLibraryView::customNotification(const AbstractView *view,
|
||||
exportLib3DItem(nodeList.first());
|
||||
} else if (identifier == "export_material_as_bundle") {
|
||||
exportLib3DItem(nodeList.first(), data.first().value<QPixmap>());
|
||||
} else if (identifier == "import_bundle_to_3d_scene") {
|
||||
} else if (identifier == "import_bundle") {
|
||||
importBundle();
|
||||
}
|
||||
}
|
||||
|
@@ -373,7 +373,7 @@ void Edit3DWidget::createContextMenu()
|
||||
m_importBundleAction = m_contextMenu->addAction(
|
||||
contextIcon(DesignerIcons::CreateIcon), // TODO: placeholder icon
|
||||
tr("Import Components"), [&] {
|
||||
view()->emitCustomNotification("import_bundle_to_3d_scene", {m_contextMenuTarget}); // To ContentLibrary
|
||||
view()->emitCustomNotification("import_bundle"); // To ContentLibrary
|
||||
});
|
||||
|
||||
m_exportBundleAction = m_contextMenu->addAction(
|
||||
|
@@ -371,6 +371,11 @@ void MaterialBrowserWidget::addMaterialToContentLibrary()
|
||||
{m_previewImageProvider->getPixmap(mat)}); // to ContentLibrary
|
||||
}
|
||||
|
||||
void MaterialBrowserWidget::importMaterial()
|
||||
{
|
||||
ModelNode mat = m_materialBrowserModel->selectedMaterial();
|
||||
m_materialBrowserView->emitCustomNotification("import_bundle"); // to ContentLibrary
|
||||
}
|
||||
void MaterialBrowserWidget::exportMaterial()
|
||||
{
|
||||
ModelNode mat = m_materialBrowserModel->selectedMaterial();
|
||||
|
@@ -63,6 +63,7 @@ public:
|
||||
Q_INVOKABLE void acceptTextureDropOnMaterial(int matIndex, const QString &texId);
|
||||
Q_INVOKABLE void focusMaterialSection(bool focusMatSec);
|
||||
Q_INVOKABLE void addMaterialToContentLibrary();
|
||||
Q_INVOKABLE void importMaterial();
|
||||
Q_INVOKABLE void exportMaterial();
|
||||
|
||||
StudioQuickWidget *quickWidget() const;
|
||||
|
Reference in New Issue
Block a user