From 8a3f38511d1eab642b990df52a14d706a861e9cf Mon Sep 17 00:00:00 2001 From: Vishesh Handa Date: Thu, 28 Aug 2014 16:20:14 +0200 Subject: [PATCH] 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. --- src/plasmaquick/dialog.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/plasmaquick/dialog.cpp b/src/plasmaquick/dialog.cpp index 1b7da28c6..55303267b 100644 --- a/src/plasmaquick/dialog.cpp +++ b/src/plasmaquick/dialog.cpp @@ -298,6 +298,11 @@ void DialogPrivate::updateMinimumWidth() q->setX(q->x() + (oldWidth - q->size().width())); } repositionIfOffScreen(); + if (visualParent) { + const QRect geom(q->popupPosition(visualParent, q->size()), q->size()); + q->setGeometry(geom); + } + updateTheme(); QObject::connect(mainItem, SIGNAL(widthChanged()), q, SLOT(slotMainItemSizeChanged())); @@ -331,6 +336,11 @@ void DialogPrivate::updateMinimumHeight() q->setY(q->y() + (oldHeight - q->size().height())); } repositionIfOffScreen(); + if (visualParent) { + const QRect geom(q->popupPosition(visualParent, q->size()), q->size()); + q->setGeometry(geom); + } + updateTheme(); QObject::connect(mainItem, SIGNAL(widthChanged()), q, SLOT(slotMainItemSizeChanged())); @@ -355,11 +365,15 @@ void DialogPrivate::updateMaximumWidth() q->setMaximumWidth(maximumWidth + margin->left() + margin->right()); q->setWidth(qBound(q->minimumWidth(), q->width(), q->maximumWidth())); - mainItem->setWidth(q->width() - margin->left() - margin->right()); frameSvgItem->setWidth(q->width()); repositionIfOffScreen(); + if (visualParent) { + const QRect geom(q->popupPosition(visualParent, q->size()), q->size()); + q->setGeometry(geom); + } + updateTheme(); QObject::connect(mainItem, SIGNAL(widthChanged()), q, SLOT(slotMainItemSizeChanged())); @@ -389,6 +403,11 @@ void DialogPrivate::updateMaximumHeight() frameSvgItem->setHeight(q->height()); repositionIfOffScreen(); + if (visualParent) { + const QRect geom(q->popupPosition(visualParent, q->size()), q->size()); + q->setGeometry(geom); + } + updateTheme(); QObject::connect(mainItem, SIGNAL(widthChanged()), q, SLOT(slotMainItemSizeChanged()));