forked from qt-creator/qt-creator
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:
@@ -249,7 +249,7 @@ StudioControls.Menu {
|
|||||||
|
|
||||||
StudioControls.MenuItem {
|
StudioControls.MenuItem {
|
||||||
text: qsTr("Add to Content Library")
|
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
|
height: visible ? implicitHeight : 0
|
||||||
onTriggered: root.rootView.addAssetsToContentLibrary(root.__selectedAssetPathsList)
|
onTriggered: root.rootView.addAssetsToContentLibrary(root.__selectedAssetPathsList)
|
||||||
}
|
}
|
||||||
|
@@ -115,17 +115,13 @@ Item {
|
|||||||
width: parent.width
|
width: parent.width
|
||||||
height: StudioTheme.Values.toolbarHeight
|
height: StudioTheme.Values.toolbarHeight
|
||||||
|
|
||||||
Component.onCompleted: {
|
tabsModel: [
|
||||||
var tabs = [
|
{ name: qsTr("Materials"), icon: StudioTheme.Constants.material_medium },
|
||||||
{ name: qsTr("Materials"), icon: StudioTheme.Constants.material_medium },
|
{ name: qsTr("Textures"), icon: StudioTheme.Constants.textures_medium },
|
||||||
{ name: qsTr("Textures"), icon: StudioTheme.Constants.textures_medium },
|
{ name: qsTr("Environments"), icon: StudioTheme.Constants.languageList_medium },
|
||||||
{ name: qsTr("Environments"), icon: StudioTheme.Constants.languageList_medium },
|
{ name: qsTr("Effects"), icon: StudioTheme.Constants.effects },
|
||||||
{ name: qsTr("Effects"), icon: StudioTheme.Constants.effects }
|
{ name: qsTr("User Assets"), icon: StudioTheme.Constants.effects } // TODO: update icon
|
||||||
];
|
]
|
||||||
if (ContentLibraryBackend.rootView.userBundleEnabled())
|
|
||||||
tabs.push({ name: qsTr("User Assets"), icon: StudioTheme.Constants.effects });
|
|
||||||
tabBar.tabsModel = tabs;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -128,12 +128,10 @@ StudioControls.Menu {
|
|||||||
onTriggered: materialBrowserModel.addNewMaterial()
|
onTriggered: materialBrowserModel.addNewMaterial()
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
StudioControls.MenuItem {
|
||||||
if (MaterialBrowserBackend.rootView.userBundleEnabled()) {
|
text: qsTr("Add to Content Library")
|
||||||
var menuItem = Qt.createQmlObject("import StudioControls as StudioControls; StudioControls.MenuItem {}", root)
|
enabled: !materialBrowserModel.selectedMaterialIsComponent
|
||||||
menuItem.text = qsTr("Add to Content Library")
|
|
||||||
menuItem.onTriggered.connect(MaterialBrowserBackend.rootView.addMaterialToContentLibrary)
|
onTriggered: MaterialBrowserBackend.rootView.addMaterialToContentLibrary()
|
||||||
root.addItem(menuItem)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -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)
|
void AssetsLibraryWidget::addAssetsToContentLibrary(const QStringList &assetPaths)
|
||||||
{
|
{
|
||||||
m_assetsView->emitCustomNotification("add_assets_to_content_lib", {}, {assetPaths});
|
m_assetsView->emitCustomNotification("add_assets_to_content_lib", {}, {assetPaths});
|
||||||
|
@@ -100,7 +100,6 @@ public:
|
|||||||
|
|
||||||
Q_INVOKABLE void showInGraphicalShell(const QString &path);
|
Q_INVOKABLE void showInGraphicalShell(const QString &path);
|
||||||
Q_INVOKABLE QString showInGraphicalShellMsg() const;
|
Q_INVOKABLE QString showInGraphicalShellMsg() const;
|
||||||
Q_INVOKABLE bool userBundleEnabled() const;
|
|
||||||
Q_INVOKABLE void addAssetsToContentLibrary(const QStringList &assetPaths);
|
Q_INVOKABLE void addAssetsToContentLibrary(const QStringList &assetPaths);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
@@ -640,12 +640,6 @@ void ContentLibraryWidget::markTextureUpdated(const QString &textureKey)
|
|||||||
m_environmentsModel->markTextureHasNoUpdates(subcategory, 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
|
QSize ContentLibraryWidget::sizeHint() const
|
||||||
{
|
{
|
||||||
return {420, 420};
|
return {420, 420};
|
||||||
|
@@ -90,7 +90,6 @@ public:
|
|||||||
Q_INVOKABLE void addLightProbe(QmlDesigner::ContentLibraryTexture *tex);
|
Q_INVOKABLE void addLightProbe(QmlDesigner::ContentLibraryTexture *tex);
|
||||||
Q_INVOKABLE void updateSceneEnvState();
|
Q_INVOKABLE void updateSceneEnvState();
|
||||||
Q_INVOKABLE void markTextureUpdated(const QString &textureKey);
|
Q_INVOKABLE void markTextureUpdated(const QString &textureKey);
|
||||||
Q_INVOKABLE bool userBundleEnabled() const;
|
|
||||||
|
|
||||||
QSize sizeHint() const override;
|
QSize sizeHint() const override;
|
||||||
|
|
||||||
|
@@ -366,6 +366,9 @@ void MaterialBrowserModel::selectMaterial(int idx, bool force)
|
|||||||
if (idx != m_selectedIndex || force) {
|
if (idx != m_selectedIndex || force) {
|
||||||
m_selectedIndex = idx;
|
m_selectedIndex = idx;
|
||||||
emit selectedIndexChanged(idx);
|
emit selectedIndexChanged(idx);
|
||||||
|
|
||||||
|
m_selectedMaterialIsComponent = selectedMaterial().isComponent();
|
||||||
|
emit selectedMaterialIsComponentChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "modelnode.h"
|
#include <modelnode.h>
|
||||||
|
|
||||||
#include <QAbstractListModel>
|
#include <QAbstractListModel>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
@@ -20,6 +20,7 @@ class MaterialBrowserModel : public QAbstractListModel
|
|||||||
|
|
||||||
Q_PROPERTY(bool isEmpty MEMBER m_isEmpty NOTIFY isEmptyChanged)
|
Q_PROPERTY(bool isEmpty MEMBER m_isEmpty NOTIFY isEmptyChanged)
|
||||||
Q_PROPERTY(int selectedIndex MEMBER m_selectedIndex NOTIFY selectedIndexChanged)
|
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 hasQuick3DImport READ hasQuick3DImport WRITE setHasQuick3DImport NOTIFY hasQuick3DImportChanged)
|
||||||
Q_PROPERTY(bool hasModelSelection READ hasModelSelection WRITE setHasModelSelection NOTIFY hasModelSelectionChanged)
|
Q_PROPERTY(bool hasModelSelection READ hasModelSelection WRITE setHasModelSelection NOTIFY hasModelSelectionChanged)
|
||||||
Q_PROPERTY(bool hasMaterialLibrary READ hasMaterialLibrary WRITE setHasMaterialLibrary NOTIFY hasMaterialLibraryChanged)
|
Q_PROPERTY(bool hasMaterialLibrary READ hasMaterialLibrary WRITE setHasMaterialLibrary NOTIFY hasMaterialLibraryChanged)
|
||||||
@@ -110,6 +111,7 @@ signals:
|
|||||||
const QList<QmlDesigner::MaterialBrowserModel::PropertyCopyData> &props,
|
const QList<QmlDesigner::MaterialBrowserModel::PropertyCopyData> &props,
|
||||||
bool all);
|
bool all);
|
||||||
void isQt6ProjectChanged();
|
void isQt6ProjectChanged();
|
||||||
|
void selectedMaterialIsComponentChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool isValidIndex(int idx) const;
|
bool isValidIndex(int idx) const;
|
||||||
@@ -132,6 +134,7 @@ private:
|
|||||||
bool m_hasMaterialLibrary = false;
|
bool m_hasMaterialLibrary = false;
|
||||||
bool m_allPropsCopied = true;
|
bool m_allPropsCopied = true;
|
||||||
bool m_isQt6Project = false;
|
bool m_isQt6Project = false;
|
||||||
|
bool m_selectedMaterialIsComponent = false;
|
||||||
QString m_copiedMaterialType;
|
QString m_copiedMaterialType;
|
||||||
|
|
||||||
QPointer<MaterialBrowserView> m_view;
|
QPointer<MaterialBrowserView> m_view;
|
||||||
|
@@ -434,10 +434,4 @@ QPointer<MaterialBrowserTexturesModel> MaterialBrowserWidget::materialBrowserTex
|
|||||||
return m_materialBrowserTexturesModel;
|
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
|
} // namespace QmlDesigner
|
||||||
|
@@ -63,7 +63,6 @@ public:
|
|||||||
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();
|
Q_INVOKABLE void addMaterialToContentLibrary();
|
||||||
Q_INVOKABLE bool userBundleEnabled() const;
|
|
||||||
|
|
||||||
StudioQuickWidget *quickWidget() const;
|
StudioQuickWidget *quickWidget() const;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user