Fix the calendar dialog popping up in the wrong place the first time.

The issue is that we are using a QProxyWidget, and it seems that QWidgets don't have a sensible size() until they're shown for the first time.  So we use sizeHint() (or effectiveSizeHint() in this case) instead.

The only issue I can see is that if the widget passed to the dialog is in a layout, its size() and effectiveSizeHint(Qt::PreferredSize) might not match.  Is this something we need to deal with?  If so, how?

CCMAIL: plasma-devel@kde.org


svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=859660
This commit is contained in:
Alex Merry 2008-09-10 21:28:16 +00:00
parent 12443b7d98
commit 057ad8b01a

View File

@ -94,12 +94,18 @@ void DialogPrivate::themeUpdated()
void DialogPrivate::adjustView()
{
if (view && widget) {
kDebug() << "resize the view.";
QSize prevSize = q->size();
kDebug() << "Widget size:" << widget->size()
<< "| Widget size hint:" << widget->effectiveSizeHint(Qt::PreferredSize)
<< "| Widget bounding rect:" << widget->boundingRect();
QRectF boundingRect = widget->boundingRect();
boundingRect.setSize(widget->effectiveSizeHint(Qt::PreferredSize));
//reposition and resize the view.
view->setSceneRect(widget->mapToScene(widget->boundingRect()).boundingRect());
view->resize(widget->size().toSize());
view->setSceneRect(widget->mapToScene(boundingRect).boundingRect());
view->resize(view->mapFromScene(view->sceneRect()).boundingRect().size());
view->centerOn(widget);
//set the sizehints correctly: