diff --git a/private/desktoptoolbox.cpp b/private/desktoptoolbox.cpp index 02315dd0f..e96106177 100644 --- a/private/desktoptoolbox.cpp +++ b/private/desktoptoolbox.cpp @@ -523,9 +523,31 @@ void DesktopToolBox::showToolBox() } d->toolBacker->setZValue(zValue() + 1); - d->toolBacker->clearLayout(); d->toolBacker->setIsToolbar(isToolbar()); + adjustToolBackerGeometry(); + + d->toolBacker->setOpacity(0); + d->toolBacker->show(); + Plasma::Animation *fadeAnim = Animator::create(Animator::FadeAnimation, d->toolBacker); + fadeAnim->setTargetWidget(d->toolBacker); + fadeAnim->setProperty("startOpacity", 0); + fadeAnim->setProperty("targetOpacity", 1); + fadeAnim->start(QAbstractAnimation::DeleteWhenStopped); +} + +void DesktopToolBox::updateToolBox() +{ + adjustToolBackerGeometry(); +} + +void DesktopToolBox::adjustToolBackerGeometry() +{ + if (!d->toolBacker) { + return; + } + + d->toolBacker->clearLayout(); QMap t = tools(); QMapIterator it(t); while (it.hasNext()) { @@ -621,14 +643,6 @@ void DesktopToolBox::showToolBox() d->toolBacker->setPos(x, mapFromParent(QPointF(0, parentSize.height() - 5 - backerRect.height())).y()); } } - - d->toolBacker->setOpacity(0); - d->toolBacker->show(); - Plasma::Animation *fadeAnim = Animator::create(Animator::FadeAnimation, d->toolBacker); - fadeAnim->setTargetWidget(d->toolBacker); - fadeAnim->setProperty("startOpacity", 0); - fadeAnim->setProperty("targetOpacity", 1); - fadeAnim->start(QAbstractAnimation::DeleteWhenStopped); } void DesktopToolBox::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) diff --git a/private/desktoptoolbox_p.h b/private/desktoptoolbox_p.h index 8f0d83c3c..5b2b46a4a 100644 --- a/private/desktoptoolbox_p.h +++ b/private/desktoptoolbox_p.h @@ -60,6 +60,7 @@ public: public Q_SLOTS: void toolTipAboutToShow(); void toolTipHidden(); + void updateToolBox(); protected: void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); @@ -76,6 +77,7 @@ protected Q_SLOTS: */ void toggle(); private: + void adjustToolBackerGeometry(); DesktopToolBoxPrivate *d; }; diff --git a/private/internaltoolbox_p.h b/private/internaltoolbox_p.h index 5cde6882c..e5d47e9db 100644 --- a/private/internaltoolbox_p.h +++ b/private/internaltoolbox_p.h @@ -99,7 +99,7 @@ public Q_SLOTS: /** * re-show the toolbox, in case any tools have changed */ - void updateToolBox(); + virtual void updateToolBox(); protected: Containment *containment();