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