diff options
author | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2022-10-25 15:28:43 +0300 |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2022-10-25 15:06:35 +0000 |
commit | 8da35bac0f30ec28ba6c4672beb7f9c48d1d4ac5 (patch) | |
tree | a4573507d6170c5e8e8319cc05cd87e23d47e50c | |
parent | 162635cbe8865fab1e8150ff815f6ce8ab71e905 (diff) |
QmlDesigner: Add support for SpecularGlossyMaterial
Task-number: QDS-8087
Change-Id: Ic5cdca5d61d5f4ad11f63f3f5a59907798cde763
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
6 files changed, 29 insertions, 7 deletions
diff --git a/share/qtcreator/qmldesigner/materialBrowserQmlSource/MaterialBrowserContextMenu.qml b/share/qtcreator/qmldesigner/materialBrowserQmlSource/MaterialBrowserContextMenu.qml index d1e9f1ab1f..796bcab6eb 100644 --- a/share/qtcreator/qmldesigner/materialBrowserQmlSource/MaterialBrowserContextMenu.qml +++ b/share/qtcreator/qmldesigner/materialBrowserQmlSource/MaterialBrowserContextMenu.qml @@ -80,6 +80,10 @@ StudioControls.Menu { root.matSectionsModel = root.matSectionsModel.concat(materialBrowserModel.principledMaterialSections); break; + case "SpecularGlossyMaterial": + root.matSectionsModel = root.matSectionsModel.concat(materialBrowserModel.specularGlossyMaterialSections); + break; + case "CustomMaterial": root.matSectionsModel = root.matSectionsModel.concat(materialBrowserModel.customMaterialSections); break; diff --git a/src/plugins/qmldesigner/components/materialbrowser/materialbrowsermodel.cpp b/src/plugins/qmldesigner/components/materialbrowser/materialbrowsermodel.cpp index 10d596abbd..be855dc1a5 100644 --- a/src/plugins/qmldesigner/components/materialbrowser/materialbrowsermodel.cpp +++ b/src/plugins/qmldesigner/components/materialbrowser/materialbrowsermodel.cpp @@ -123,10 +123,12 @@ bool MaterialBrowserModel::loadPropertyGroups(const QString &path) m_defaultMaterialSections.clear(); m_principledMaterialSections.clear(); + m_specularGlossyMaterialSections.clear(); m_customMaterialSections.clear(); if (ok) { m_defaultMaterialSections.append(m_propertyGroupsObj.value("DefaultMaterial").toObject().keys()); m_principledMaterialSections.append(m_propertyGroupsObj.value("PrincipledMaterial").toObject().keys()); + m_specularGlossyMaterialSections.append(m_propertyGroupsObj.value("SpecularGlossyMaterial").toObject().keys()); QStringList customMatSections = m_propertyGroupsObj.value("CustomMaterial").toObject().keys(); if (customMatSections.size() > 1) // as of now custom material has only 1 section, so we don't add it @@ -145,6 +147,7 @@ void MaterialBrowserModel::unloadPropertyGroups() m_propertyGroupsObj = {}; m_defaultMaterialSections.clear(); m_principledMaterialSections.clear(); + m_specularGlossyMaterialSections.clear(); m_customMaterialSections.clear(); emit materialSectionsChanged(); } diff --git a/src/plugins/qmldesigner/components/materialbrowser/materialbrowsermodel.h b/src/plugins/qmldesigner/components/materialbrowser/materialbrowsermodel.h index 039d40921b..4a75378de6 100644 --- a/src/plugins/qmldesigner/components/materialbrowser/materialbrowsermodel.h +++ b/src/plugins/qmldesigner/components/materialbrowser/materialbrowsermodel.h @@ -47,6 +47,7 @@ class MaterialBrowserModel : public QAbstractListModel Q_PROPERTY(QString copiedMaterialType READ copiedMaterialType WRITE setCopiedMaterialType NOTIFY copiedMaterialTypeChanged) Q_PROPERTY(QStringList defaultMaterialSections MEMBER m_defaultMaterialSections NOTIFY materialSectionsChanged) Q_PROPERTY(QStringList principledMaterialSections MEMBER m_principledMaterialSections NOTIFY materialSectionsChanged) + Q_PROPERTY(QStringList specularGlossyMaterialSections MEMBER m_specularGlossyMaterialSections NOTIFY materialSectionsChanged) Q_PROPERTY(QStringList customMaterialSections MEMBER m_customMaterialSections NOTIFY materialSectionsChanged) public: @@ -128,6 +129,7 @@ private: QString m_searchText; QList<ModelNode> m_materialList; QStringList m_defaultMaterialSections; + QStringList m_specularGlossyMaterialSections; QStringList m_principledMaterialSections; QStringList m_customMaterialSections; ModelNode m_copiedMaterial; diff --git a/src/plugins/qmldesigner/components/materialeditor/materialeditorview.cpp b/src/plugins/qmldesigner/components/materialeditor/materialeditorview.cpp index cc8e4d2190..9352e200d1 100644 --- a/src/plugins/qmldesigner/components/materialeditor/materialeditorview.cpp +++ b/src/plugins/qmldesigner/components/materialeditor/materialeditorview.cpp @@ -718,8 +718,8 @@ void MaterialEditorView::updatePossibleTypes() return; // Ensure basic types are always first - static const QStringList basicTypes {"DefaultMaterial", "PrincipledMaterial", "CustomMaterial"}; - QStringList allTypes = basicTypes; + QStringList nonQuick3dTypes; + QStringList allTypes; const QList<ItemLibraryEntry> itemLibEntries = m_itemLibraryInfo->entries(); for (const ItemLibraryEntry &entry : itemLibEntries) { @@ -734,12 +734,22 @@ void MaterialEditorView::updatePossibleTypes() addImport = model()->hasImport(import, true, true); } if (addImport) { - QString typeName = QString::fromLatin1(entry.typeName().split('.').last()); - if (!allTypes.contains(typeName)) - allTypes.append(typeName); + const QList<QByteArray> typeSplit = entry.typeName().split('.'); + const QString typeName = QString::fromLatin1(typeSplit.last()); + if (typeSplit.size() == 2 && typeSplit.first() == "QtQuick3D") { + if (!allTypes.contains(typeName)) + allTypes.append(typeName); + } else if (!nonQuick3dTypes.contains(typeName)) { + nonQuick3dTypes.append(typeName); + } } } } + + allTypes.sort(); + nonQuick3dTypes.sort(); + allTypes.append(nonQuick3dTypes); + m_qmlBackEnd->contextObject()->setPossibleTypes(allTypes); } diff --git a/src/plugins/qmldesigner/components/navigator/choosefrompropertylistdialog.cpp b/src/plugins/qmldesigner/components/navigator/choosefrompropertylistdialog.cpp index 6d8a303f7c..557810d543 100644 --- a/src/plugins/qmldesigner/components/navigator/choosefrompropertylistdialog.cpp +++ b/src/plugins/qmldesigner/components/navigator/choosefrompropertylistdialog.cpp @@ -40,6 +40,7 @@ ChooseFromPropertyListFilter::ChooseFromPropertyListFilter(const NodeMetaInfo &i // Texture // -> DefaultMaterial // -> PrincipledMaterial + // -> SpecularGlossyMaterial // -> SpriteParticle3D // -> TextureInput // -> SceneEnvironment @@ -65,7 +66,8 @@ ChooseFromPropertyListFilter::ChooseFromPropertyListFilter(const NodeMetaInfo &i if (insertInfo.isSubclassOf(textureType)) { const TypeName textureTypeCpp = "<cpp>.QQuick3DTexture"; if (parentInfo.isSubclassOf("QtQuick3D.DefaultMaterial") - || parentInfo.isSubclassOf("QtQuick3D.PrincipledMaterial")) { + || parentInfo.isSubclassOf("QtQuick3D.PrincipledMaterial") + || parentInfo.isSubclassOf("QtQuick3D.SpecularGlossyMaterial")) { // All texture properties are valid targets const PropertyNameList targetNodeNameList = parentInfo.propertyNames(); for (const PropertyName &name : targetNodeNameList) { diff --git a/src/plugins/qmldesigner/components/navigator/navigatortreemodel.cpp b/src/plugins/qmldesigner/components/navigator/navigatortreemodel.cpp index d9c9d6699e..5ca192690a 100644 --- a/src/plugins/qmldesigner/components/navigator/navigatortreemodel.cpp +++ b/src/plugins/qmldesigner/components/navigator/navigatortreemodel.cpp @@ -1042,7 +1042,8 @@ bool NavigatorTreeModel::dropAsImage3dTexture(const ModelNode &targetNode, }; if (targetNode.isSubclassOf("QtQuick3D.DefaultMaterial") - || targetNode.isSubclassOf("QtQuick3D.PrincipledMaterial")) { + || targetNode.isSubclassOf("QtQuick3D.PrincipledMaterial") + || targetNode.isSubclassOf("QtQuick3D.SpecularGlossyMaterial")) { // if dropping an image on a material, create a texture instead of image // Show texture property selection dialog auto dialog = ChooseFromPropertyListDialog::createIfNeeded(targetNode, "QtQuick3D.Texture", |