diff options
author | Alberto Mardegan <mardy@users.sourceforge.net> | 2015-11-12 01:56:30 +0200 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@theqtcompany.com> | 2016-04-13 20:15:18 +0000 |
commit | 10f0ae7c571b7e0de41d5fdc5627db6a1ddeb926 (patch) | |
tree | 622ecd0110a02a3b2cdc5d52f1b8aeb08639f1f2 /src/dialogs | |
parent | 726b6ee9b43652ef198a7df590b08e641dd69377 (diff) | |
download | qtquickcontrols-10f0ae7c571b7e0de41d5fdc5627db6a1ddeb926.tar.gz |
Dialog: allow proper resize and default size for content
Currently Dialog use implicitly positioned items as content. This makes
impossible to use item, that can be properly resized with change of
dialog window size and has proper default size (set implicit width and
height).
This change made it use implicit size if there is one item or fallback
to previous algorithm, that use childrenRect for explicitly sized and
positioned items, so it won't break behavior of the existing
applications.
[ChangeLog][Dialog] Proper resize and default size for content
Task-number: QTBUG-49058
Change-Id: I7fa4da7d5fd39d47f60ba9f43c88f78e75739b0a
Initial-patch-by: Nikita Krupenko <krnekit@gmail.com>
Reviewed-by: Nikita Krupenko <krnekit@gmail.com>
Reviewed-by: Shawn Rutledge <shawn.rutledge@theqtcompany.com>
Diffstat (limited to 'src/dialogs')
-rw-r--r-- | src/dialogs/DefaultDialogWrapper.qml | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/dialogs/DefaultDialogWrapper.qml b/src/dialogs/DefaultDialogWrapper.qml index a34ee97d..531b5c02 100644 --- a/src/dialogs/DefaultDialogWrapper.qml +++ b/src/dialogs/DefaultDialogWrapper.qml @@ -50,13 +50,14 @@ AbstractDialog { id: content property real spacing: 6 property real outerSpacing: 12 - property real buttonsRowImplicitWidth: minimumWidth + property real buttonsRowImplicitHeight: 0 + property real buttonsRowImplicitWidth: Screen.pixelDensity * 50 property bool buttonsInSingleRow: defaultContentItem.width >= buttonsRowImplicitWidth property real minimumHeight: implicitHeight - property real minimumWidth: Screen.pixelDensity * 50 - implicitHeight: defaultContentItem.implicitHeight + spacing + outerSpacing * 2 + buttonsRight.implicitHeight + property real minimumWidth: implicitWidth + implicitHeight: defaultContentItem.implicitHeight + spacing + outerSpacing * 2 + Math.max(buttonsRight.implicitHeight, buttonsRowImplicitHeight) implicitWidth: Math.min(root.__maximumDimension, Math.max( - defaultContentItem.implicitWidth, buttonsRowImplicitWidth, Screen.pixelDensity * 50) + outerSpacing * 2); + defaultContentItem.implicitWidth, buttonsRowImplicitWidth, Screen.pixelDensity * 50) + outerSpacing * 2) color: palette.window Keys.onPressed: { event.accepted = true @@ -82,9 +83,14 @@ AbstractDialog { left: parent.left right: parent.right top: parent.top + bottom: buttonsLeft.implicitHeight ? buttonsLeft.top : buttonsRight.top margins: content.outerSpacing + bottomMargin: buttonsLeft.implicitHeight + buttonsRight.implicitHeight > 0 ? content.spacing : 0 } - implicitHeight: childrenRect.height + implicitHeight: children.length === 1 ? children[0].implicitHeight + : (children.length ? childrenRect.height : 0) + implicitWidth: children.length === 1 ? children[0].implicitWidth + : (children.length ? childrenRect.width : 0) } Flow { @@ -135,7 +141,9 @@ AbstractDialog { function setupButtons() { buttonsLeftRepeater.model = root.__standardButtonsLeftModel() buttonsRightRepeater.model = root.__standardButtonsRightModel() - if (buttonsLeftRepeater.count + buttonsRightRepeater.count < 2) + if (buttonsRightRepeater.model && buttonsRightRepeater.model.length > 0) + content.buttonsRowImplicitHeight = buttonsRight.visibleChildren[0].implicitHeight + if (buttonsLeftRepeater.count + buttonsRightRepeater.count < 1) return; var calcWidth = 0; @@ -150,7 +158,7 @@ AbstractDialog { for (var i = 0; i < buttonsRight.visibleChildren.length; ++i) calculateForButton(i, buttonsRight.visibleChildren[i]) - content.minimumWidth = calcWidth + content.outerSpacing * 2 + content.minimumWidth = Math.max(calcWidth + content.outerSpacing * 2, content.implicitWidth) for (i = 0; i < buttonsLeft.visibleChildren.length; ++i) calculateForButton(i, buttonsLeft.visibleChildren[i]) content.buttonsRowImplicitWidth = calcWidth + content.spacing |