Migrating Plasma Applet disappear animation to ZoomAnimation (it works

smoother and the code is simpler).


svn path=/trunk/KDE/kdelibs/; revision=1061465
This commit is contained in:
Adenilson Cavalcanti Da Silva 2009-12-11 19:53:55 +00:00
parent 3a550b3ef7
commit 48af57c6ce
3 changed files with 20 additions and 23 deletions

View File

@ -22,6 +22,7 @@
#include "applet.h"
#include "private/applet_p.h"
#include <plasma/animations/animation.h>
#include <cmath>
#include <limits>
@ -452,9 +453,11 @@ void Applet::destroy()
if (isContainment()) {
d->cleanUpAndDelete();
} else {
connect(Animator::self(), SIGNAL(animationFinished(QGraphicsItem*,Plasma::Animator::Animation)),
this, SLOT(appletAnimationComplete(QGraphicsItem*,Plasma::Animator::Animation)));
Animator::self()->animateItem(this, Animator::DisappearAnimation);
Animation *zoomAnim =
Plasma::Animator::create(Plasma::Animator::ZoomAnimation);
connect(zoomAnim, SIGNAL(finished()), this, SLOT(appletAnimationComplete()));
zoomAnim->setWidgetToAnimate(this);
zoomAnim->start();
}
}
@ -463,11 +466,9 @@ bool Applet::destroyed() const
return d->transient;
}
void AppletPrivate::appletAnimationComplete(QGraphicsItem *item, Plasma::Animator::Animation anim)
void AppletPrivate::appletAnimationComplete()
{
if (anim == Animator::DisappearAnimation && item == q) {
cleanUpAndDelete();
}
cleanUpAndDelete();
}
void AppletPrivate::selectItemToDestroy()
@ -2856,26 +2857,23 @@ AppletOverlayWidget::AppletOverlayWidget(QGraphicsWidget *parent)
opacity(0.4)
{
resize(parent->size());
Animator::self()->animateItem(this, Animator::AppearAnimation);
}
void AppletOverlayWidget::destroy()
{
connect(Animator::self(),
SIGNAL(animationFinished(QGraphicsItem*,Plasma::Animator::Animation)),
this,
SLOT(overlayAnimationComplete(QGraphicsItem*,Plasma::Animator::Animation)));
Animator::self()->animateItem(this, Animator::DisappearAnimation);
Animation *zoomAnim =
Plasma::Animator::create(Plasma::Animator::ZoomAnimation);
connect(zoomAnim, SIGNAL(finished()), this, SLOT(overlayAnimationComplete()));
zoomAnim->setWidgetToAnimate(this);
zoomAnim->start();
}
void AppletOverlayWidget::overlayAnimationComplete(QGraphicsItem *item, Plasma::Animator::Animation)
void AppletOverlayWidget::overlayAnimationComplete()
{
if (item == this) {
if (scene()) {
scene()->removeItem(this);
}
deleteLater();
if (scene()) {
scene()->removeItem(this);
}
deleteLater();
}
void AppletOverlayWidget::paint(QPainter *painter,

View File

@ -1064,8 +1064,7 @@ class PLASMA_EXPORT Applet : public QGraphicsWidget
Q_PRIVATE_SLOT(d, void setFocus())
Q_PRIVATE_SLOT(d, void checkImmutability())
Q_PRIVATE_SLOT(d, void themeChanged())
Q_PRIVATE_SLOT(d, void appletAnimationComplete(QGraphicsItem *item,
Plasma::Animator::Animation anim))
Q_PRIVATE_SLOT(d, void appletAnimationComplete())
Q_PRIVATE_SLOT(d, void selectItemToDestroy())
Q_PRIVATE_SLOT(d, void updateRect(const QRectF& rect))
Q_PRIVATE_SLOT(d, void destroyMessageOverlay())

View File

@ -61,7 +61,7 @@ protected:
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
protected Q_SLOTS:
void overlayAnimationComplete(QGraphicsItem *item, Plasma::Animator::Animation);
void overlayAnimationComplete();
};
class AppletPrivate : public DataEngineConsumer
@ -90,7 +90,7 @@ public:
void checkImmutability();
void themeChanged();
void resetConfigurationObject();
void appletAnimationComplete(QGraphicsItem *item, Plasma::Animator::Animation anim);
void appletAnimationComplete();
void selectItemToDestroy();
void updateRect(const QRectF &rect);
void setFocus();