From fab0de787f4c1f66d6d340e92f220921146df260 Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Mon, 15 Dec 2008 18:29:45 +0000 Subject: [PATCH] consolidate the code paths in flushUpdatedConstraintsEvent, document it a bit better, and call layout()->updateGeometry() less often; sadly it's still needed otherwise the panel containment doesn't come up properly =/ hopefully Qt 4.5 will alleviate that issue svn path=/trunk/KDE/kdelibs/; revision=897317 --- applet.cpp | 84 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 43 insertions(+), 41 deletions(-) diff --git a/applet.cpp b/applet.cpp index 561ff62e2..e7e5e9397 100644 --- a/applet.cpp +++ b/applet.cpp @@ -882,28 +882,34 @@ void Applet::flushPendingConstraintsEvents() } } - if (c & Plasma::SizeConstraint && d->messageOverlay) { - d->messageOverlay->setGeometry(QRectF(QPointF(0, 0), geometry().size())); + if (c & Plasma::SizeConstraint) { + if (d->messageOverlay) { + d->messageOverlay->setGeometry(QRectF(QPointF(0, 0), geometry().size())); - QGraphicsItem *button = 0; - QList children = d->messageOverlay->QGraphicsItem::children(); + QGraphicsItem *button = 0; + QList children = d->messageOverlay->QGraphicsItem::children(); - if (!children.isEmpty()) { - button = children.first(); + if (!children.isEmpty()) { + button = children.first(); + } + + if (button) { + QSizeF s = button->boundingRect().size(); + button->setPos(d->messageOverlay->boundingRect().width() / 2 - s.width() / 2, + d->messageOverlay->boundingRect().height() / 2 - s.height() / 2); + } } - if (button) { - QSizeF s = button->boundingRect().size(); - button->setPos(d->messageOverlay->boundingRect().width() / 2 - s.width() / 2, - d->messageOverlay->boundingRect().height() / 2 - s.height() / 2); + if (d->busyWidget && d->busyWidget->isVisible()) { + int busySize = qMin(size().width(), size().height())/3; + QRect busyRect(0, 0, busySize, busySize); + busyRect.moveCenter(boundingRect().center().toPoint()); + d->busyWidget->setGeometry(busyRect); } - } - if (c & Plasma::SizeConstraint && d->busyWidget && d->busyWidget->isVisible()) { - int busySize = qMin(size().width(), size().height())/3; - QRect busyRect(0, 0, busySize, busySize); - busyRect.moveCenter(boundingRect().center().toPoint()); - d->busyWidget->setGeometry(busyRect); + if (d->started && layout()) { + layout()->updateGeometry(); + } } if (c & Plasma::FormFactorConstraint) { @@ -926,30 +932,29 @@ void Applet::flushPendingConstraintsEvents() } } - //enforce square size in panels - if ((c & Plasma::SizeConstraint || c & Plasma::FormFactorConstraint) && - aspectRatioMode() == Plasma::Square) { - if (formFactor() == Horizontal) { - setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding)); - } else if (formFactor() == Vertical) { - setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); - } + if (c & Plasma::SizeConstraint || c & Plasma::FormFactorConstraint) { + if (aspectRatioMode() == Plasma::Square) { + // enforce square size in panels + if (formFactor() == Horizontal) { + setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding)); + } else if (formFactor() == Vertical) { + setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); + } - updateGeometry(); - } - - //enforce a constrained square size in panels - if ((c & Plasma::SizeConstraint || c & Plasma::FormFactorConstraint) && - aspectRatioMode() == Plasma::ConstrainedSquare) { - if (formFactor() == Horizontal) { - setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding)); - } else if (formFactor() == Vertical) { - setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); - } - - updateGeometry(); + updateGeometry(); + } else if (aspectRatioMode() == Plasma::ConstrainedSquare) { + // enforce a constrained square size in panels + if (formFactor() == Horizontal) { + setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding)); + } else if (formFactor() == Vertical) { + setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); + } + + updateGeometry(); + } } + // now take care of constraints in special subclasses: Contaiment and PopupApplet Containment* containment = qobject_cast(this); if (isContainment() && containment) { containment->d->containmentConstraintsEvent(c); @@ -960,12 +965,9 @@ void Applet::flushPendingConstraintsEvents() popup->d->popupConstraintsEvent(c); } + // pass the constraint on to the actual subclass constraintsEvent(c); - if (layout()) { - layout()->updateGeometry(); - } - if (c & StartupCompletedConstraint) { // start up is done, we can now go do a mod timer if (d->modificationsTimerId > 0) {