support setting the direction forwards or backwards; conflicts with direction so used a bool instead of an enum, makes more sense anyways imho. the use of an enum in QAbstractAnimation seems a bit overkill
svn path=/trunk/KDE/kdelibs/; revision=1038850
This commit is contained in:
parent
a9a4fc471b
commit
1f7370376b
@ -22,15 +22,22 @@
|
||||
|
||||
#include <QEasingCurve>
|
||||
|
||||
#include <kdebug.h>
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
AbstractAnimationPrivate::AbstractAnimationPrivate()
|
||||
: easingCurve(QEasingCurve::Linear),
|
||||
animVisible(true),
|
||||
forwards(true)
|
||||
{
|
||||
}
|
||||
|
||||
AbstractAnimation::AbstractAnimation(QObject *parent)
|
||||
: QObject(parent),
|
||||
d(new AbstractAnimationPrivate)
|
||||
{
|
||||
d->easingCurve = QEasingCurve::Linear;
|
||||
}
|
||||
|
||||
AbstractAnimation::~AbstractAnimation()
|
||||
@ -58,6 +65,16 @@ QEasingCurve::Type AbstractAnimation::easingCurveType() const
|
||||
return d->easingCurve;
|
||||
}
|
||||
|
||||
void AbstractAnimation::setForwards(bool forwards)
|
||||
{
|
||||
d->forwards = forwards;
|
||||
}
|
||||
|
||||
bool AbstractAnimation::forwards() const
|
||||
{
|
||||
return d->forwards;
|
||||
}
|
||||
|
||||
void AbstractAnimation::setDirection(AnimationDirection direction)
|
||||
{
|
||||
d->animDirection = direction;
|
||||
@ -123,6 +140,8 @@ void AbstractAnimation::start()
|
||||
{
|
||||
QAbstractAnimation* anim = toQAbstractAnimation(parent());
|
||||
if (anim) {
|
||||
anim->setDirection(d->forwards ? QAbstractAnimation::Forward :
|
||||
QAbstractAnimation::Backward);
|
||||
anim->start(QAbstractAnimation::DeleteWhenStopped);
|
||||
}
|
||||
}
|
||||
|
@ -51,6 +51,8 @@ class PLASMA_EXPORT AbstractAnimation : public QObject
|
||||
Q_PROPERTY(qreal distance READ distance WRITE setDistance)
|
||||
Q_PROPERTY(bool isVisible READ isVisible WRITE setVisible)
|
||||
Q_PROPERTY(QGraphicsWidget *widgetToAnimate READ widgetToAnimate WRITE setWidgetToAnimate)
|
||||
Q_PROPERTY(bool forwards READ forwards WRITE setForwards)
|
||||
|
||||
/**
|
||||
* TODO: add missing properties (e.g. angle, axis, reference, etc)
|
||||
*/
|
||||
@ -101,6 +103,17 @@ public:
|
||||
*/
|
||||
QEasingCurve::Type easingCurveType() const;
|
||||
|
||||
/**
|
||||
* Sets whether the animation will run forwards or backwards
|
||||
* @arg forward true to run the animation forewards
|
||||
*/
|
||||
void setForwards(bool forward);
|
||||
|
||||
/**
|
||||
* @return true if the animation will run forwards, false if it will run backwards
|
||||
*/
|
||||
bool forwards() const;
|
||||
|
||||
/**
|
||||
* Set the animation direction
|
||||
* @arg direction animation direction
|
||||
|
Loading…
Reference in New Issue
Block a user