QmlDesigner: Prevent adding component materials to the content lib

Also remove the experimental restriction on the content lib user section

Fixes: QDS-12637
Change-Id: Ice2ac3f32a934d7c65ea7f406a2b5f8c4b5fed0c
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
This commit is contained in:
Mahmoud Badri
2024-05-14 16:35:11 +03:00
parent bfbcf88161
commit f462be8e80
11 changed files with 20 additions and 41 deletions

View File

@@ -249,7 +249,7 @@ StudioControls.Menu {
StudioControls.MenuItem {
text: qsTr("Add to Content Library")
visible: root.rootView.userBundleEnabled() && root.__fileIndex && root.assetsModel.allFilePathsAreTextures(root.__selectedAssetPathsList)
visible: root.__fileIndex && root.assetsModel.allFilePathsAreTextures(root.__selectedAssetPathsList)
height: visible ? implicitHeight : 0
onTriggered: root.rootView.addAssetsToContentLibrary(root.__selectedAssetPathsList)
}

View File

@@ -115,17 +115,13 @@ Item {
width: parent.width
height: StudioTheme.Values.toolbarHeight
Component.onCompleted: {
var tabs = [
tabsModel: [
{ name: qsTr("Materials"), icon: StudioTheme.Constants.material_medium },
{ name: qsTr("Textures"), icon: StudioTheme.Constants.textures_medium },
{ name: qsTr("Environments"), icon: StudioTheme.Constants.languageList_medium },
{ name: qsTr("Effects"), icon: StudioTheme.Constants.effects }
];
if (ContentLibraryBackend.rootView.userBundleEnabled())
tabs.push({ name: qsTr("User Assets"), icon: StudioTheme.Constants.effects });
tabBar.tabsModel = tabs;
}
{ name: qsTr("Effects"), icon: StudioTheme.Constants.effects },
{ name: qsTr("User Assets"), icon: StudioTheme.Constants.effects } // TODO: update icon
]
}
}
}

View File

@@ -128,12 +128,10 @@ StudioControls.Menu {
onTriggered: materialBrowserModel.addNewMaterial()
}
Component.onCompleted: {
if (MaterialBrowserBackend.rootView.userBundleEnabled()) {
var menuItem = Qt.createQmlObject("import StudioControls as StudioControls; StudioControls.MenuItem {}", root)
menuItem.text = qsTr("Add to Content Library")
menuItem.onTriggered.connect(MaterialBrowserBackend.rootView.addMaterialToContentLibrary)
root.addItem(menuItem)
}
StudioControls.MenuItem {
text: qsTr("Add to Content Library")
enabled: !materialBrowserModel.selectedMaterialIsComponent
onTriggered: MaterialBrowserBackend.rootView.addMaterialToContentLibrary()
}
}

View File

@@ -635,12 +635,6 @@ void AssetsLibraryWidget::addResources(const QStringList &files, bool showDialog
}
}
bool AssetsLibraryWidget::userBundleEnabled() const
{
// TODO: this method is to be removed after user bundle implementation is complete
return Core::ICore::settings()->value("QML/Designer/UseExperimentalFeatures45", false).toBool();
}
void AssetsLibraryWidget::addAssetsToContentLibrary(const QStringList &assetPaths)
{
m_assetsView->emitCustomNotification("add_assets_to_content_lib", {}, {assetPaths});

View File

@@ -100,7 +100,6 @@ public:
Q_INVOKABLE void showInGraphicalShell(const QString &path);
Q_INVOKABLE QString showInGraphicalShellMsg() const;
Q_INVOKABLE bool userBundleEnabled() const;
Q_INVOKABLE void addAssetsToContentLibrary(const QStringList &assetPaths);
signals:

View File

@@ -640,12 +640,6 @@ void ContentLibraryWidget::markTextureUpdated(const QString &textureKey)
m_environmentsModel->markTextureHasNoUpdates(subcategory, textureKey);
}
bool ContentLibraryWidget::userBundleEnabled() const
{
// TODO: this method is to be removed after user bundle implementation is complete
return Core::ICore::settings()->value("QML/Designer/UseExperimentalFeatures45", false).toBool();
}
QSize ContentLibraryWidget::sizeHint() const
{
return {420, 420};

View File

@@ -90,7 +90,6 @@ public:
Q_INVOKABLE void addLightProbe(QmlDesigner::ContentLibraryTexture *tex);
Q_INVOKABLE void updateSceneEnvState();
Q_INVOKABLE void markTextureUpdated(const QString &textureKey);
Q_INVOKABLE bool userBundleEnabled() const;
QSize sizeHint() const override;

View File

@@ -366,6 +366,9 @@ void MaterialBrowserModel::selectMaterial(int idx, bool force)
if (idx != m_selectedIndex || force) {
m_selectedIndex = idx;
emit selectedIndexChanged(idx);
m_selectedMaterialIsComponent = selectedMaterial().isComponent();
emit selectedMaterialIsComponentChanged();
}
}

View File

@@ -3,7 +3,7 @@
#pragma once
#include "modelnode.h"
#include <modelnode.h>
#include <QAbstractListModel>
#include <QJsonObject>
@@ -20,6 +20,7 @@ class MaterialBrowserModel : public QAbstractListModel
Q_PROPERTY(bool isEmpty MEMBER m_isEmpty NOTIFY isEmptyChanged)
Q_PROPERTY(int selectedIndex MEMBER m_selectedIndex NOTIFY selectedIndexChanged)
Q_PROPERTY(bool selectedMaterialIsComponent MEMBER m_selectedMaterialIsComponent NOTIFY selectedMaterialIsComponentChanged)
Q_PROPERTY(bool hasQuick3DImport READ hasQuick3DImport WRITE setHasQuick3DImport NOTIFY hasQuick3DImportChanged)
Q_PROPERTY(bool hasModelSelection READ hasModelSelection WRITE setHasModelSelection NOTIFY hasModelSelectionChanged)
Q_PROPERTY(bool hasMaterialLibrary READ hasMaterialLibrary WRITE setHasMaterialLibrary NOTIFY hasMaterialLibraryChanged)
@@ -110,6 +111,7 @@ signals:
const QList<QmlDesigner::MaterialBrowserModel::PropertyCopyData> &props,
bool all);
void isQt6ProjectChanged();
void selectedMaterialIsComponentChanged();
private:
bool isValidIndex(int idx) const;
@@ -132,6 +134,7 @@ private:
bool m_hasMaterialLibrary = false;
bool m_allPropsCopied = true;
bool m_isQt6Project = false;
bool m_selectedMaterialIsComponent = false;
QString m_copiedMaterialType;
QPointer<MaterialBrowserView> m_view;

View File

@@ -434,10 +434,4 @@ QPointer<MaterialBrowserTexturesModel> MaterialBrowserWidget::materialBrowserTex
return m_materialBrowserTexturesModel;
}
bool MaterialBrowserWidget::userBundleEnabled() const
{
// TODO: this method is to be removed after user bundle implementation is complete
return Core::ICore::settings()->value("QML/Designer/UseExperimentalFeatures45", false).toBool();
}
} // namespace QmlDesigner

View File

@@ -63,7 +63,6 @@ public:
Q_INVOKABLE void acceptTextureDropOnMaterial(int matIndex, const QString &texId);
Q_INVOKABLE void focusMaterialSection(bool focusMatSec);
Q_INVOKABLE void addMaterialToContentLibrary();
Q_INVOKABLE bool userBundleEnabled() const;
StudioQuickWidget *quickWidget() const;