diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.cpp b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.cpp index aec4c3b7a1d..f590e6de449 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.cpp @@ -133,7 +133,11 @@ void PropertyEditorQmlBackend::setupPropertyEditorValue(const PropertyName &name QVariant properDefaultLayoutAttachedProperties(const QmlObjectNode &qmlObjectNode, const PropertyName &propertyName) { - QVariant value = qmlObjectNode.modelValue(propertyName); + const QVariant value = qmlObjectNode.modelValue("Layout." + propertyName); + QVariant marginsValue = qmlObjectNode.modelValue("Layout.margins"); + + if (!marginsValue.isValid()) + marginsValue.setValue(0.0); if (value.isValid()) return value; @@ -153,11 +157,10 @@ QVariant properDefaultLayoutAttachedProperties(const QmlObjectNode &qmlObjectNod if ("columnSpan" == propertyName || "rowSpan" == propertyName) return 1; - if ("topMargin" == propertyName || "bottomMargin" == propertyName) - return 0; - - if ("leftMargin" == propertyName || "rightMargin" == propertyName) - return 0; + if ("topMargin" == propertyName || "bottomMargin" == propertyName || + "leftMargin" == propertyName || "rightMargin" == propertyName || + "margins" == propertyName) + return marginsValue; return QVariant(); } @@ -169,9 +172,9 @@ void PropertyEditorQmlBackend::setupLayoutAttachedProperties(const QmlObjectNode static const PropertyNameList propertyNames = {"alignment", "column", "columnSpan", "fillHeight", "fillWidth", "maximumHeight", "maximumWidth", "minimumHeight", "minimumWidth", "preferredHeight", "preferredWidth", "row", "rowSpan", - "topMargin", "bottomMargin", "leftMargin", "rightMargin"}; + "topMargin", "bottomMargin", "leftMargin", "rightMargin", "margins"}; - foreach (const PropertyName &propertyName, propertyNames) { + for (const PropertyName &propertyName : propertyNames) { createPropertyEditorValue(qmlObjectNode, "Layout." + propertyName, properDefaultLayoutAttachedProperties(qmlObjectNode, propertyName), propertyEditor); } } @@ -629,7 +632,15 @@ void PropertyEditorQmlBackend::setValueforLayoutAttachedProperties(const QmlObje { PropertyName propertyName = name; propertyName.replace("Layout.", ""); - setValue(qmlObjectNode, name, properDefaultLayoutAttachedProperties(qmlObjectNode, propertyName)); + setValue(qmlObjectNode, name, properDefaultLayoutAttachedProperties(qmlObjectNode, propertyName)); + + if (propertyName == "margins") { + const QVariant marginsValue = properDefaultLayoutAttachedProperties(qmlObjectNode, "margins"); + setValue(qmlObjectNode, "Layout.topMargin", marginsValue); + setValue(qmlObjectNode, "Layout.bottomMargin", marginsValue); + setValue(qmlObjectNode, "Layout.leftMargin", marginsValue); + setValue(qmlObjectNode, "Layout.rightMargin", marginsValue); + } } QUrl PropertyEditorQmlBackend::getQmlUrlForMetaInfo(const NodeMetaInfo &metaInfo, TypeName &className) diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.cpp b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.cpp index c7a9e6473e4..1d0c165bdaf 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.cpp @@ -591,9 +591,18 @@ void PropertyEditorView::propertiesRemoved(const QList& proper if (node == m_selectedNode || QmlObjectNode(m_selectedNode).propertyChangeForCurrentState() == node) { setValue(m_selectedNode, property.name(), QmlObjectNode(m_selectedNode).instanceValue(property.name())); - if (propertyIsAttachedLayoutProperty(property.name())) + if (propertyIsAttachedLayoutProperty(property.name())) { m_qmlBackEndForCurrentType->setValueforLayoutAttachedProperties(m_selectedNode, property.name()); + if (property.name() == "Layout.margins") { + m_qmlBackEndForCurrentType->setValueforLayoutAttachedProperties(m_selectedNode, "Layout.topMargin"); + m_qmlBackEndForCurrentType->setValueforLayoutAttachedProperties(m_selectedNode, "Layout.bottomMargin"); + m_qmlBackEndForCurrentType->setValueforLayoutAttachedProperties(m_selectedNode, "Layout.leftMargin"); + m_qmlBackEndForCurrentType->setValueforLayoutAttachedProperties(m_selectedNode, "Layout.rightMargin"); + + } + } + if ("width" == property.name() || "height" == property.name()) { const QmlItemNode qmlItemNode = m_selectedNode; if (qmlItemNode.isValid() && qmlItemNode.isInLayout())