make dialog size as small as possible

also, when to title text is shown, delete the title bar
This commit is contained in:
Marco Martin 2012-11-30 12:01:25 +01:00
parent 57e77a8591
commit 222c969bdd
3 changed files with 19 additions and 14 deletions

View File

@ -127,6 +127,7 @@ Dialog {
title: PlasmaCore.FrameSvgItem {
imagePath: "widgets/extender-dragger"
prefix: "root"
visible: titleAreaText.text != ""
anchors.left: parent.left
anchors.right: parent.right
//FIXME: +5 because of Plasma::Dialog margins

View File

@ -248,8 +248,8 @@ Item {
Item {
id: dialogLayout
width: theme.defaultFont.mSize.width * 40
height: titleBar.childrenRect.height + contentItem.childrenRect.height + buttonItem.childrenRect.height + 8
width: Math.max(buttonItem.childrenRect.width, Math.min(contentItem.childrenRect.width, theme.defaultFont.mSize.width * 30))
height: titleBar.height + contentItem.childrenRect.height + buttonItem.childrenRect.height + 10
parent: internalLoader.dialog ? internalLoader.dialog : internalLoader.inlineDialog
// Consume all key events that are not processed by children
@ -259,7 +259,7 @@ Item {
Item {
id: titleBar
height: childrenRect.height
height: children.length > 0 && children[0].visible ? childrenRect.height : 0
anchors {
top: parent.top
left: parent.left
@ -270,15 +270,13 @@ Item {
Item {
id: contentItem
onChildrenRectChanged: mainItem.width = Math.max(childrenRect.width, buttonItem.childrenRect.width)
clip: true
anchors {
top: titleBar.bottom
left: parent.left
right: parent.right
bottom: buttonItem.top
bottomMargin: 8
bottomMargin: 6
}
}

View File

@ -63,16 +63,19 @@ CommonDialog {
}
content: Item {
implicitHeight: Math.min(theme.defaultFont.mSize.height * 12, label.paintedHeight + 32)
width: Math.max(parent.width, theme.defaultFont.mSize.width*20)
height: Math.max(parent.height, implicitHeight)
implicitWidth: Math.max(theme.defaultFont.mSize.width * 15, Math.min(label.implicitWidth+12, theme.defaultFont.mSize.width * 25))
implicitHeight: Math.min(theme.defaultFont.mSize.height * 12, label.paintedHeight + 6)
width: implicitWidth
height: implicitHeight
PlasmaExtras.ScrollArea {
anchors {
top: parent.top
topMargin: 6
bottom: parent.bottom
bottomMargin: 6
left: parent.left
leftMargin: 6
right: parent.right
@ -83,16 +86,19 @@ CommonDialog {
anchors.fill: parent
contentHeight: label.paintedHeight
flickableDirection: Flickable.VerticalFlick
clip: true
interactive: contentHeight > height
Label {
id: label
anchors { right: parent.right }
width: flickable.width
anchors {
top: parent.top
right: parent.right
}
width: flickable.width
height: paintedHeight
wrapMode: Text.WordWrap
text: root.message
horizontalAlignment: Text.AlignLeft
horizontalAlignment: lineCount > 1 ? Text.AlignLeft : Text.AlignHCenter
}
}
}