forked from qt-creator/qt-creator
QmlDesigner: Fix adding material to user assets
Use material index as parameter like other similar functions, as it doesn't rely on being able to interpret QQmlDMAbstractItemModelData as ModelNode, which doesn't appear to work anymore with project storage builds. Also fix typo in a related warning. Fixes: QDS-14993 Change-Id: I41c9895352272c7134c2e00888558a66676f8f83 Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
@@ -138,8 +138,9 @@ StudioControls.Menu {
|
|||||||
|
|
||||||
StudioControls.MenuItem {
|
StudioControls.MenuItem {
|
||||||
text: qsTr("Add to Content Library")
|
text: qsTr("Add to Content Library")
|
||||||
|
enabled: root.targetMaterial
|
||||||
|
|
||||||
onTriggered: MaterialBrowserBackend.rootView.addMaterialToContentLibrary(root.targetMaterial)
|
onTriggered: MaterialBrowserBackend.rootView.addMaterialToContentLibrary(root.targetIndex)
|
||||||
}
|
}
|
||||||
|
|
||||||
StudioControls.MenuItem {
|
StudioControls.MenuItem {
|
||||||
|
@@ -720,7 +720,7 @@ void ContentLibraryView::addLibItem(const ModelNode &node, const QPixmap &iconPi
|
|||||||
bundlePath = Utils::FilePath::fromString(Paths::bundlesPathSetting() + "/User/3d/");
|
bundlePath = Utils::FilePath::fromString(Paths::bundlesPathSetting() + "/User/3d/");
|
||||||
m_bundleId = compUtils.user3DBundleId();
|
m_bundleId = compUtils.user3DBundleId();
|
||||||
} else {
|
} else {
|
||||||
qWarning() << __FUNCTION__ << "Unsuppported node type";
|
qWarning() << __FUNCTION__ << "Unsupported node type";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -371,10 +371,12 @@ void MaterialBrowserWidget::focusMaterialSection(bool focusMatSec)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaterialBrowserWidget::addMaterialToContentLibrary(const QVariant &material)
|
void MaterialBrowserWidget::addMaterialToContentLibrary(int idx)
|
||||||
{
|
{
|
||||||
|
ModelNode mat = m_materialBrowserModel->materialAt(idx);
|
||||||
|
QTC_ASSERT(mat, return);
|
||||||
|
|
||||||
QmlDesignerPlugin::instance()->mainWidget()->showDockWidget("ContentLibrary");
|
QmlDesignerPlugin::instance()->mainWidget()->showDockWidget("ContentLibrary");
|
||||||
ModelNode mat = material.value<ModelNode>();
|
|
||||||
m_materialBrowserView->emitCustomNotification("add_material_to_content_lib", {mat},
|
m_materialBrowserView->emitCustomNotification("add_material_to_content_lib", {mat},
|
||||||
{m_previewImageProvider->getPixmap(mat)}); // to ContentLibrary
|
{m_previewImageProvider->getPixmap(mat)}); // to ContentLibrary
|
||||||
}
|
}
|
||||||
|
@@ -63,7 +63,7 @@ public:
|
|||||||
Q_INVOKABLE void acceptAssetsDropOnMaterial(int matIndex, const QList<QUrl> &urls);
|
Q_INVOKABLE void acceptAssetsDropOnMaterial(int matIndex, const QList<QUrl> &urls);
|
||||||
Q_INVOKABLE void acceptTextureDropOnMaterial(int matIndex, const QString &texId);
|
Q_INVOKABLE void acceptTextureDropOnMaterial(int matIndex, const QString &texId);
|
||||||
Q_INVOKABLE void focusMaterialSection(bool focusMatSec);
|
Q_INVOKABLE void focusMaterialSection(bool focusMatSec);
|
||||||
Q_INVOKABLE void addMaterialToContentLibrary(const QVariant &material);
|
Q_INVOKABLE void addMaterialToContentLibrary(int idx);
|
||||||
Q_INVOKABLE void importMaterial();
|
Q_INVOKABLE void importMaterial();
|
||||||
Q_INVOKABLE void exportMaterial(int idx);
|
Q_INVOKABLE void exportMaterial(int idx);
|
||||||
Q_INVOKABLE void addQtQuick3D();
|
Q_INVOKABLE void addQtQuick3D();
|
||||||
|
Reference in New Issue
Block a user