forked from qt-creator/qt-creator
QmlDesigner: Add layout margins to property editor
Change-Id: I39565559fbd3f5cae46e72f9139f2eac17b647b0 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
committed by
Tim Jenssen
parent
1ee005aef4
commit
cad9da05fd
@@ -40,6 +40,8 @@ SectionLayout {
|
|||||||
onBackendValueChanged: evaluateAlignment()
|
onBackendValueChanged: evaluateAlignment()
|
||||||
onValueFromBackendChanged: evaluateAlignment()
|
onValueFromBackendChanged: evaluateAlignment()
|
||||||
|
|
||||||
|
property int spinBoxWidth: 62
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
target: modelNodeBackend
|
target: modelNodeBackend
|
||||||
onSelectionChanged: {
|
onSelectionChanged: {
|
||||||
@@ -47,6 +49,8 @@ SectionLayout {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
id: root
|
||||||
|
|
||||||
Component.onCompleted: evaluateAlignment()
|
Component.onCompleted: evaluateAlignment()
|
||||||
|
|
||||||
function indexOfVerticalAlignment() {
|
function indexOfVerticalAlignment() {
|
||||||
@@ -256,7 +260,7 @@ SectionLayout {
|
|||||||
|
|
||||||
Label {
|
Label {
|
||||||
text: "W"
|
text: "W"
|
||||||
width: 12
|
width: 28
|
||||||
}
|
}
|
||||||
|
|
||||||
SpinBox {
|
SpinBox {
|
||||||
@@ -264,6 +268,7 @@ SectionLayout {
|
|||||||
maximumValue: 0xffff
|
maximumValue: 0xffff
|
||||||
minimumValue: -1
|
minimumValue: -1
|
||||||
decimals: 0
|
decimals: 0
|
||||||
|
implicitWidth: root.spinBoxWidth
|
||||||
}
|
}
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
@@ -273,7 +278,7 @@ SectionLayout {
|
|||||||
|
|
||||||
Label {
|
Label {
|
||||||
text: "H"
|
text: "H"
|
||||||
width: 12
|
width: 28
|
||||||
}
|
}
|
||||||
|
|
||||||
SpinBox {
|
SpinBox {
|
||||||
@@ -281,6 +286,7 @@ SectionLayout {
|
|||||||
maximumValue: 0xffff
|
maximumValue: 0xffff
|
||||||
minimumValue: -1
|
minimumValue: -1
|
||||||
decimals: 0
|
decimals: 0
|
||||||
|
implicitWidth: root.spinBoxWidth
|
||||||
}
|
}
|
||||||
ExpandingSpacer {
|
ExpandingSpacer {
|
||||||
|
|
||||||
@@ -297,7 +303,7 @@ SectionLayout {
|
|||||||
|
|
||||||
Label {
|
Label {
|
||||||
text: "W"
|
text: "W"
|
||||||
width: 12
|
width: 28
|
||||||
}
|
}
|
||||||
|
|
||||||
SpinBox {
|
SpinBox {
|
||||||
@@ -305,6 +311,7 @@ SectionLayout {
|
|||||||
maximumValue: 0xffff
|
maximumValue: 0xffff
|
||||||
minimumValue: 0
|
minimumValue: 0
|
||||||
decimals: 0
|
decimals: 0
|
||||||
|
implicitWidth: root.spinBoxWidth
|
||||||
}
|
}
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
@@ -314,7 +321,7 @@ SectionLayout {
|
|||||||
|
|
||||||
Label {
|
Label {
|
||||||
text: "H"
|
text: "H"
|
||||||
width: 12
|
width: 28
|
||||||
}
|
}
|
||||||
|
|
||||||
SpinBox {
|
SpinBox {
|
||||||
@@ -322,6 +329,7 @@ SectionLayout {
|
|||||||
maximumValue: 0xffff
|
maximumValue: 0xffff
|
||||||
minimumValue: 0
|
minimumValue: 0
|
||||||
decimals: 0
|
decimals: 0
|
||||||
|
implicitWidth: root.spinBoxWidth
|
||||||
}
|
}
|
||||||
ExpandingSpacer {
|
ExpandingSpacer {
|
||||||
|
|
||||||
@@ -338,7 +346,7 @@ SectionLayout {
|
|||||||
|
|
||||||
Label {
|
Label {
|
||||||
text: "W"
|
text: "W"
|
||||||
width: 12
|
width: 28
|
||||||
}
|
}
|
||||||
|
|
||||||
SpinBox {
|
SpinBox {
|
||||||
@@ -346,6 +354,7 @@ SectionLayout {
|
|||||||
maximumValue: 0xffff
|
maximumValue: 0xffff
|
||||||
minimumValue: 0
|
minimumValue: 0
|
||||||
decimals: 0
|
decimals: 0
|
||||||
|
implicitWidth: root.spinBoxWidth
|
||||||
}
|
}
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
@@ -355,7 +364,7 @@ SectionLayout {
|
|||||||
|
|
||||||
Label {
|
Label {
|
||||||
text: "H"
|
text: "H"
|
||||||
width: 12
|
width: 28
|
||||||
}
|
}
|
||||||
|
|
||||||
SpinBox {
|
SpinBox {
|
||||||
@@ -363,6 +372,91 @@ SectionLayout {
|
|||||||
maximumValue: 0xffff
|
maximumValue: 0xffff
|
||||||
minimumValue: 0
|
minimumValue: 0
|
||||||
decimals: 0
|
decimals: 0
|
||||||
|
implicitWidth: root.spinBoxWidth
|
||||||
|
}
|
||||||
|
ExpandingSpacer {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Label {
|
||||||
|
text: qsTr("Margins")
|
||||||
|
}
|
||||||
|
|
||||||
|
SecondColumnLayout {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
|
||||||
|
Label {
|
||||||
|
text: "Top"
|
||||||
|
width: 28
|
||||||
|
}
|
||||||
|
|
||||||
|
SpinBox {
|
||||||
|
backendValue: backendValues.Layout_topMargin
|
||||||
|
maximumValue: 0xffff
|
||||||
|
minimumValue: 0
|
||||||
|
decimals: 0
|
||||||
|
implicitWidth: root.spinBoxWidth
|
||||||
|
}
|
||||||
|
|
||||||
|
Item {
|
||||||
|
width: 4
|
||||||
|
height: 4
|
||||||
|
}
|
||||||
|
|
||||||
|
Label {
|
||||||
|
text: "Bottom"
|
||||||
|
width: 28
|
||||||
|
}
|
||||||
|
|
||||||
|
SpinBox {
|
||||||
|
backendValue: backendValues.Layout_bottomMargin
|
||||||
|
maximumValue: 0xffff
|
||||||
|
minimumValue: 0
|
||||||
|
decimals: 0
|
||||||
|
implicitWidth: root.spinBoxWidth
|
||||||
|
}
|
||||||
|
ExpandingSpacer {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Label {
|
||||||
|
text: ("")
|
||||||
|
}
|
||||||
|
|
||||||
|
SecondColumnLayout {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
|
||||||
|
Label {
|
||||||
|
text: "Left"
|
||||||
|
width: 28
|
||||||
|
}
|
||||||
|
|
||||||
|
SpinBox {
|
||||||
|
backendValue: backendValues.Layout_leftMargin
|
||||||
|
maximumValue: 0xffff
|
||||||
|
minimumValue: 0
|
||||||
|
decimals: 0
|
||||||
|
implicitWidth: root.spinBoxWidth
|
||||||
|
}
|
||||||
|
|
||||||
|
Item {
|
||||||
|
width: 4
|
||||||
|
height: 4
|
||||||
|
}
|
||||||
|
|
||||||
|
Label {
|
||||||
|
text: "Right"
|
||||||
|
width: 28
|
||||||
|
}
|
||||||
|
|
||||||
|
SpinBox {
|
||||||
|
backendValue: backendValues.Layout_rightMargin
|
||||||
|
maximumValue: 0xffff
|
||||||
|
minimumValue: 0
|
||||||
|
decimals: 0
|
||||||
|
implicitWidth: root.spinBoxWidth
|
||||||
}
|
}
|
||||||
ExpandingSpacer {
|
ExpandingSpacer {
|
||||||
|
|
||||||
@@ -379,7 +473,7 @@ SectionLayout {
|
|||||||
|
|
||||||
Item {
|
Item {
|
||||||
height: 4
|
height: 4
|
||||||
width: 12
|
width: 28
|
||||||
}
|
}
|
||||||
|
|
||||||
SpinBox {
|
SpinBox {
|
||||||
@@ -387,6 +481,7 @@ SectionLayout {
|
|||||||
maximumValue: 0xffff
|
maximumValue: 0xffff
|
||||||
minimumValue: 0
|
minimumValue: 0
|
||||||
decimals: 0
|
decimals: 0
|
||||||
|
implicitWidth: root.spinBoxWidth
|
||||||
}
|
}
|
||||||
|
|
||||||
ExpandingSpacer {
|
ExpandingSpacer {
|
||||||
@@ -404,7 +499,7 @@ SectionLayout {
|
|||||||
|
|
||||||
Item {
|
Item {
|
||||||
height: 4
|
height: 4
|
||||||
width: 12
|
width: 28
|
||||||
}
|
}
|
||||||
|
|
||||||
SpinBox {
|
SpinBox {
|
||||||
@@ -412,6 +507,7 @@ SectionLayout {
|
|||||||
maximumValue: 0xffff
|
maximumValue: 0xffff
|
||||||
minimumValue: 0
|
minimumValue: 0
|
||||||
decimals: 0
|
decimals: 0
|
||||||
|
implicitWidth: root.spinBoxWidth
|
||||||
}
|
}
|
||||||
|
|
||||||
ExpandingSpacer {
|
ExpandingSpacer {
|
||||||
|
@@ -152,6 +152,12 @@ QVariant properDefaultLayoutAttachedProperties(const QmlObjectNode &qmlObjectNod
|
|||||||
if ("columnSpan" == propertyName || "rowSpan" == propertyName)
|
if ("columnSpan" == propertyName || "rowSpan" == propertyName)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
if ("topMargin" == propertyName || "bottomMargin" == propertyName)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if ("leftMargin" == propertyName || "rightMargin" == propertyName)
|
||||||
|
return 0;
|
||||||
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,7 +167,8 @@ void PropertyEditorQmlBackend::setupLayoutAttachedProperties(const QmlObjectNode
|
|||||||
|
|
||||||
static const PropertyNameList propertyNames =
|
static const PropertyNameList propertyNames =
|
||||||
{"alignment", "column", "columnSpan", "fillHeight", "fillWidth", "maximumHeight", "maximumWidth",
|
{"alignment", "column", "columnSpan", "fillHeight", "fillWidth", "maximumHeight", "maximumWidth",
|
||||||
"minimumHeight", "minimumWidth", "preferredHeight", "preferredWidth", "row", "rowSpan"};
|
"minimumHeight", "minimumWidth", "preferredHeight", "preferredWidth", "row", "rowSpan",
|
||||||
|
"topMargin", "bottomMargin", "leftMargin", "rightMargin"};
|
||||||
|
|
||||||
foreach (const PropertyName &propertyName, propertyNames) {
|
foreach (const PropertyName &propertyName, propertyNames) {
|
||||||
createPropertyEditorValue(qmlObjectNode, "Layout." + propertyName, properDefaultLayoutAttachedProperties(qmlObjectNode, propertyName), propertyEditor);
|
createPropertyEditorValue(qmlObjectNode, "Layout." + propertyName, properDefaultLayoutAttachedProperties(qmlObjectNode, propertyName), propertyEditor);
|
||||||
|
Reference in New Issue
Block a user