forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -80,6 +80,10 @@ StudioControls.Menu {
|
|||||||
root.matSectionsModel = root.matSectionsModel.concat(materialBrowserModel.principledMaterialSections);
|
root.matSectionsModel = root.matSectionsModel.concat(materialBrowserModel.principledMaterialSections);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "SpecularGlossyMaterial":
|
||||||
|
root.matSectionsModel = root.matSectionsModel.concat(materialBrowserModel.specularGlossyMaterialSections);
|
||||||
|
break;
|
||||||
|
|
||||||
case "CustomMaterial":
|
case "CustomMaterial":
|
||||||
root.matSectionsModel = root.matSectionsModel.concat(materialBrowserModel.customMaterialSections);
|
root.matSectionsModel = root.matSectionsModel.concat(materialBrowserModel.customMaterialSections);
|
||||||
break;
|
break;
|
||||||
|
@@ -123,10 +123,12 @@ bool MaterialBrowserModel::loadPropertyGroups(const QString &path)
|
|||||||
|
|
||||||
m_defaultMaterialSections.clear();
|
m_defaultMaterialSections.clear();
|
||||||
m_principledMaterialSections.clear();
|
m_principledMaterialSections.clear();
|
||||||
|
m_specularGlossyMaterialSections.clear();
|
||||||
m_customMaterialSections.clear();
|
m_customMaterialSections.clear();
|
||||||
if (ok) {
|
if (ok) {
|
||||||
m_defaultMaterialSections.append(m_propertyGroupsObj.value("DefaultMaterial").toObject().keys());
|
m_defaultMaterialSections.append(m_propertyGroupsObj.value("DefaultMaterial").toObject().keys());
|
||||||
m_principledMaterialSections.append(m_propertyGroupsObj.value("PrincipledMaterial").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();
|
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
|
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_propertyGroupsObj = {};
|
||||||
m_defaultMaterialSections.clear();
|
m_defaultMaterialSections.clear();
|
||||||
m_principledMaterialSections.clear();
|
m_principledMaterialSections.clear();
|
||||||
|
m_specularGlossyMaterialSections.clear();
|
||||||
m_customMaterialSections.clear();
|
m_customMaterialSections.clear();
|
||||||
emit materialSectionsChanged();
|
emit materialSectionsChanged();
|
||||||
}
|
}
|
||||||
|
@@ -47,6 +47,7 @@ class MaterialBrowserModel : public QAbstractListModel
|
|||||||
Q_PROPERTY(QString copiedMaterialType READ copiedMaterialType WRITE setCopiedMaterialType NOTIFY copiedMaterialTypeChanged)
|
Q_PROPERTY(QString copiedMaterialType READ copiedMaterialType WRITE setCopiedMaterialType NOTIFY copiedMaterialTypeChanged)
|
||||||
Q_PROPERTY(QStringList defaultMaterialSections MEMBER m_defaultMaterialSections NOTIFY materialSectionsChanged)
|
Q_PROPERTY(QStringList defaultMaterialSections MEMBER m_defaultMaterialSections NOTIFY materialSectionsChanged)
|
||||||
Q_PROPERTY(QStringList principledMaterialSections MEMBER m_principledMaterialSections 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)
|
Q_PROPERTY(QStringList customMaterialSections MEMBER m_customMaterialSections NOTIFY materialSectionsChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -128,6 +129,7 @@ private:
|
|||||||
QString m_searchText;
|
QString m_searchText;
|
||||||
QList<ModelNode> m_materialList;
|
QList<ModelNode> m_materialList;
|
||||||
QStringList m_defaultMaterialSections;
|
QStringList m_defaultMaterialSections;
|
||||||
|
QStringList m_specularGlossyMaterialSections;
|
||||||
QStringList m_principledMaterialSections;
|
QStringList m_principledMaterialSections;
|
||||||
QStringList m_customMaterialSections;
|
QStringList m_customMaterialSections;
|
||||||
ModelNode m_copiedMaterial;
|
ModelNode m_copiedMaterial;
|
||||||
|
@@ -718,8 +718,8 @@ void MaterialEditorView::updatePossibleTypes()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Ensure basic types are always first
|
// Ensure basic types are always first
|
||||||
static const QStringList basicTypes {"DefaultMaterial", "PrincipledMaterial", "CustomMaterial"};
|
QStringList nonQuick3dTypes;
|
||||||
QStringList allTypes = basicTypes;
|
QStringList allTypes;
|
||||||
|
|
||||||
const QList<ItemLibraryEntry> itemLibEntries = m_itemLibraryInfo->entries();
|
const QList<ItemLibraryEntry> itemLibEntries = m_itemLibraryInfo->entries();
|
||||||
for (const ItemLibraryEntry &entry : itemLibEntries) {
|
for (const ItemLibraryEntry &entry : itemLibEntries) {
|
||||||
@@ -734,12 +734,22 @@ void MaterialEditorView::updatePossibleTypes()
|
|||||||
addImport = model()->hasImport(import, true, true);
|
addImport = model()->hasImport(import, true, true);
|
||||||
}
|
}
|
||||||
if (addImport) {
|
if (addImport) {
|
||||||
QString typeName = QString::fromLatin1(entry.typeName().split('.').last());
|
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))
|
if (!allTypes.contains(typeName))
|
||||||
allTypes.append(typeName);
|
allTypes.append(typeName);
|
||||||
|
} else if (!nonQuick3dTypes.contains(typeName)) {
|
||||||
|
nonQuick3dTypes.append(typeName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
allTypes.sort();
|
||||||
|
nonQuick3dTypes.sort();
|
||||||
|
allTypes.append(nonQuick3dTypes);
|
||||||
|
|
||||||
m_qmlBackEnd->contextObject()->setPossibleTypes(allTypes);
|
m_qmlBackEnd->contextObject()->setPossibleTypes(allTypes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -40,6 +40,7 @@ ChooseFromPropertyListFilter::ChooseFromPropertyListFilter(const NodeMetaInfo &i
|
|||||||
// Texture
|
// Texture
|
||||||
// -> DefaultMaterial
|
// -> DefaultMaterial
|
||||||
// -> PrincipledMaterial
|
// -> PrincipledMaterial
|
||||||
|
// -> SpecularGlossyMaterial
|
||||||
// -> SpriteParticle3D
|
// -> SpriteParticle3D
|
||||||
// -> TextureInput
|
// -> TextureInput
|
||||||
// -> SceneEnvironment
|
// -> SceneEnvironment
|
||||||
@@ -65,7 +66,8 @@ ChooseFromPropertyListFilter::ChooseFromPropertyListFilter(const NodeMetaInfo &i
|
|||||||
if (insertInfo.isSubclassOf(textureType)) {
|
if (insertInfo.isSubclassOf(textureType)) {
|
||||||
const TypeName textureTypeCpp = "<cpp>.QQuick3DTexture";
|
const TypeName textureTypeCpp = "<cpp>.QQuick3DTexture";
|
||||||
if (parentInfo.isSubclassOf("QtQuick3D.DefaultMaterial")
|
if (parentInfo.isSubclassOf("QtQuick3D.DefaultMaterial")
|
||||||
|| parentInfo.isSubclassOf("QtQuick3D.PrincipledMaterial")) {
|
|| parentInfo.isSubclassOf("QtQuick3D.PrincipledMaterial")
|
||||||
|
|| parentInfo.isSubclassOf("QtQuick3D.SpecularGlossyMaterial")) {
|
||||||
// All texture properties are valid targets
|
// All texture properties are valid targets
|
||||||
const PropertyNameList targetNodeNameList = parentInfo.propertyNames();
|
const PropertyNameList targetNodeNameList = parentInfo.propertyNames();
|
||||||
for (const PropertyName &name : targetNodeNameList) {
|
for (const PropertyName &name : targetNodeNameList) {
|
||||||
|
@@ -1042,7 +1042,8 @@ bool NavigatorTreeModel::dropAsImage3dTexture(const ModelNode &targetNode,
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (targetNode.isSubclassOf("QtQuick3D.DefaultMaterial")
|
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
|
// if dropping an image on a material, create a texture instead of image
|
||||||
// Show texture property selection dialog
|
// Show texture property selection dialog
|
||||||
auto dialog = ChooseFromPropertyListDialog::createIfNeeded(targetNode, "QtQuick3D.Texture",
|
auto dialog = ChooseFromPropertyListDialog::createIfNeeded(targetNode, "QtQuick3D.Texture",
|
||||||
|
Reference in New Issue
Block a user