various cleanups

svn path=/trunk/KDE/kdelibs/; revision=1217825
This commit is contained in:
Aaron J. Seigo 2011-01-28 22:30:54 +00:00
parent 2a916cb089
commit 56fc44f841
3 changed files with 10 additions and 7 deletions

View File

@ -528,7 +528,7 @@ void ContainmentPrivate::checkContainmentFurniture()
Corona *Containment::corona() const
{
return dynamic_cast<Corona*>(scene());
return qobject_cast<Corona*>(scene());
}
void Containment::mouseMoveEvent(QGraphicsSceneMouseEvent *event)

View File

@ -436,14 +436,14 @@ int Corona::numScreens() const
QRect Corona::screenGeometry(int id) const
{
Q_UNUSED(id);
if (views().isEmpty()) {
return sceneRect().toRect();
} else {
QGraphicsView *v = views()[0];
QGraphicsView *v = views().value(0);
if (v) {
QRect r = sceneRect().toRect();
r.moveTo(v->mapToGlobal(QPoint(0, 0)));
return r;
}
return sceneRect().toRect();
}
QRegion Corona::availableScreenRegion(int id) const

View File

@ -913,8 +913,11 @@ void ExtenderPrivate::adjustSize()
{
QRect screenRect;
QSizeF size = mainWidget->effectiveSizeHint(Qt::PreferredSize);
if (applet && applet.data()->containment() && applet.data()->containment()->corona()) {
screenRect = applet.data()->containment()->corona()->screenGeometry(applet.data()->containment()->screen());
if (applet) {
Containment *containment = applet.data()->containment();
if (containment && containment->corona()) {
screenRect = containment->corona()->screenGeometry(containment->screen());
}
}
q->resize(qMin(screenRect.width()/3, (int)size.width()),
qMin(screenRect.height()/3, (int)size.height()));