Dialog: Set the correct popup position on layout width/height change

We seem to have cases where once the dialog is visible and the visible
event is over, then the width/height updates itself, so we need to
reposition the dialog appropriately.
This commit is contained in:
Vishesh Handa 2014-08-28 16:20:14 +02:00
parent eb6ea04be7
commit 8a3f38511d

View File

@ -298,6 +298,11 @@ void DialogPrivate::updateMinimumWidth()
q->setX(q->x() + (oldWidth - q->size().width())); q->setX(q->x() + (oldWidth - q->size().width()));
} }
repositionIfOffScreen(); repositionIfOffScreen();
if (visualParent) {
const QRect geom(q->popupPosition(visualParent, q->size()), q->size());
q->setGeometry(geom);
}
updateTheme(); updateTheme();
QObject::connect(mainItem, SIGNAL(widthChanged()), q, SLOT(slotMainItemSizeChanged())); QObject::connect(mainItem, SIGNAL(widthChanged()), q, SLOT(slotMainItemSizeChanged()));
@ -331,6 +336,11 @@ void DialogPrivate::updateMinimumHeight()
q->setY(q->y() + (oldHeight - q->size().height())); q->setY(q->y() + (oldHeight - q->size().height()));
} }
repositionIfOffScreen(); repositionIfOffScreen();
if (visualParent) {
const QRect geom(q->popupPosition(visualParent, q->size()), q->size());
q->setGeometry(geom);
}
updateTheme(); updateTheme();
QObject::connect(mainItem, SIGNAL(widthChanged()), q, SLOT(slotMainItemSizeChanged())); QObject::connect(mainItem, SIGNAL(widthChanged()), q, SLOT(slotMainItemSizeChanged()));
@ -355,11 +365,15 @@ void DialogPrivate::updateMaximumWidth()
q->setMaximumWidth(maximumWidth + margin->left() + margin->right()); q->setMaximumWidth(maximumWidth + margin->left() + margin->right());
q->setWidth(qBound(q->minimumWidth(), q->width(), q->maximumWidth())); q->setWidth(qBound(q->minimumWidth(), q->width(), q->maximumWidth()));
mainItem->setWidth(q->width() - margin->left() - margin->right()); mainItem->setWidth(q->width() - margin->left() - margin->right());
frameSvgItem->setWidth(q->width()); frameSvgItem->setWidth(q->width());
repositionIfOffScreen(); repositionIfOffScreen();
if (visualParent) {
const QRect geom(q->popupPosition(visualParent, q->size()), q->size());
q->setGeometry(geom);
}
updateTheme(); updateTheme();
QObject::connect(mainItem, SIGNAL(widthChanged()), q, SLOT(slotMainItemSizeChanged())); QObject::connect(mainItem, SIGNAL(widthChanged()), q, SLOT(slotMainItemSizeChanged()));
@ -389,6 +403,11 @@ void DialogPrivate::updateMaximumHeight()
frameSvgItem->setHeight(q->height()); frameSvgItem->setHeight(q->height());
repositionIfOffScreen(); repositionIfOffScreen();
if (visualParent) {
const QRect geom(q->popupPosition(visualParent, q->size()), q->size());
q->setGeometry(geom);
}
updateTheme(); updateTheme();
QObject::connect(mainItem, SIGNAL(widthChanged()), q, SLOT(slotMainItemSizeChanged())); QObject::connect(mainItem, SIGNAL(widthChanged()), q, SLOT(slotMainItemSizeChanged()));