use QGraphicsOpacityEffect instead of simple setOpacity. this solves a bug with Plasma::Label and possibly other
widgets svn path=/trunk/KDE/kdelibs/; revision=1038688
This commit is contained in:
parent
7e80fdd8f1
commit
016d870394
@ -20,21 +20,59 @@
|
||||
#include "fade.h"
|
||||
|
||||
#include <QRect>
|
||||
#include <QtGui/QGraphicsOpacityEffect>
|
||||
|
||||
#include <kdebug.h>
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
FadeAnimation::FadeAnimation(qreal factor)
|
||||
: m_animFactor(qBound(qreal(0.0), factor, qreal(1.0)))
|
||||
class FadeAnimationPrivate
|
||||
{
|
||||
public:
|
||||
FadeAnimationPrivate()
|
||||
{
|
||||
}
|
||||
|
||||
~FadeAnimationPrivate()
|
||||
{
|
||||
}
|
||||
|
||||
QGraphicsOpacityEffect *opacityEffect;
|
||||
};
|
||||
|
||||
FadeAnimation::FadeAnimation(qreal factor)
|
||||
: d(new FadeAnimationPrivate()),
|
||||
m_animFactor(qBound(qreal(0.0), factor, qreal(1.0)))
|
||||
{
|
||||
}
|
||||
|
||||
FadeAnimation::~FadeAnimation()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
void FadeAnimation::setWidgetToAnimate(QGraphicsWidget *widget)
|
||||
{
|
||||
QGraphicsWidget *m_widget = widgetToAnimate();
|
||||
if (m_widget) {
|
||||
QGraphicsEffect *effect = m_widget->graphicsEffect();
|
||||
if (effect && dynamic_cast<QGraphicsOpacityEffect *>(effect)) {
|
||||
effect->deleteLater();
|
||||
}
|
||||
}
|
||||
|
||||
Animation::setWidgetToAnimate(widget);
|
||||
|
||||
d->opacityEffect = new QGraphicsOpacityEffect(widget);
|
||||
widget->setGraphicsEffect(d->opacityEffect);
|
||||
}
|
||||
|
||||
QAbstractAnimation* FadeAnimation::render(QObject* parent)
|
||||
{
|
||||
|
||||
//create animation
|
||||
QGraphicsWidget *m_object = widgetToAnimate();
|
||||
QPropertyAnimation* anim = new QPropertyAnimation(m_object, "opacity", parent);
|
||||
QPropertyAnimation* anim = new QPropertyAnimation(d->opacityEffect, "opacity", parent);
|
||||
anim->setEndValue(m_animFactor);
|
||||
anim->setDuration(duration());
|
||||
|
||||
|
@ -30,6 +30,8 @@
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
class FadeAnimationPrivate;
|
||||
|
||||
/**
|
||||
* @class Fade plasma/animations/fade.h
|
||||
* @short Fade effect
|
||||
@ -42,12 +44,15 @@ class FadeAnimation : public Animation
|
||||
|
||||
public:
|
||||
FadeAnimation(qreal factor = 0.5);
|
||||
virtual ~FadeAnimation(){};
|
||||
virtual ~FadeAnimation();
|
||||
|
||||
void setWidgetToAnimate(QGraphicsWidget *widget);
|
||||
|
||||
protected:
|
||||
virtual QAbstractAnimation* render(QObject* parent = 0);
|
||||
|
||||
private:
|
||||
FadeAnimationPrivate *const d;
|
||||
qreal m_animFactor;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user