Skip to content

Commit

Permalink
QmlDesigner: Prevent adding component materials to the content lib
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
mbadri-qt committed May 14, 2024
1 parent bfbcf88 commit f462be8
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,13 @@ Item {
width: parent.width
height: StudioTheme.Values.toolbarHeight

Component.onCompleted: {
var tabs = [
{ 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;
}
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 },
{ name: qsTr("User Assets"), icon: StudioTheme.Constants.effects } // TODO: update icon
]
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ class AssetsLibraryWidget : public QFrame

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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ class ContentLibraryWidget : public QFrame
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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#pragma once

#include "modelnode.h"
#include <modelnode.h>

#include <QAbstractListModel>
#include <QJsonObject>
Expand All @@ -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)
Expand Down Expand Up @@ -110,6 +111,7 @@ class MaterialBrowserModel : public QAbstractListModel
const QList<QmlDesigner::MaterialBrowserModel::PropertyCopyData> &props,
bool all);
void isQt6ProjectChanged();
void selectedMaterialIsComponentChanged();

private:
bool isValidIndex(int idx) const;
Expand All @@ -132,6 +134,7 @@ class MaterialBrowserModel : public QAbstractListModel
bool m_hasMaterialLibrary = false;
bool m_allPropsCopied = true;
bool m_isQt6Project = false;
bool m_selectedMaterialIsComponent = false;
QString m_copiedMaterialType;

QPointer<MaterialBrowserView> m_view;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ class MaterialBrowserWidget : public QFrame
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;

Expand Down

0 comments on commit f462be8

Please sign in to comment.