forked from qt-creator/qt-creator
QmlDesigner: Use new validation approach in material editor
Many validation tests can now be skipped. Task-number: QDS-7454 Change-Id: I9c93498b96c1f1facd72a98d58751d3ad031c483 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
This commit is contained in:
@@ -114,8 +114,8 @@ void MaterialEditorView::changeValue(const QString &name)
|
|||||||
|
|
||||||
QVariant castedValue;
|
QVariant castedValue;
|
||||||
|
|
||||||
if (metaInfo.isValid() && metaInfo.hasProperty(propertyName)) {
|
if (auto property = metaInfo.property(propertyName)) {
|
||||||
castedValue = metaInfo.property(propertyName).castedValue(value->value());
|
castedValue = property.castedValue(value->value());
|
||||||
} else {
|
} else {
|
||||||
qWarning() << __FUNCTION__ << propertyName << "cannot be casted (metainfo)";
|
qWarning() << __FUNCTION__ << propertyName << "cannot be casted (metainfo)";
|
||||||
return;
|
return;
|
||||||
@@ -128,8 +128,8 @@ void MaterialEditorView::changeValue(const QString &name)
|
|||||||
|
|
||||||
bool propertyTypeUrl = false;
|
bool propertyTypeUrl = false;
|
||||||
|
|
||||||
if (metaInfo.isValid() && metaInfo.hasProperty(propertyName)) {
|
if (auto property = metaInfo.property(propertyName)) {
|
||||||
if (metaInfo.property(propertyName).propertyType().isUrl()) {
|
if (property.propertyType().isUrl()) {
|
||||||
// turn absolute local file paths into relative paths
|
// turn absolute local file paths into relative paths
|
||||||
propertyTypeUrl = true;
|
propertyTypeUrl = true;
|
||||||
QString filePath = castedValue.toUrl().toString();
|
QString filePath = castedValue.toUrl().toString();
|
||||||
@@ -191,9 +191,8 @@ void MaterialEditorView::changeExpression(const QString &propertyName)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (auto metaInfo = m_selectedMaterial.metaInfo();
|
if (auto property = m_selectedMaterial.metaInfo().property(name)) {
|
||||||
metaInfo.isValid() && metaInfo.hasProperty(name)) {
|
auto propertyTypeName = property.propertyType().typeName();
|
||||||
auto propertyTypeName = metaInfo.property(name).propertyType().typeName();
|
|
||||||
if (propertyTypeName == "QColor") {
|
if (propertyTypeName == "QColor") {
|
||||||
if (QColor(value->expression().remove('"')).isValid()) {
|
if (QColor(value->expression().remove('"')).isValid()) {
|
||||||
qmlObjectNode.setVariantProperty(name, QColor(value->expression().remove('"')));
|
qmlObjectNode.setVariantProperty(name, QColor(value->expression().remove('"')));
|
||||||
@@ -550,8 +549,7 @@ void MaterialEditorView::setupQmlBackend()
|
|||||||
qmlPaneUrl = QUrl::fromLocalFile(materialEditorResourcesPath() + "/MaterialEditorPane.qml");
|
qmlPaneUrl = QUrl::fromLocalFile(materialEditorResourcesPath() + "/MaterialEditorPane.qml");
|
||||||
|
|
||||||
TypeName diffClassName;
|
TypeName diffClassName;
|
||||||
NodeMetaInfo metaInfo = m_selectedMaterial.metaInfo();
|
if (NodeMetaInfo metaInfo = m_selectedMaterial.metaInfo()) {
|
||||||
if (metaInfo.isValid()) {
|
|
||||||
diffClassName = metaInfo.typeName();
|
diffClassName = metaInfo.typeName();
|
||||||
for (const NodeMetaInfo &metaInfo : metaInfo.classHierarchy()) {
|
for (const NodeMetaInfo &metaInfo : metaInfo.classHierarchy()) {
|
||||||
if (PropertyEditorQmlBackend::checkIfUrlExists(qmlSpecificsUrl))
|
if (PropertyEditorQmlBackend::checkIfUrlExists(qmlSpecificsUrl))
|
||||||
@@ -560,10 +558,13 @@ void MaterialEditorView::setupQmlBackend()
|
|||||||
+ "Specifics", metaInfo);
|
+ "Specifics", metaInfo);
|
||||||
diffClassName = metaInfo.typeName();
|
diffClassName = metaInfo.typeName();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (metaInfo.isValid() && diffClassName != m_selectedMaterial.type()) {
|
if (diffClassName != m_selectedMaterial.type()) {
|
||||||
specificQmlData = PropertyEditorQmlBackend::templateGeneration(
|
specificQmlData = PropertyEditorQmlBackend::templateGeneration(metaInfo,
|
||||||
metaInfo, model()->metaInfo(diffClassName), m_selectedMaterial);
|
model()->metaInfo(
|
||||||
|
diffClassName),
|
||||||
|
m_selectedMaterial);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
currentTypeName = QString::fromLatin1(m_selectedMaterial.type());
|
currentTypeName = QString::fromLatin1(m_selectedMaterial.type());
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user