diff --git a/containment.cpp b/containment.cpp index 8e0bed7d8..173f1f038 100644 --- a/containment.cpp +++ b/containment.cpp @@ -67,6 +67,9 @@ #include "private/extenderitemmimedata_p.h" #include "private/paneltoolbox_p.h" +#include "plasma/plasma.h" +#include "animations/animation.h" + namespace Plasma { @@ -154,10 +157,6 @@ void Containment::init() setAcceptDrops(true); setAcceptsHoverEvents(true); - //TODO: would be nice to not do this on init, as it causes Animator to init - connect(Animator::self(), SIGNAL(animationFinished(QGraphicsItem*,Plasma::Animator::Animation)), - this, SLOT(containmentAppletAnimationComplete(QGraphicsItem*,Plasma::Animator::Animation))); - if (d->type == NoContainmentType) { setContainmentType(DesktopContainment); } @@ -953,17 +952,21 @@ void Containment::addApplet(Applet *applet, const QPointF &pos, bool delayInit) applet->installSceneEventFilter(this); //applet->setWindowFlags(Qt::Window); } + } else { applet->init(); - Animator::self()->animateItem(applet, Animator::AppearAnimation); + applet->setScale(0); + d->zoomAnim = Plasma::Animator::create(Plasma::Animator::ZoomAnimation); + connect(d->zoomAnim, SIGNAL(finished()), this, SLOT(containmentAppletAnimationComplete())); + d->zoomAnim->setWidgetToAnimate(applet); + d->zoomAnim->setProperty("zoom", 1.0); + d->zoomAnim->start(); } applet->updateConstraints(Plasma::AllConstraints); - if (!delayInit) { applet->flushPendingConstraintsEvents(); } - emit appletAdded(applet, pos); if (!currentContainment) { @@ -972,7 +975,6 @@ void Containment::addApplet(Applet *applet, const QPointF &pos, bool delayInit) applet->flushPendingConstraintsEvents(); } } - if (!delayInit) { applet->d->scheduleModificationNotification(); } @@ -2307,22 +2309,17 @@ void ContainmentPrivate::appletDestroyed(Plasma::Applet *applet) emit q->configNeedsSaving(); } -void ContainmentPrivate::containmentAppletAnimationComplete(QGraphicsItem *item, Plasma::Animator::Animation anim) +void ContainmentPrivate::containmentAppletAnimationComplete() { - if (anim == Animator::AppearAnimation && - item->parentItem() == q) { - Applet *applet = qgraphicsitem_cast(item); - - if (applet) { - if (type == Containment::DesktopContainment) { - applet->installSceneEventFilter(q); - } - - KConfigGroup *cg = applet->d->mainConfigGroup(); - applet->save(*cg); - emit q->configNeedsSaving(); - //applet->setWindowFlags(Qt::Window); + Applet *applet = qgraphicsitem_cast(zoomAnim->widgetToAnimate()); + if (applet->parentItem() == q) { + if (type == Containment::DesktopContainment) { + applet->installSceneEventFilter(q); } + + KConfigGroup *cg = applet->d->mainConfigGroup(); + applet->save(*cg); + emit q->configNeedsSaving(); } } diff --git a/containment.h b/containment.h index 5c860fed3..003d1d2ed 100644 --- a/containment.h +++ b/containment.h @@ -604,8 +604,7 @@ class PLASMA_EXPORT Containment : public Applet Containment(const QString &packagePath, uint appletId, const QVariantList &args); Q_PRIVATE_SLOT(d, void appletDestroyed(Plasma::Applet*)) - Q_PRIVATE_SLOT(d, void containmentAppletAnimationComplete(QGraphicsItem *, - Plasma::Animator::Animation anim)) + Q_PRIVATE_SLOT(d, void containmentAppletAnimationComplete()) Q_PRIVATE_SLOT(d, void triggerShowAddWidgets()) Q_PRIVATE_SLOT(d, void handleDisappeared(AppletHandle *handle)) Q_PRIVATE_SLOT(d, void positionToolBox()) diff --git a/private/containment_p.h b/private/containment_p.h index ac09ebc70..9672adb6f 100644 --- a/private/containment_p.h +++ b/private/containment_p.h @@ -36,6 +36,7 @@ namespace Plasma class AccessAppletJob; class Containment; class AbstractToolBox; +class Animation; class ContainmentPrivate { @@ -83,7 +84,7 @@ public: void setLockToolText(); void handleDisappeared(AppletHandle *handle); void appletDestroyed(Plasma::Applet*); - void containmentAppletAnimationComplete(QGraphicsItem *item, Plasma::Animator::Animation anim); + void containmentAppletAnimationComplete(); void zoomIn(); void zoomOut(); void clearDataForMimeJob(KIO::Job *job); @@ -164,6 +165,7 @@ public: QTimer *showDropZoneDelayTimer; bool drawWallpaper : 1; bool dropZoneStarted : 1; + Animation *zoomAnim; }; } // Plasma namespace