better manage save and restore of popup size of popupapplets when the

content is a qgraphicswidget (i.e it works now), also ensure the default
size when it first pops up is the gwidget's preferred size

svn path=/trunk/KDE/kdelibs/; revision=902439
This commit is contained in:
Marco Martin 2008-12-28 12:54:48 +00:00
parent 548b02c948
commit 996a1277bc
2 changed files with 24 additions and 6 deletions

View File

@ -397,6 +397,15 @@ void Dialog::hideEvent(QHideEvent * event)
void Dialog::showEvent(QShowEvent * event)
{
Q_UNUSED(event);
//check if the widget size is still synced with the view
if (d->widget && d->view && d->widget->size().toSize() != d->view->size()) {
d->widget->resize(d->view->size());
d->view->setSceneRect(d->widget->mapToScene(d->widget->boundingRect()).boundingRect());
d->view->centerOn(d->widget);
}
emit dialogVisible(true);
}

View File

@ -291,8 +291,6 @@ void PopupAppletPrivate::popupConstraintsEvent(Plasma::Constraints constraints)
KWindowSystem::setState(dialog->winId(), NET::SkipTaskbar | NET::SkipPager);
dialog->installEventFilter(q);
QObject::connect(dialog, SIGNAL(dialogResized()), q, SLOT(dialogSizeChanged()));
QObject::connect(dialog, SIGNAL(dialogVisible(bool)), q, SLOT(dialogStatusChanged(bool)));
q->setMinimumSize(QSize(0, 0));
if (gWidget) {
Corona *corona = qobject_cast<Corona *>(gWidget->scene());
@ -307,10 +305,13 @@ void PopupAppletPrivate::popupConstraintsEvent(Plasma::Constraints constraints)
l_layout->setSpacing(0);
l_layout->setMargin(0);
l_layout->addWidget(qWidget);
}
dialog->adjustSize();
}
QObject::connect(dialog, SIGNAL(dialogResized()), q, SLOT(dialogSizeChanged()));
QObject::connect(dialog, SIGNAL(dialogVisible(bool)), q, SLOT(dialogStatusChanged(bool)));
}
dialog->adjustSize();
if (icon && lay) {
lay->addItem(icon);
@ -470,7 +471,7 @@ void PopupAppletPrivate::togglePopup()
updateDialogPosition();
KWindowSystem::setState(dialog->winId(), NET::SkipTaskbar | NET::SkipPager);
dialog->show();
dialog->adjustSize();
dialog->resize(dialog->size());
}
dialog->clearFocus();
@ -521,9 +522,17 @@ void PopupAppletPrivate::updateDialogPosition()
Q_ASSERT(q->containment());
Q_ASSERT(q->containment()->corona());
const int width = qMin(sizeGroup.readEntry("DialogWidth", 0),
int preferredWidth = 0;
int preferredHeight = 0;
if (dialog->graphicsWidget()) {
preferredWidth = dialog->graphicsWidget()->preferredSize().width();
preferredHeight = dialog->graphicsWidget()->preferredSize().height();
}
const int width = qMin(sizeGroup.readEntry("DialogWidth", preferredWidth),
q->containment()->corona()->screenGeometry(-1).width() - 50);
const int height = qMin(sizeGroup.readEntry("DialogHeight", 0),
const int height = qMin(sizeGroup.readEntry("DialogHeight", preferredHeight),
q->containment()->corona()->screenGeometry(-1).height() - 50);
QSize saved(width, height);