make dialogs layout work a bit better
This commit is contained in:
parent
ed4504f731
commit
01e84b4483
@ -48,8 +48,8 @@ import "." 0.1
|
|||||||
Item {
|
Item {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
width: 600
|
width: 300
|
||||||
height: 400
|
height: 200
|
||||||
|
|
||||||
property alias title: titleBar.children
|
property alias title: titleBar.children
|
||||||
property alias content: contentItem.children
|
property alias content: contentItem.children
|
||||||
@ -129,7 +129,6 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Consume all key events that are not processed by children
|
// Consume all key events that are not processed by children
|
||||||
Keys.onPressed: event.accepted = true
|
Keys.onPressed: event.accepted = true
|
||||||
Keys.onReleased: event.accepted = true
|
Keys.onReleased: event.accepted = true
|
||||||
@ -148,14 +147,19 @@ Item {
|
|||||||
id: contentItem
|
id: contentItem
|
||||||
|
|
||||||
clip: true
|
clip: true
|
||||||
onChildrenRectChanged: {
|
|
||||||
|
function adjustSize() {
|
||||||
root.width = Math.max(childrenRect.width, buttonItem.childrenRect.width) + dialog.margins.left + dialog.margins.right
|
root.width = Math.max(childrenRect.width, buttonItem.childrenRect.width) + dialog.margins.left + dialog.margins.right
|
||||||
root.height = childrenRect.height + titleBar.height + buttonItem.height + dialog.margins.top + dialog.margins.bottom
|
|
||||||
|
root.height = Math.max(children[0].implicitHeight, childrenRect.height) + titleBar.height + buttonItem.height + dialog.margins.top + dialog.margins.bottom
|
||||||
}
|
}
|
||||||
width: childrenRect.width > 0 ? Math.min(childrenRect.width, parent.width) : parent.width
|
onChildrenRectChanged: adjustSize()
|
||||||
|
Component.onCompleted: adjustSize()
|
||||||
|
|
||||||
anchors {
|
anchors {
|
||||||
top: titleBar.bottom
|
top: titleBar.bottom
|
||||||
horizontalCenter: parent.horizontalCenter
|
left: parent.left
|
||||||
|
right: parent.right
|
||||||
bottom: buttonItem.top
|
bottom: buttonItem.top
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -164,6 +168,8 @@ Item {
|
|||||||
id: buttonItem
|
id: buttonItem
|
||||||
|
|
||||||
height: childrenRect.height
|
height: childrenRect.height
|
||||||
|
onChildrenRectChanged: contentItem.adjustSize()
|
||||||
|
Component.onCompleted: contentItem.adjustSize()
|
||||||
anchors {
|
anchors {
|
||||||
left: parent.left
|
left: parent.left
|
||||||
right: parent.right
|
right: parent.right
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
import QtQuick 1.1
|
import QtQuick 1.1
|
||||||
|
import org.kde.plasma.extras 0.1 as PlasmaExtras
|
||||||
import "." 0.1
|
import "." 0.1
|
||||||
|
|
||||||
CommonDialog {
|
CommonDialog {
|
||||||
@ -49,8 +49,8 @@ CommonDialog {
|
|||||||
objectName: "root"
|
objectName: "root"
|
||||||
|
|
||||||
property string message
|
property string message
|
||||||
property string acceptButtonText
|
property string acceptButtonText: i18n("Ok")
|
||||||
property string rejectButtonText
|
property string rejectButtonText: i18n("Cancel")
|
||||||
|
|
||||||
onAcceptButtonTextChanged: internal.updateButtonTexts()
|
onAcceptButtonTextChanged: internal.updateButtonTexts()
|
||||||
onRejectButtonTextChanged: internal.updateButtonTexts()
|
onRejectButtonTextChanged: internal.updateButtonTexts()
|
||||||
@ -63,22 +63,24 @@ CommonDialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
content: Item {
|
content: Item {
|
||||||
implicitHeight: Math.min(theme.defaultFont.mSize.height*12, label.paintedHeight+12)
|
implicitHeight: Math.min(theme.defaultFont.mSize.height * 12, label.paintedHeight + 32)
|
||||||
width: parent.width
|
width: Math.max(parent.width, theme.defaultFont.mSize.width*20)
|
||||||
|
height: Math.max(parent.height, implicitHeight)
|
||||||
|
|
||||||
Item {
|
PlasmaExtras.ScrollArea {
|
||||||
anchors {
|
anchors {
|
||||||
top: parent.top; topMargin: 6
|
top: parent.top
|
||||||
bottom: parent.bottom; bottomMargin: 6
|
topMargin: 6
|
||||||
left: parent.left; leftMargin: 6
|
bottom: parent.bottom
|
||||||
|
bottomMargin: 6
|
||||||
|
left: parent.left
|
||||||
|
leftMargin: 6
|
||||||
right: parent.right
|
right: parent.right
|
||||||
}
|
}
|
||||||
|
|
||||||
Flickable {
|
Flickable {
|
||||||
id: flickable
|
id: flickable
|
||||||
width: parent.width
|
anchors.fill: parent
|
||||||
height: parent.height
|
|
||||||
anchors { left: parent.left; top: parent.top }
|
|
||||||
contentHeight: label.paintedHeight
|
contentHeight: label.paintedHeight
|
||||||
flickableDirection: Flickable.VerticalFlick
|
flickableDirection: Flickable.VerticalFlick
|
||||||
clip: true
|
clip: true
|
||||||
@ -93,16 +95,6 @@ CommonDialog {
|
|||||||
horizontalAlignment: Text.AlignLeft
|
horizontalAlignment: Text.AlignLeft
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ScrollBar {
|
|
||||||
id: scrollBar
|
|
||||||
height: parent.height
|
|
||||||
anchors { top: flickable.top; right: flickable.right }
|
|
||||||
flickableItem: flickable
|
|
||||||
interactive: false
|
|
||||||
orientation: Qt.Vertical
|
|
||||||
//platformInverted: root.platformInverted
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,7 +108,8 @@ CommonDialog {
|
|||||||
id: contentItem
|
id: contentItem
|
||||||
property alias filterText: filterField.filterText
|
property alias filterText: filterField.filterText
|
||||||
implicitWidth: theme.defaultFont.mSize.width * 40
|
implicitWidth: theme.defaultFont.mSize.width * 40
|
||||||
height: theme.defaultFont.mSize.height * 12
|
implicitHeight: theme.defaultFont.mSize.height * 12
|
||||||
|
height: implicitHeight
|
||||||
|
|
||||||
TextField {
|
TextField {
|
||||||
id: filterField
|
id: filterField
|
||||||
|
Loading…
x
Reference in New Issue
Block a user