fix layouting of dialogs of both formfactors

This commit is contained in:
Marco Martin 2011-11-25 19:59:00 +01:00
parent 41dadc7729
commit 18aadf9e24
3 changed files with 14 additions and 18 deletions

View File

@ -134,8 +134,7 @@ Item {
Item { Item {
id: contentItem id: contentItem
onChildrenRectChanged: mainItem.width = childrenRect.width onChildrenRectChanged: mainItem.width = Math.max(childrenRect.width, buttonItem.childrenRect.width)
clip: true
anchors { anchors {
top: titleBar.bottom top: titleBar.bottom
left: parent.left left: parent.left
@ -153,6 +152,7 @@ Item {
left: parent.left left: parent.left
right: parent.right right: parent.right
bottom: parent.bottom bottom: parent.bottom
bottomMargin: 4
} }
} }
} }

View File

@ -82,14 +82,14 @@ Dialog {
QtObject { QtObject {
id: internal id: internal
function buttonWidth() { /*function buttonWidth() {
switch (buttonTexts.length) { switch (buttonTexts.length) {
case 0: return 0 case 0: return 0
case 1: return Math.round((800 - 3 * 4) / 2) case 1: return Math.round((800 - 3 * 4) / 2)
default: return (buttonContainer.width - (buttonTexts.length + 1) * default: return (buttonContainer.width - (buttonTexts.length + 1) *
4) / buttonTexts.length 4) / buttonTexts.length
} }
} }*/
function iconSource() { function iconSource() {
return root.titleIcon return root.titleIcon
@ -145,20 +145,13 @@ Dialog {
} }
} }
buttons: Item { buttons: Row {
id: buttonContainer id: buttonRow
LayoutMirroring.enabled: false LayoutMirroring.enabled: false
LayoutMirroring.childrenInherit: true LayoutMirroring.childrenInherit: true
objectName: "buttonRow"
width: parent.width anchors.centerIn: parent
height: buttonTexts.length ? 48 + 2 * 2 : 0 spacing: 4
Row {
id: buttonRow
objectName: "buttonRow"
anchors.centerIn: parent
spacing: 4
}
} }
} }

View File

@ -112,6 +112,7 @@ Item {
} }
mainItem: Item { mainItem: Item {
id: mainItem
width: theme.defaultFont.mSize.width * 40 width: theme.defaultFont.mSize.width * 40
height: titleBar.childrenRect.height + contentItem.childrenRect.height + buttonItem.childrenRect.height height: titleBar.childrenRect.height + contentItem.childrenRect.height + buttonItem.childrenRect.height
@ -133,6 +134,8 @@ Item {
Item { Item {
id: contentItem id: contentItem
onChildrenRectChanged: mainItem.width = Math.max(childrenRect.width, buttonItem.childrenRect.width)
clip: true clip: true
anchors { anchors {
top: titleBar.bottom top: titleBar.bottom
@ -146,15 +149,15 @@ Item {
id: buttonItem id: buttonItem
height: childrenRect.height height: childrenRect.height
clip: true
anchors { anchors {
left: parent.left left: parent.left
right: parent.right right: parent.right
bottom: parent.bottom bottom: parent.bottom
bottomMargin: 4
} }
} }
} }
Component.onCompleted: { Component.onCompleted: {
rootItem = Utils.rootObject() rootItem = Utils.rootObject()
} }