fix dialog default size
This commit is contained in:
parent
279d3727a5
commit
e9cee7f69c
@ -189,10 +189,10 @@ void FullScreenWindow::setMainItem(QGraphicsObject *mainItem)
|
|||||||
mainItem->setParentItem(0);
|
mainItem->setParentItem(0);
|
||||||
mainItem->setParent(this);
|
mainItem->setParent(this);
|
||||||
m_scene = mainItem->scene();
|
m_scene = mainItem->scene();
|
||||||
|
m_view->resize(mainItem->boundingRect().size().toSize());
|
||||||
|
mainItem->installEventFilter(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
mainItem->installEventFilter(this);
|
|
||||||
|
|
||||||
//if this is called in Compenent.onCompleted we have to wait a loop the item is added to a scene
|
//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()));
|
QTimer::singleShot(0, this, SLOT(syncViewToMainItem()));
|
||||||
}
|
}
|
||||||
@ -243,9 +243,12 @@ void FullScreenWindow::syncViewToMainItem()
|
|||||||
m_view->setScene(scene);
|
m_view->setScene(scene);
|
||||||
|
|
||||||
|
|
||||||
|
QRectF itemGeometry(QPointF(m_mainItem.data()->x(), m_mainItem.data()->y()),
|
||||||
|
QSizeF(m_mainItem.data()->boundingRect().size()));
|
||||||
if (m_declarativeItemContainer) {
|
if (m_declarativeItemContainer) {
|
||||||
m_view->resize(m_declarativeItemContainer->size().toSize());
|
m_view->resize(itemGeometry.size().toSize());
|
||||||
m_view->setSceneRect(m_declarativeItemContainer->geometry());
|
m_view->setSceneRect(m_declarativeItemContainer->geometry());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
QRectF itemGeometry(QPointF(m_mainItem.data()->x(), m_mainItem.data()->y()),
|
QRectF itemGeometry(QPointF(m_mainItem.data()->x(), m_mainItem.data()->y()),
|
||||||
QSizeF(m_mainItem.data()->boundingRect().size()));
|
QSizeF(m_mainItem.data()->boundingRect().size()));
|
||||||
|
@ -48,8 +48,8 @@ import "." 0.1
|
|||||||
Item {
|
Item {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
width: Math.max(buttonItem.childrenRect.width + dialog.margins.left + dialog.margins.right + theme.defaultFont.mSize.width * 4, theme.defaultFont.mSize.width * 45)
|
width: 600
|
||||||
height: titleBar.childrenRect.height + contentItem.childrenRect.height + buttonItem.childrenRect.height + 8 + dialog.margins.top + dialog.margins.bottom
|
height: 400
|
||||||
|
|
||||||
property alias title: titleBar.children
|
property alias title: titleBar.children
|
||||||
property alias content: contentItem.children
|
property alias content: contentItem.children
|
||||||
@ -136,7 +136,7 @@ Item {
|
|||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: titleBar
|
id: titleBar
|
||||||
height: childrenRect.height
|
height: Math.max(theme.defaultFont.mSize.height * 1.5, childrenRect.height)
|
||||||
anchors {
|
anchors {
|
||||||
top: parent.top
|
top: parent.top
|
||||||
left: parent.left
|
left: parent.left
|
||||||
@ -148,11 +148,14 @@ Item {
|
|||||||
id: contentItem
|
id: contentItem
|
||||||
|
|
||||||
clip: true
|
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 {
|
anchors {
|
||||||
top: titleBar.bottom
|
top: titleBar.bottom
|
||||||
left: parent.left
|
horizontalCenter: parent.horizontalCenter
|
||||||
right: parent.right
|
|
||||||
bottom: buttonItem.top
|
bottom: buttonItem.top
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user