alter the toolbox backer layout when the items change

CCBUG:224278

svn path=/branches/KDE/4.4/kdelibs/; revision=1080325
This commit is contained in:
Aaron J. Seigo 2010-01-26 06:09:01 +00:00
parent 88216206bb
commit 635aba8ddf
3 changed files with 26 additions and 10 deletions

View File

@ -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<ToolType, IconWidget *> t = tools();
QMapIterator<ToolType, IconWidget *> 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)

View File

@ -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;
};

View File

@ -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();