fix dialog default size

This commit is contained in:
Marco Martin 2012-09-18 18:07:11 +02:00
parent 279d3727a5
commit e9cee7f69c
2 changed files with 15 additions and 9 deletions

View File

@ -189,9 +189,9 @@ void FullScreenWindow::setMainItem(QGraphicsObject *mainItem)
mainItem->setParentItem(0);
mainItem->setParent(this);
m_scene = mainItem->scene();
}
m_view->resize(mainItem->boundingRect().size().toSize());
mainItem->installEventFilter(this);
}
//if this is called in Compenent.onCompleted we have to wait a loop the item is added to a scene
QTimer::singleShot(0, this, SLOT(syncViewToMainItem()));
@ -243,9 +243,12 @@ void FullScreenWindow::syncViewToMainItem()
m_view->setScene(scene);
QRectF itemGeometry(QPointF(m_mainItem.data()->x(), m_mainItem.data()->y()),
QSizeF(m_mainItem.data()->boundingRect().size()));
if (m_declarativeItemContainer) {
m_view->resize(m_declarativeItemContainer->size().toSize());
m_view->resize(itemGeometry.size().toSize());
m_view->setSceneRect(m_declarativeItemContainer->geometry());
} else {
QRectF itemGeometry(QPointF(m_mainItem.data()->x(), m_mainItem.data()->y()),
QSizeF(m_mainItem.data()->boundingRect().size()));

View File

@ -48,8 +48,8 @@ import "." 0.1
Item {
id: root
width: Math.max(buttonItem.childrenRect.width + dialog.margins.left + dialog.margins.right + theme.defaultFont.mSize.width * 4, theme.defaultFont.mSize.width * 45)
height: titleBar.childrenRect.height + contentItem.childrenRect.height + buttonItem.childrenRect.height + 8 + dialog.margins.top + dialog.margins.bottom
width: 600
height: 400
property alias title: titleBar.children
property alias content: contentItem.children
@ -136,7 +136,7 @@ Item {
Item {
id: titleBar
height: childrenRect.height
height: Math.max(theme.defaultFont.mSize.height * 1.5, childrenRect.height)
anchors {
top: parent.top
left: parent.left
@ -148,11 +148,14 @@ Item {
id: contentItem
clip: true
onChildrenRectChanged: mainItem.width = Math.max(childrenRect.width, buttonItem.childrenRect.width) + dialog.margins.left + dialog.margins.right
onChildrenRectChanged: {
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
}
width: childrenRect.width > 0 ? Math.min(childrenRect.width, parent.width) : parent.width
anchors {
top: titleBar.bottom
left: parent.left
right: parent.right
horizontalCenter: parent.horizontalCenter
bottom: buttonItem.top
}
}