forked from qt-creator/qt-creator
QmlDesigner: Add scene root material support to material editor/browser
If the scene root item is Material subclass, material library is not created for the scene. Material editor and browser functionalities that relate to having material library are disabled. Material editor will always show the material that is the scene root. Fixes: QDS-7374 Change-Id: Icd1c212c17b59e4a2caa6b3b4d7e615e68b21eb9 Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
@@ -342,24 +342,14 @@ void Qt5InformationNodeInstanceServer::resolveImportSupport()
|
||||
void Qt5InformationNodeInstanceServer::updateMaterialPreviewData(const QVector<PropertyValueContainer> &valueChanges)
|
||||
{
|
||||
const PropertyName matPrevPrefix("matPrev");
|
||||
qint32 materialLibraryId = -1;
|
||||
for (const auto &container : valueChanges) {
|
||||
if (container.name().startsWith(matPrevPrefix)) {
|
||||
if (!hasInstanceForId(container.instanceId()))
|
||||
continue;
|
||||
if (materialLibraryId < 0) {
|
||||
ServerNodeInstance instance = instanceForId(container.instanceId());
|
||||
if (instance.id() == "__materialLibrary__")
|
||||
materialLibraryId = container.instanceId();
|
||||
}
|
||||
if (container.instanceId() == materialLibraryId) {
|
||||
if (container.name() == "matPrevEnv")
|
||||
m_materialPreviewData.env = container.value().toString();
|
||||
else if (container.name() == "matPrevEnvValue")
|
||||
m_materialPreviewData.envValue = container.value().toString();
|
||||
else if (container.name() == "matPrevModel")
|
||||
m_materialPreviewData.model = container.value().toString();
|
||||
}
|
||||
if (container.instanceId() == 0) {
|
||||
if (container.name() == "matPrevEnv")
|
||||
m_materialPreviewData.env = container.value().toString();
|
||||
else if (container.name() == "matPrevEnvValue")
|
||||
m_materialPreviewData.envValue = container.value().toString();
|
||||
else if (container.name() == "matPrevModel")
|
||||
m_materialPreviewData.model = container.value().toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -67,8 +67,10 @@ Item {
|
||||
acceptedButtons: Qt.RightButton
|
||||
|
||||
onClicked: {
|
||||
root.currentMaterial = null
|
||||
contextMenu.popup()
|
||||
if (!materialBrowserModel.hasMaterialRoot) {
|
||||
root.currentMaterial = null
|
||||
contextMenu.popup()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,6 +164,7 @@ Item {
|
||||
|
||||
Row {
|
||||
width: root.width
|
||||
enabled: !materialBrowserModel.hasMaterialRoot && materialBrowserModel.hasQuick3DImport
|
||||
|
||||
SearchBox {
|
||||
id: searchBox
|
||||
@@ -186,22 +189,22 @@ Item {
|
||||
color: StudioTheme.Values.themeTextColor
|
||||
font.pixelSize: StudioTheme.Values.baseFontSize
|
||||
leftPadding: 10
|
||||
visible: materialBrowserModel.hasQuick3DImport && materialBrowserModel.isEmpty && !searchBox.isEmpty()
|
||||
visible: materialBrowserModel.hasQuick3DImport && materialBrowserModel.isEmpty
|
||||
&& !searchBox.isEmpty() && !materialBrowserModel.hasMaterialRoot
|
||||
}
|
||||
|
||||
Text {
|
||||
text: qsTr("There are no materials in this project.<br>Select '<b>+</b>' to create one.")
|
||||
textFormat: Text.RichText
|
||||
color: StudioTheme.Values.themeTextColor
|
||||
font.pixelSize: StudioTheme.Values.mediumFontSize
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
topPadding: 30
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
visible: materialBrowserModel.hasQuick3DImport && materialBrowserModel.isEmpty && searchBox.isEmpty()
|
||||
}
|
||||
text: {
|
||||
if (materialBrowserModel.hasMaterialRoot)
|
||||
qsTr("<b>Material Browser</b> is disabled inside a material component.")
|
||||
else if (!materialBrowserModel.hasQuick3DImport)
|
||||
qsTr("To use <b>Material Browser</b>, first add the QtQuick3D module in the <b>Components</b> view.")
|
||||
else if (materialBrowserModel.isEmpty && searchBox.isEmpty())
|
||||
qsTr("There are no materials in this project.<br>Select '<b>+</b>' to create one.")
|
||||
else
|
||||
""
|
||||
}
|
||||
|
||||
Text {
|
||||
text: qsTr("To use <b>Material Browser</b>, first add the QtQuick3D module in the <b>Components</b> view.");
|
||||
textFormat: Text.RichText
|
||||
color: StudioTheme.Values.themeTextColor
|
||||
font.pixelSize: StudioTheme.Values.mediumFontSize
|
||||
@@ -209,8 +212,7 @@ Item {
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
wrapMode: Text.WordWrap
|
||||
width: root.width
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
visible: !materialBrowserModel.hasQuick3DImport
|
||||
visible: text !== ""
|
||||
}
|
||||
|
||||
ScrollView {
|
||||
|
@@ -50,7 +50,7 @@ Rectangle {
|
||||
normalColor: StudioTheme.Values.themeSectionHeadBackground
|
||||
iconSize: StudioTheme.Values.bigIconFontSize
|
||||
buttonSize: root.height
|
||||
enabled: hasMaterial && hasModelSelection && hasQuick3DImport
|
||||
enabled: hasMaterial && hasModelSelection && hasQuick3DImport && !hasMaterialRoot
|
||||
onClicked: root.toolBarAction(ToolBarAction.ApplyToSelected)
|
||||
tooltip: qsTr("Apply material to selected model.")
|
||||
}
|
||||
@@ -61,7 +61,7 @@ Rectangle {
|
||||
normalColor: StudioTheme.Values.themeSectionHeadBackground
|
||||
iconSize: StudioTheme.Values.bigIconFontSize
|
||||
buttonSize: root.height
|
||||
enabled: hasQuick3DImport
|
||||
enabled: hasQuick3DImport && !hasMaterialRoot
|
||||
onClicked: root.toolBarAction(ToolBarAction.AddNewMaterial)
|
||||
tooltip: qsTr("Create new material.")
|
||||
}
|
||||
@@ -72,7 +72,7 @@ Rectangle {
|
||||
normalColor: StudioTheme.Values.themeSectionHeadBackground
|
||||
iconSize: StudioTheme.Values.bigIconFontSize
|
||||
buttonSize: root.height
|
||||
enabled: hasMaterial && hasQuick3DImport
|
||||
enabled: hasMaterial && hasQuick3DImport && !hasMaterialRoot
|
||||
onClicked: root.toolBarAction(ToolBarAction.DeleteCurrentMaterial)
|
||||
tooltip: qsTr("Delete current material.")
|
||||
}
|
||||
@@ -83,7 +83,7 @@ Rectangle {
|
||||
normalColor: StudioTheme.Values.themeSectionHeadBackground
|
||||
iconSize: StudioTheme.Values.bigIconFontSize
|
||||
buttonSize: root.height
|
||||
enabled: hasMaterial && hasQuick3DImport
|
||||
enabled: hasMaterial && hasQuick3DImport && !hasMaterialRoot
|
||||
onClicked: root.toolBarAction(ToolBarAction.OpenMaterialBrowser)
|
||||
tooltip: qsTr("Open material browser.")
|
||||
}
|
||||
|
@@ -136,7 +136,7 @@ Item {
|
||||
},
|
||||
State {
|
||||
name: "hover"
|
||||
when: searchFilterText.hovered && !searchFilterText.activeFocus
|
||||
when: root.enabled && searchFilterText.hovered && !searchFilterText.activeFocus
|
||||
PropertyChanges {
|
||||
target: textFieldBackground
|
||||
color: StudioTheme.Values.themeControlBackgroundHover
|
||||
|
@@ -124,6 +124,20 @@ void MaterialBrowserModel::setHasModelSelection(bool b)
|
||||
emit hasModelSelectionChanged();
|
||||
}
|
||||
|
||||
bool MaterialBrowserModel::hasMaterialRoot() const
|
||||
{
|
||||
return m_hasMaterialRoot;
|
||||
}
|
||||
|
||||
void MaterialBrowserModel::setHasMaterialRoot(bool b)
|
||||
{
|
||||
if (m_hasMaterialRoot == b)
|
||||
return;
|
||||
|
||||
m_hasMaterialRoot = b;
|
||||
emit hasMaterialRootChanged();
|
||||
}
|
||||
|
||||
TypeName MaterialBrowserModel::copiedMaterialType() const
|
||||
{
|
||||
return m_copiedMaterialType;
|
||||
|
@@ -42,6 +42,7 @@ class MaterialBrowserModel : public QAbstractListModel
|
||||
Q_PROPERTY(int selectedIndex MEMBER m_selectedIndex NOTIFY selectedIndexChanged)
|
||||
Q_PROPERTY(bool hasQuick3DImport READ hasQuick3DImport WRITE setHasQuick3DImport NOTIFY hasQuick3DImportChanged)
|
||||
Q_PROPERTY(bool hasModelSelection READ hasModelSelection WRITE setHasModelSelection NOTIFY hasModelSelectionChanged)
|
||||
Q_PROPERTY(bool hasMaterialRoot READ hasMaterialRoot WRITE setHasMaterialRoot NOTIFY hasMaterialRootChanged)
|
||||
Q_PROPERTY(TypeName copiedMaterialType READ copiedMaterialType WRITE setCopiedMaterialType NOTIFY copiedMaterialTypeChanged)
|
||||
|
||||
public:
|
||||
@@ -60,6 +61,9 @@ public:
|
||||
bool hasModelSelection() const;
|
||||
void setHasModelSelection(bool b);
|
||||
|
||||
bool hasMaterialRoot() const;
|
||||
void setHasMaterialRoot(bool b);
|
||||
|
||||
TypeName copiedMaterialType() const;
|
||||
void setCopiedMaterialType(const TypeName &matType);
|
||||
|
||||
@@ -88,6 +92,7 @@ signals:
|
||||
void isEmptyChanged();
|
||||
void hasQuick3DImportChanged();
|
||||
void hasModelSelectionChanged();
|
||||
void hasMaterialRootChanged();
|
||||
void copiedMaterialTypeChanged();
|
||||
void selectedIndexChanged(int idx);
|
||||
void renameMaterialTriggered(const QmlDesigner::ModelNode &material, const QString &newName);
|
||||
@@ -110,6 +115,7 @@ private:
|
||||
bool m_isEmpty = true;
|
||||
bool m_hasQuick3DImport = false;
|
||||
bool m_hasModelSelection = false;
|
||||
bool m_hasMaterialRoot = false;
|
||||
TypeName m_copiedMaterialType;
|
||||
};
|
||||
|
||||
|
@@ -127,6 +127,7 @@ void MaterialBrowserView::modelAttached(Model *model)
|
||||
AbstractView::modelAttached(model);
|
||||
|
||||
m_widget->clearSearchFilter();
|
||||
m_widget->materialBrowserModel()->setHasMaterialRoot(rootModelNode().isSubclassOf("QtQuick3D.Material"));
|
||||
m_hasQuick3DImport = model->hasImport("QtQuick3D");
|
||||
|
||||
// Project load is already very busy and may even trigger puppet reset, so let's wait a moment
|
||||
|
@@ -233,6 +233,20 @@ void MaterialEditorContextObject::setHasQuick3DImport(bool b)
|
||||
emit hasQuick3DImportChanged();
|
||||
}
|
||||
|
||||
bool MaterialEditorContextObject::hasMaterialRoot() const
|
||||
{
|
||||
return m_hasMaterialRoot;
|
||||
}
|
||||
|
||||
void MaterialEditorContextObject::setHasMaterialRoot(bool b)
|
||||
{
|
||||
if (b == m_hasMaterialRoot)
|
||||
return;
|
||||
|
||||
m_hasMaterialRoot = b;
|
||||
emit hasMaterialRootChanged();
|
||||
}
|
||||
|
||||
bool MaterialEditorContextObject::hasModelSelection() const
|
||||
{
|
||||
return m_hasModelSelection;
|
||||
|
@@ -56,6 +56,7 @@ class MaterialEditorContextObject : public QObject
|
||||
Q_PROPERTY(bool hasActiveTimeline READ hasActiveTimeline NOTIFY hasActiveTimelineChanged)
|
||||
Q_PROPERTY(bool hasQuick3DImport READ hasQuick3DImport WRITE setHasQuick3DImport NOTIFY hasQuick3DImportChanged)
|
||||
Q_PROPERTY(bool hasModelSelection READ hasModelSelection WRITE setHasModelSelection NOTIFY hasModelSelectionChanged)
|
||||
Q_PROPERTY(bool hasMaterialRoot READ hasMaterialRoot WRITE setHasMaterialRoot NOTIFY hasMaterialRootChanged)
|
||||
|
||||
Q_PROPERTY(QQmlPropertyMap *backendValues READ backendValues WRITE setBackendValues NOTIFY backendValuesChanged)
|
||||
|
||||
@@ -105,6 +106,9 @@ public:
|
||||
bool hasQuick3DImport() const;
|
||||
void setHasQuick3DImport(bool b);
|
||||
|
||||
bool hasMaterialRoot() const;
|
||||
void setHasMaterialRoot(bool b);
|
||||
|
||||
bool hasModelSelection() const;
|
||||
void setHasModelSelection(bool b);
|
||||
|
||||
@@ -134,6 +138,7 @@ signals:
|
||||
void hasAliasExportChanged();
|
||||
void hasActiveTimelineChanged();
|
||||
void hasQuick3DImportChanged();
|
||||
void hasMaterialRootChanged();
|
||||
void hasModelSelectionChanged();
|
||||
|
||||
private:
|
||||
@@ -155,6 +160,7 @@ private:
|
||||
bool m_aliasExport = false;
|
||||
bool m_hasActiveTimeline = false;
|
||||
bool m_hasQuick3DImport = false;
|
||||
bool m_hasMaterialRoot = false;
|
||||
bool m_hasModelSelection = false;
|
||||
|
||||
ModelNode m_selectedMaterial;
|
||||
|
@@ -420,12 +420,15 @@ void MaterialEditorView::handleToolBarAction(int action)
|
||||
if (!model())
|
||||
break;
|
||||
executeInTransaction("MaterialEditorView:handleToolBarAction", [&] {
|
||||
ModelNode matLib = materialLibraryNode();
|
||||
if (!matLib.isValid())
|
||||
return;
|
||||
|
||||
NodeMetaInfo metaInfo = model()->metaInfo("QtQuick3D.DefaultMaterial");
|
||||
ModelNode newMatNode = createModelNode("QtQuick3D.DefaultMaterial", metaInfo.majorVersion(),
|
||||
metaInfo.minorVersion());
|
||||
renameMaterial(newMatNode, "New Material");
|
||||
|
||||
materialLibraryNode().defaultNodeListProperty().reparentHere(newMatNode);
|
||||
matLib.defaultNodeListProperty().reparentHere(newMatNode);
|
||||
});
|
||||
break;
|
||||
}
|
||||
@@ -462,10 +465,8 @@ void MaterialEditorView::handlePreviewEnvChanged(const QString &envAndValue)
|
||||
PropertyName matPrevEnvValueAuxProp("matPrevEnvValue");
|
||||
|
||||
auto renderPreviews = [=](const QString &auxEnv, const QString &auxValue) {
|
||||
ModelNode matLib = modelNodeForId(Constants::MATERIAL_LIB_ID);
|
||||
QTC_ASSERT(matLib.isValid(), return);
|
||||
matLib.setAuxiliaryData(matPrevEnvAuxProp, auxEnv);
|
||||
matLib.setAuxiliaryData(matPrevEnvValueAuxProp, auxValue);
|
||||
rootModelNode().setAuxiliaryData(matPrevEnvAuxProp, auxEnv);
|
||||
rootModelNode().setAuxiliaryData(matPrevEnvValueAuxProp, auxValue);
|
||||
QTimer::singleShot(0, this, &MaterialEditorView::requestPreviewRender);
|
||||
emitCustomNotification("refresh_material_browser", {});
|
||||
};
|
||||
@@ -473,13 +474,11 @@ void MaterialEditorView::handlePreviewEnvChanged(const QString &envAndValue)
|
||||
if (env == "Color") {
|
||||
m_colorDialog.clear();
|
||||
|
||||
ModelNode matLib = modelNodeForId(Constants::MATERIAL_LIB_ID);
|
||||
QTC_ASSERT(matLib.isValid(), return);
|
||||
// Store color to separate property to persist selection over non-color env changes
|
||||
PropertyName colorAuxProp("matPrevColor");
|
||||
QString oldColor = matLib.auxiliaryData(colorAuxProp).toString();
|
||||
QString oldEnv = matLib.auxiliaryData(matPrevEnvAuxProp).toString();
|
||||
QString oldValue = matLib.auxiliaryData(matPrevEnvValueAuxProp).toString();
|
||||
QString oldColor = rootModelNode().auxiliaryData(colorAuxProp).toString();
|
||||
QString oldEnv = rootModelNode().auxiliaryData(matPrevEnvAuxProp).toString();
|
||||
QString oldValue = rootModelNode().auxiliaryData(matPrevEnvValueAuxProp).toString();
|
||||
|
||||
m_colorDialog = new QColorDialog(Core::ICore::dialogParent());
|
||||
m_colorDialog->setModal(true);
|
||||
@@ -495,9 +494,7 @@ void MaterialEditorView::handlePreviewEnvChanged(const QString &envAndValue)
|
||||
QObject::connect(m_colorDialog, &QColorDialog::colorSelected,
|
||||
m_colorDialog, [=](const QColor &color) {
|
||||
renderPreviews(env, color.name());
|
||||
ModelNode matLib = modelNodeForId(Constants::MATERIAL_LIB_ID);
|
||||
QTC_ASSERT(matLib.isValid(), return);
|
||||
matLib.setAuxiliaryData(colorAuxProp, color.name());
|
||||
rootModelNode().setAuxiliaryData(colorAuxProp, color.name());
|
||||
});
|
||||
|
||||
QObject::connect(m_colorDialog, &QColorDialog::rejected,
|
||||
@@ -519,9 +516,7 @@ void MaterialEditorView::handlePreviewModelChanged(const QString &modelStr)
|
||||
QTC_ASSERT(model(), return);
|
||||
QTC_ASSERT(model()->nodeInstanceView(), return);
|
||||
|
||||
ModelNode matLib = modelNodeForId(Constants::MATERIAL_LIB_ID);
|
||||
QTC_ASSERT(matLib.isValid(), return);
|
||||
matLib.setAuxiliaryData("matPrevModel", modelStr);
|
||||
rootModelNode().setAuxiliaryData("matPrevModel", modelStr);
|
||||
|
||||
QTimer::singleShot(0, this, &MaterialEditorView::requestPreviewRender);
|
||||
emitCustomNotification("refresh_material_browser", {});
|
||||
@@ -570,6 +565,7 @@ void MaterialEditorView::setupQmlBackend()
|
||||
|
||||
currentQmlBackend->widget()->installEventFilter(this);
|
||||
currentQmlBackend->contextObject()->setHasQuick3DImport(m_hasQuick3DImport);
|
||||
currentQmlBackend->contextObject()->setHasMaterialRoot(m_hasMaterialRoot);
|
||||
|
||||
m_stackedWidget->setCurrentWidget(currentQmlBackend->widget());
|
||||
|
||||
@@ -623,23 +619,20 @@ bool MaterialEditorView::noValidSelection() const
|
||||
void MaterialEditorView::initPreviewData()
|
||||
{
|
||||
if (model() && m_qmlBackEnd) {
|
||||
ModelNode matLib = modelNodeForId(Constants::MATERIAL_LIB_ID);
|
||||
if (matLib.isValid()) {
|
||||
QString env = matLib.auxiliaryData("matPrevEnv").toString();
|
||||
QString envValue = matLib.auxiliaryData("matPrevEnvValue").toString();
|
||||
QString modelStr = matLib.auxiliaryData("matPrevModel").toString();
|
||||
if (!envValue.isEmpty() && env != "Color" && env != "Default") {
|
||||
env += '=';
|
||||
env += envValue;
|
||||
}
|
||||
if (env.isEmpty())
|
||||
env = "Default";
|
||||
if (modelStr.isEmpty())
|
||||
modelStr = "#Sphere";
|
||||
QMetaObject::invokeMethod(m_qmlBackEnd->widget()->rootObject(),
|
||||
"initPreviewData",
|
||||
Q_ARG(QVariant, env), Q_ARG(QVariant, modelStr));
|
||||
QString env = rootModelNode().auxiliaryData("matPrevEnv").toString();
|
||||
QString envValue = rootModelNode().auxiliaryData("matPrevEnvValue").toString();
|
||||
QString modelStr = rootModelNode().auxiliaryData("matPrevModel").toString();
|
||||
if (!envValue.isEmpty() && env != "Color" && env != "Default") {
|
||||
env += '=';
|
||||
env += envValue;
|
||||
}
|
||||
if (env.isEmpty())
|
||||
env = "Default";
|
||||
if (modelStr.isEmpty())
|
||||
modelStr = "#Sphere";
|
||||
QMetaObject::invokeMethod(m_qmlBackEnd->widget()->rootObject(),
|
||||
"initPreviewData",
|
||||
Q_ARG(QVariant, env), Q_ARG(QVariant, modelStr));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -650,11 +643,15 @@ void MaterialEditorView::modelAttached(Model *model)
|
||||
m_locked = true;
|
||||
|
||||
m_hasQuick3DImport = model->hasImport("QtQuick3D");
|
||||
m_hasMaterialRoot = rootModelNode().isSubclassOf("QtQuick3D.Material");
|
||||
|
||||
// Creating the material library node on model attach causes errors as long as the type information
|
||||
// not complete yet, so we keep checking until type info is complete.
|
||||
if (m_hasQuick3DImport)
|
||||
if (m_hasMaterialRoot) {
|
||||
m_selectedMaterial = rootModelNode();
|
||||
} else if (m_hasQuick3DImport) {
|
||||
// Creating the material library node on model attach causes errors as long as the type
|
||||
// information is not complete yet, so we keep checking until type info is complete.
|
||||
m_ensureMatLibTimer.start(500);
|
||||
}
|
||||
|
||||
if (!m_setupCompleted) {
|
||||
reloadQml();
|
||||
@@ -868,6 +865,10 @@ void MaterialEditorView::duplicateMaterial(const ModelNode &material)
|
||||
QmlObjectNode sourceMat(material);
|
||||
|
||||
executeInTransaction(__FUNCTION__, [&] {
|
||||
ModelNode matLib = materialLibraryNode();
|
||||
if (!matLib.isValid())
|
||||
return;
|
||||
|
||||
// create the duplicate material
|
||||
NodeMetaInfo metaInfo = model()->metaInfo(matType);
|
||||
QmlObjectNode duplicateMat = createModelNode(matType, metaInfo.majorVersion(), metaInfo.minorVersion());
|
||||
@@ -889,7 +890,7 @@ void MaterialEditorView::duplicateMaterial(const ModelNode &material)
|
||||
duplicateMat.setBindingProperty(prop.name(), prop.toBindingProperty().expression());
|
||||
}
|
||||
|
||||
materialLibraryNode().defaultNodeListProperty().reparentHere(duplicateMat);
|
||||
matLib.defaultNodeListProperty().reparentHere(duplicateMat);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -899,8 +900,10 @@ void MaterialEditorView::customNotification(const AbstractView *view, const QStr
|
||||
Q_UNUSED(view)
|
||||
|
||||
if (identifier == "selected_material_changed") {
|
||||
m_selectedMaterial = nodeList.first();
|
||||
QTimer::singleShot(0, this, &MaterialEditorView::resetView);
|
||||
if (!m_hasMaterialRoot) {
|
||||
m_selectedMaterial = nodeList.first();
|
||||
QTimer::singleShot(0, this, &MaterialEditorView::resetView);
|
||||
}
|
||||
} else if (identifier == "apply_to_selected_triggered") {
|
||||
applyMaterialToSelectedModels(nodeList.first(), data.first().toBool());
|
||||
} else if (identifier == "rename_material") {
|
||||
|
@@ -131,6 +131,7 @@ private:
|
||||
bool m_locked = false;
|
||||
bool m_setupCompleted = false;
|
||||
bool m_hasQuick3DImport = false;
|
||||
bool m_hasMaterialRoot = false;
|
||||
|
||||
QPointer<QColorDialog> m_colorDialog;
|
||||
};
|
||||
|
@@ -834,7 +834,7 @@ void AbstractView::changeRootNodeType(const TypeName &type, int majorVersion, in
|
||||
void AbstractView::ensureMaterialLibraryNode()
|
||||
{
|
||||
ModelNode matLib = modelNodeForId(Constants::MATERIAL_LIB_ID);
|
||||
if (matLib.isValid())
|
||||
if (matLib.isValid() || rootModelNode().isSubclassOf("QtQuick3D.Material"))
|
||||
return;
|
||||
|
||||
// Create material library node
|
||||
@@ -863,13 +863,11 @@ void AbstractView::ensureMaterialLibraryNode()
|
||||
}
|
||||
|
||||
// Returns ModelNode for project's material library.
|
||||
// Since this calls ensureMaterialLibraryNode(), it should only be called within a transaction.
|
||||
ModelNode AbstractView::materialLibraryNode()
|
||||
{
|
||||
ensureMaterialLibraryNode();
|
||||
|
||||
ModelNode matLib = modelNodeForId(Constants::MATERIAL_LIB_ID);
|
||||
QTC_ASSERT(matLib.isValid(), return {});
|
||||
|
||||
return matLib;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user