From 18aadf9e24c0d117fbc12552f7aadac2da1d1158 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Fri, 25 Nov 2011 19:59:00 +0100 Subject: [PATCH] fix layouting of dialogs of both formfactors --- .../platformcomponents/touch/Dialog.qml | 4 ++-- .../plasmacomponents/qml/CommonDialog.qml | 21 +++++++------------ .../plasmacomponents/qml/Dialog.qml | 7 +++++-- 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/declarativeimports/plasmacomponents/platformcomponents/touch/Dialog.qml b/declarativeimports/plasmacomponents/platformcomponents/touch/Dialog.qml index 94bbc5b2b..65a0f443f 100644 --- a/declarativeimports/plasmacomponents/platformcomponents/touch/Dialog.qml +++ b/declarativeimports/plasmacomponents/platformcomponents/touch/Dialog.qml @@ -134,8 +134,7 @@ Item { Item { id: contentItem - onChildrenRectChanged: mainItem.width = childrenRect.width - clip: true + onChildrenRectChanged: mainItem.width = Math.max(childrenRect.width, buttonItem.childrenRect.width) anchors { top: titleBar.bottom left: parent.left @@ -153,6 +152,7 @@ Item { left: parent.left right: parent.right bottom: parent.bottom + bottomMargin: 4 } } } diff --git a/declarativeimports/plasmacomponents/qml/CommonDialog.qml b/declarativeimports/plasmacomponents/qml/CommonDialog.qml index 3aeb5724e..61ff7de2d 100644 --- a/declarativeimports/plasmacomponents/qml/CommonDialog.qml +++ b/declarativeimports/plasmacomponents/qml/CommonDialog.qml @@ -82,14 +82,14 @@ Dialog { QtObject { id: internal - function buttonWidth() { + /*function buttonWidth() { switch (buttonTexts.length) { case 0: return 0 case 1: return Math.round((800 - 3 * 4) / 2) default: return (buttonContainer.width - (buttonTexts.length + 1) * 4) / buttonTexts.length } - } + }*/ function iconSource() { return root.titleIcon @@ -145,20 +145,13 @@ Dialog { } } - buttons: Item { - id: buttonContainer + buttons: Row { + id: buttonRow LayoutMirroring.enabled: false LayoutMirroring.childrenInherit: true - - width: parent.width - height: buttonTexts.length ? 48 + 2 * 2 : 0 - - Row { - id: buttonRow - objectName: "buttonRow" - anchors.centerIn: parent - spacing: 4 - } + objectName: "buttonRow" + anchors.centerIn: parent + spacing: 4 } } diff --git a/declarativeimports/plasmacomponents/qml/Dialog.qml b/declarativeimports/plasmacomponents/qml/Dialog.qml index 0fa1c9b63..c20004335 100644 --- a/declarativeimports/plasmacomponents/qml/Dialog.qml +++ b/declarativeimports/plasmacomponents/qml/Dialog.qml @@ -112,6 +112,7 @@ Item { } mainItem: Item { + id: mainItem width: theme.defaultFont.mSize.width * 40 height: titleBar.childrenRect.height + contentItem.childrenRect.height + buttonItem.childrenRect.height @@ -133,6 +134,8 @@ Item { Item { id: contentItem + onChildrenRectChanged: mainItem.width = Math.max(childrenRect.width, buttonItem.childrenRect.width) + clip: true anchors { top: titleBar.bottom @@ -146,15 +149,15 @@ Item { id: buttonItem height: childrenRect.height - clip: true anchors { left: parent.left right: parent.right bottom: parent.bottom + bottomMargin: 4 } } } - + Component.onCompleted: { rootItem = Utils.rootObject() }