From cf6a88c3ae86a45cb36761453e0f52ec5337840b Mon Sep 17 00:00:00 2001 From: Henning Gruendl Date: Tue, 1 Oct 2019 10:48:16 +0200 Subject: [PATCH] QmlDesigner: Cleanup layout specifics * Add missing drag range property to AnchorRow, MarginSection and PaddingSection SpinBoxes * Use MarginSection for LayoutProperties Change-Id: I656fc0df353a16477a1ad0279af7186899f5f7e6 Reviewed-by: Tim Jenssen --- .../QtQuick/AnchorRow.qml | 1 + .../QtQuick/ItemPane.qml | 11 ++ .../QtQuick/LayoutPoperties.qml | 185 +++--------------- .../QtQuick/LayoutSection.qml | 4 +- .../imports/HelperWidgets/MarginSection.qml | 16 ++ .../imports/HelperWidgets/PaddingSection.qml | 5 + 6 files changed, 62 insertions(+), 160 deletions(-) diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/AnchorRow.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/AnchorRow.qml index 602a713b6ab..16f82787b38 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/AnchorRow.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/AnchorRow.qml @@ -100,6 +100,7 @@ RowLayout { maximumValue: 0xffff minimumValue: -0xffff backendValue: anchorMargin + realDragRange: 5000 } StudioControls.ButtonRow { diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/ItemPane.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/ItemPane.qml index d21f5f19fa8..c8eb5721410 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/ItemPane.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/ItemPane.qml @@ -27,6 +27,8 @@ import QtQuick 2.0 import HelperWidgets 2.0 import QtQuick.Layouts 1.0 import QtQuickDesignerTheme 1.0 +import StudioControls 1.0 as StudioControls +import StudioTheme 1.0 as StudioTheme Rectangle { id: itemPane @@ -284,6 +286,15 @@ Rectangle { tabView.layoutSectionHeight = childRectHeight + tabView.extraHeight } } + + MarginSection { + visible: anchorBackend.isInLayout + backendValueTopMargin: backendValues.Layout_topMargin + backendValueBottomMargin: backendValues.Layout_bottomMargin + backendValueLeftMargin: backendValues.Layout_leftMargin + backendValueRightMargin: backendValues.Layout_rightMargin + backendValueMargins: backendValues.Layout_margins + } } } diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/LayoutPoperties.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/LayoutPoperties.qml index cbe22a8a3d9..83d4a65b513 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/LayoutPoperties.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/LayoutPoperties.qml @@ -26,7 +26,6 @@ import QtQuick 2.0 import HelperWidgets 2.0 import QtQuick.Layouts 1.0 -import QtQuick.Controls 1.0 as Controls import StudioControls 1.0 as StudioControls SectionLayout { @@ -71,11 +70,9 @@ SectionLayout { return 3; return 0; - } function indexOfHorizontalAlignment() { - if (backendValue.expression === undefined) return 0; @@ -89,11 +86,9 @@ SectionLayout { return 2; return 0; - } function evaluateAlignment() { - blockAlignment = true verticalAlignmentComboBox.currentIndex = indexOfVerticalAlignment(); @@ -119,17 +114,14 @@ SectionLayout { backendValue.expression = expressionStr backendValue.resetValue(); } - } - Label { text: qsTr("Alignment") tooltip: qsTr("Alignment of an item within the cells it occupies.") } SecondColumnLayout { - StudioControls.ComboBox { ColorLogic { id: colorLogic @@ -139,7 +131,7 @@ SectionLayout { ExtendedFunctionLogic { id: extFuncLogic backendValue: backendValues.Layout_alignment - onReseted: { + onReseted: { horizontalAlignmentComboBox.currentIndex = 0 verticalAlignmentComboBox.currentIndex = 0 } @@ -170,21 +162,13 @@ SectionLayout { Component.onCompleted: { horizontalAlignmentComboBox.__isCompleted = true; } - } - - ExpandingSpacer { - - } - } Label { - } SecondColumnLayout { - StudioControls.ComboBox { id: verticalAlignmentComboBox Layout.fillWidth: true @@ -199,7 +183,7 @@ SectionLayout { property bool __isCompleted: false - model: ["AlignVCenter", "AlignTop","AlignBottom","AlignBaseline"] + model: ["AlignVCenter", "AlignTop", "AlignBottom", "AlignBaseline"] onActivated: { if (!verticalAlignmentComboBox.__isCompleted) @@ -212,13 +196,7 @@ SectionLayout { Component.onCompleted: { verticalAlignmentComboBox.__isCompleted = true; } - } - - ExpandingSpacer { - - } - } Label { @@ -230,21 +208,13 @@ SectionLayout { CheckBox { backendValue: backendValues.Layout_fillWidth text: qsTr("Fill width") - } - - Item { - width: 10 - height: 10 - + Layout.fillWidth: true } CheckBox { backendValue: backendValues.Layout_fillHeight text: qsTr("Fill height") - } - - ExpandingSpacer { - + Layout.fillWidth: true } } @@ -258,15 +228,15 @@ SectionLayout { Label { text: "W" - width: 28 + width: 12 } SpinBox { backendValue: backendValues.Layout_preferredWidth - maximumValue: 0xffff minimumValue: -1 + maximumValue: 0xffff + realDragRange: 5000 decimals: 0 - implicitWidth: root.spinBoxWidth } Item { @@ -276,18 +246,15 @@ SectionLayout { Label { text: "H" - width: 28 + width: 12 } SpinBox { backendValue: backendValues.Layout_preferredHeight - maximumValue: 0xffff minimumValue: -1 + maximumValue: 0xffff + realDragRange: 5000 decimals: 0 - implicitWidth: root.spinBoxWidth - } - ExpandingSpacer { - } } @@ -301,15 +268,15 @@ SectionLayout { Label { text: "W" - width: 28 + width: 12 } SpinBox { backendValue: backendValues.Layout_minimumWidth - maximumValue: 0xffff minimumValue: 0 + maximumValue: 0xffff + realDragRange: 5000 decimals: 0 - implicitWidth: root.spinBoxWidth } Item { @@ -319,18 +286,15 @@ SectionLayout { Label { text: "H" - width: 28 + width: 12 } SpinBox { backendValue: backendValues.Layout_minimumHeight - maximumValue: 0xffff minimumValue: 0 + maximumValue: 0xffff + realDragRange: 5000 decimals: 0 - implicitWidth: root.spinBoxWidth - } - ExpandingSpacer { - } } @@ -344,15 +308,15 @@ SectionLayout { Label { text: "W" - width: 28 + width: 12 } SpinBox { backendValue: backendValues.Layout_maximumWidth - maximumValue: 0xffff minimumValue: 0 + maximumValue: 0xffff + realDragRange: 5000 decimals: 0 - implicitWidth: root.spinBoxWidth } Item { @@ -362,102 +326,15 @@ SectionLayout { Label { text: "H" - width: 28 + width: 12 } SpinBox { backendValue: backendValues.Layout_maximumHeight - maximumValue: 0xffff minimumValue: 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 + realDragRange: 5000 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 { - } } @@ -471,19 +348,15 @@ SectionLayout { Item { height: 4 - width: 28 + width: 12 } SpinBox { backendValue: backendValues.Layout_rowSpan - maximumValue: 0xffff minimumValue: 0 + maximumValue: 0xffff + realDragRange: 5000 decimals: 0 - implicitWidth: root.spinBoxWidth - } - - ExpandingSpacer { - } } @@ -497,19 +370,15 @@ SectionLayout { Item { height: 4 - width: 28 + width: 12 } SpinBox { backendValue: backendValues.Layout_columnSpan - maximumValue: 0xffff minimumValue: 0 + maximumValue: 0xffff + realDragRange: 5000 decimals: 0 - implicitWidth: root.spinBoxWidth - } - - ExpandingSpacer { - } } } diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/LayoutSection.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/LayoutSection.qml index f211a4b37f2..7eeb8d22856 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/LayoutSection.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/LayoutSection.qml @@ -26,7 +26,8 @@ import QtQuick 2.0 import HelperWidgets 2.0 import QtQuick.Layouts 1.0 -import QtQuick.Controls 1.0 as Controls +import StudioControls 1.0 as StudioControls +import StudioTheme 1.0 as StudioTheme Section { anchors.left: parent.left @@ -167,6 +168,5 @@ Section { verticalAnchor: true buttonRow.visible: false } - } } diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/MarginSection.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/MarginSection.qml index 63b8f8702b4..0143674c9a9 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/MarginSection.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/MarginSection.qml @@ -34,6 +34,12 @@ Section { anchors.left: parent.left anchors.right: parent.right + property alias backendValueTopMargin: spinBoxTopMargin.backendValue + property alias backendValueBottomMargin: spinBoxBottomMargin.backendValue + property alias backendValueLeftMargin: spinBoxLeftMargin.backendValue + property alias backendValueRightMargin: spinBoxRightMargin.backendValue + property alias backendValueMargins: spinBoxMargins.backendValue + SectionLayout { Label { text: qsTr("Vertical") @@ -45,8 +51,10 @@ Section { width: 42 } SpinBox { + id: spinBoxTopMargin minimumValue: -10000 maximumValue: 10000 + realDragRange: 5000 decimals: 0 backendValue: backendValues.topMargin Layout.fillWidth: true @@ -62,8 +70,10 @@ Section { width: 42 } SpinBox { + id: spinBoxBottomMargin minimumValue: -10000 maximumValue: 10000 + realDragRange: 5000 decimals: 0 backendValue: backendValues.bottomMargin Layout.fillWidth: true @@ -80,8 +90,10 @@ Section { width: 42 } SpinBox { + id: spinBoxLeftMargin minimumValue: -10000 maximumValue: 10000 + realDragRange: 5000 decimals: 0 backendValue: backendValues.leftMargin Layout.fillWidth: true @@ -97,8 +109,10 @@ Section { width: 42 } SpinBox { + id: spinBoxRightMargin minimumValue: -10000 maximumValue: 10000 + realDragRange: 5000 decimals: 0 backendValue: backendValues.rightMargin Layout.fillWidth: true @@ -111,8 +125,10 @@ Section { } SecondColumnLayout { SpinBox { + id: spinBoxMargins minimumValue: -10000 maximumValue: 10000 + realDragRange: 5000 decimals: 0 backendValue: backendValues.margins Layout.fillWidth: true diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/PaddingSection.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/PaddingSection.qml index de4bf9605b0..318807eb55d 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/PaddingSection.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/PaddingSection.qml @@ -47,6 +47,7 @@ Section { SpinBox { maximumValue: 10000 minimumValue: -10000 + realDragRange: 5000 decimals: 0 backendValue: backendValues.topPadding Layout.fillWidth: true @@ -64,6 +65,7 @@ Section { SpinBox { maximumValue: 10000 minimumValue: -10000 + realDragRange: 5000 decimals: 0 backendValue: backendValues.bottomPadding Layout.fillWidth: true @@ -82,6 +84,7 @@ Section { SpinBox { maximumValue: 10000 minimumValue: -10000 + realDragRange: 5000 decimals: 0 backendValue: backendValues.leftPadding Layout.fillWidth: true @@ -99,6 +102,7 @@ Section { SpinBox { maximumValue: 10000 minimumValue: -10000 + realDragRange: 5000 decimals: 0 backendValue: backendValues.rightPadding Layout.fillWidth: true @@ -113,6 +117,7 @@ Section { SpinBox { maximumValue: 10000 minimumValue: -10000 + realDragRange: 5000 decimals: 0 backendValue: backendValues.padding Layout.fillWidth: true