* kill some memory leaks
* mark appropriate ctors with explicit * Direction -> MovementDirection so it doesn't conflict with QAbstractAnimation::Direction svn path=/branches/KDE/4.4/kdelibs/; revision=1073810
This commit is contained in:
parent
5f6fd5e387
commit
341cfb6362
@ -72,14 +72,15 @@ QGraphicsWidget* Animation::targetWidget() const
|
||||
return d->animObject.data();
|
||||
}
|
||||
|
||||
void Animation::setEasingCurveType(QEasingCurve::Type type)
|
||||
void Animation::setEasingCurve(const QEasingCurve &curve)
|
||||
{
|
||||
d->easingCurve.setType(type);
|
||||
kDebug() << "setting easing curve to type" << curve.type();
|
||||
d->easingCurve = curve;
|
||||
}
|
||||
|
||||
QEasingCurve::Type Animation::easingCurveType() const
|
||||
QEasingCurve Animation::easingCurve() const
|
||||
{
|
||||
return d->easingCurve.type();
|
||||
return d->easingCurve;
|
||||
}
|
||||
|
||||
QEasingCurve& Animation::easingCurve()
|
||||
|
@ -48,9 +48,9 @@ class PLASMA_EXPORT Animation : public QAbstractAnimation
|
||||
|
||||
Q_OBJECT
|
||||
Q_ENUMS(Reference)
|
||||
Q_ENUMS(Direction)
|
||||
Q_ENUMS(MovementDirection)
|
||||
Q_PROPERTY(int duration READ duration WRITE setDuration)
|
||||
Q_PROPERTY(QEasingCurve::Type easingCurveType READ easingCurveType WRITE setEasingCurveType)
|
||||
Q_PROPERTY(QEasingCurve easingCurve READ easingCurve WRITE setEasingCurve)
|
||||
Q_PROPERTY(QGraphicsWidget *targetWidget READ targetWidget WRITE setTargetWidget)
|
||||
|
||||
public:
|
||||
@ -74,7 +74,7 @@ public:
|
||||
/**
|
||||
* The movement direction of an animation.
|
||||
*/
|
||||
enum Direction {
|
||||
enum MovementDirection {
|
||||
MoveUp = 0, /**< Move up */
|
||||
MoveUpRight, /**< Move up and right */
|
||||
MoveRight, /**< Move right */
|
||||
@ -114,12 +114,12 @@ public:
|
||||
/**
|
||||
* Set the animation easing curve type
|
||||
*/
|
||||
void setEasingCurveType(QEasingCurve::Type type);
|
||||
void setEasingCurve(const QEasingCurve &curve);
|
||||
|
||||
/**
|
||||
* Get the animation easing curve type
|
||||
*/
|
||||
QEasingCurve::Type easingCurveType() const;
|
||||
QEasingCurve easingCurve() const;
|
||||
|
||||
protected:
|
||||
/**
|
||||
|
@ -46,7 +46,8 @@ class FadeAnimation : public Animation
|
||||
|
||||
public:
|
||||
/** Default constructor */
|
||||
FadeAnimation(QObject *parent = 0);
|
||||
explicit FadeAnimation(QObject *parent = 0);
|
||||
|
||||
/** Destructor */
|
||||
virtual ~FadeAnimation();
|
||||
|
||||
|
@ -44,7 +44,8 @@ class GeometryAnimation : public Animation
|
||||
|
||||
public:
|
||||
/** Default constructor */
|
||||
GeometryAnimation(QObject *parent = 0);
|
||||
explicit GeometryAnimation(QObject *parent = 0);
|
||||
|
||||
/** Destructor */
|
||||
virtual ~GeometryAnimation();
|
||||
|
||||
|
@ -50,7 +50,8 @@ public:
|
||||
* @param factor Expand factor (default is twice the size of
|
||||
* animated widget).
|
||||
*/
|
||||
GrowAnimation(QObject *parent = 0, qreal factor = 2);
|
||||
explicit GrowAnimation(QObject *parent = 0, qreal factor = 2);
|
||||
|
||||
/** Destructor */
|
||||
virtual ~GrowAnimation(){};
|
||||
|
||||
|
@ -45,7 +45,8 @@ class PulseAnimation : public Animation
|
||||
|
||||
public:
|
||||
/** Default Constructor */
|
||||
PulseAnimation(QObject *parent = 0);
|
||||
explicit PulseAnimation(QObject *parent = 0);
|
||||
|
||||
/** Destructor */
|
||||
~PulseAnimation();
|
||||
|
||||
|
@ -29,7 +29,7 @@ class ShadowFake: public QGraphicsWidget
|
||||
Q_PROPERTY(QGraphicsWidget *target READ target WRITE setTarget)
|
||||
|
||||
public:
|
||||
ShadowFake(QGraphicsItem *parent = 0);
|
||||
explicit ShadowFake(QGraphicsItem *parent = 0);
|
||||
~ShadowFake();
|
||||
|
||||
void setTarget(QGraphicsWidget *target);
|
||||
|
@ -26,10 +26,7 @@
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
RotationAnimation::RotationAnimation(QObject *parent,
|
||||
const qint8 &reference,
|
||||
const Qt::Axis &axis,
|
||||
const qreal &angle)
|
||||
RotationAnimation::RotationAnimation(QObject *parent, qint8 reference, Qt::Axis axis, qreal angle)
|
||||
: Animation(parent)
|
||||
{
|
||||
setAngle(angle);
|
||||
|
@ -56,10 +56,10 @@ public:
|
||||
* @param angle Rotation angle (0 to 360)
|
||||
*
|
||||
*/
|
||||
RotationAnimation(QObject *parent = 0,
|
||||
const qint8 &reference = Center,
|
||||
const Qt::Axis &axis = Qt::ZAxis,
|
||||
const qreal &angle = 180);
|
||||
explicit RotationAnimation(QObject *parent = 0,
|
||||
qint8 reference = Center,
|
||||
Qt::Axis axis = Qt::ZAxis,
|
||||
qreal angle = 180);
|
||||
|
||||
/** Destructor */
|
||||
~RotationAnimation();
|
||||
|
@ -30,27 +30,26 @@ namespace Plasma
|
||||
RotationStackedAnimation::RotationStackedAnimation(QObject *parent)
|
||||
: Animation(parent)
|
||||
{
|
||||
backRotation = new QGraphicsRotation(this);
|
||||
frontRotation = new QGraphicsRotation(this);
|
||||
sLayout = new StackedLayout;
|
||||
m_backRotation = new QGraphicsRotation(this);
|
||||
m_frontRotation = new QGraphicsRotation(this);
|
||||
m_sLayout = new StackedLayout;
|
||||
}
|
||||
|
||||
RotationStackedAnimation::~RotationStackedAnimation()
|
||||
{
|
||||
/* TODO: test what is lacking a parent and delete it */
|
||||
delete m_sLayout;
|
||||
}
|
||||
|
||||
void RotationStackedAnimation::setMovementDirection(const qint8 &direction)
|
||||
{
|
||||
animDirection = static_cast<Direction>(direction);
|
||||
m_animDirection = static_cast<MovementDirection>(direction);
|
||||
}
|
||||
|
||||
qint8 RotationStackedAnimation::movementDirection() const
|
||||
{
|
||||
return static_cast<qint8>(animDirection);
|
||||
return static_cast<qint8>(m_animDirection);
|
||||
}
|
||||
|
||||
|
||||
void RotationStackedAnimation::setReference(const qint8 &reference)
|
||||
{
|
||||
m_reference = reference;
|
||||
@ -71,14 +70,14 @@ void RotationStackedAnimation::setBackWidget(QGraphicsWidget *backWidget)
|
||||
m_backWidget = backWidget;
|
||||
|
||||
if(targetWidget()) {
|
||||
sLayout->addWidget(targetWidget());
|
||||
sLayout->addWidget(m_backWidget.data());
|
||||
m_sLayout->addWidget(targetWidget());
|
||||
m_sLayout->addWidget(m_backWidget.data());
|
||||
}
|
||||
}
|
||||
|
||||
QGraphicsLayoutItem *RotationStackedAnimation::layout()
|
||||
{
|
||||
return sLayout;
|
||||
return m_sLayout;
|
||||
}
|
||||
|
||||
void RotationStackedAnimation::updateState(
|
||||
@ -103,60 +102,60 @@ void RotationStackedAnimation::updateState(
|
||||
vector.first = QVector3D(widgetFrontWidth/2, widgetFrontHeight/2, 0);
|
||||
vector.second = QVector3D(widgetBackWidth/2, widgetBackHeight/2, 0);
|
||||
|
||||
if (animDirection == MoveLeft || animDirection == MoveRight) {
|
||||
frontRotation->setAxis(Qt::YAxis);
|
||||
backRotation->setAxis(Qt::YAxis);
|
||||
if (m_animDirection == MoveLeft || m_animDirection == MoveRight) {
|
||||
m_frontRotation->setAxis(Qt::YAxis);
|
||||
m_backRotation->setAxis(Qt::YAxis);
|
||||
|
||||
if (animDirection == MoveLeft) {
|
||||
if (m_animDirection == MoveLeft) {
|
||||
/* TODO: the order way */
|
||||
|
||||
} else {
|
||||
frontStartAngle = 0;
|
||||
frontEndAngle = 90;
|
||||
backStartAngle = 265; //hack
|
||||
backEndAngle = 360;
|
||||
m_frontStartAngle = 0;
|
||||
m_frontEndAngle = 90;
|
||||
m_backStartAngle = 265; //hack
|
||||
m_backEndAngle = 360;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
frontRotation->setOrigin(vector.first);
|
||||
backRotation->setOrigin(vector.second);
|
||||
m_frontRotation->setOrigin(vector.first);
|
||||
m_backRotation->setOrigin(vector.second);
|
||||
|
||||
QList<QGraphicsTransform *> backTransformation;
|
||||
QList<QGraphicsTransform *> frontTransformation;
|
||||
|
||||
frontTransformation.append(frontRotation);
|
||||
backTransformation.append(backRotation);
|
||||
frontTransformation.append(m_frontRotation);
|
||||
backTransformation.append(m_backRotation);
|
||||
|
||||
widgets.first->setTransformations(frontTransformation);
|
||||
widgets.second->setTransformations(backTransformation);
|
||||
|
||||
if (oldState == Stopped && newState == Running) {
|
||||
frontRotation->setAngle(direction() == Forward ? frontStartAngle : frontEndAngle);
|
||||
backRotation->setAngle(direction() == Forward ? backStartAngle : backEndAngle);
|
||||
m_frontRotation->setAngle(direction() == Forward ? m_frontStartAngle : m_frontEndAngle);
|
||||
m_backRotation->setAngle(direction() == Forward ? m_backStartAngle : m_backEndAngle);
|
||||
} else if(newState == Stopped) {
|
||||
frontRotation->setAngle(direction() == Forward ? frontEndAngle : frontStartAngle);
|
||||
backRotation->setAngle(direction() == Forward ? backEndAngle : backStartAngle);
|
||||
}
|
||||
m_frontRotation->setAngle(direction() == Forward ? m_frontEndAngle : m_frontStartAngle);
|
||||
m_backRotation->setAngle(direction() == Forward ? m_backEndAngle : m_backStartAngle);
|
||||
}
|
||||
}
|
||||
|
||||
void RotationStackedAnimation::updateCurrentTime(int currentTime)
|
||||
{
|
||||
QGraphicsWidget *w = targetWidget();
|
||||
if(w) {
|
||||
qreal delta;
|
||||
if (currentTime <= duration()/2) {
|
||||
delta = Animation::easingCurve().valueForProgress(
|
||||
(currentTime * 2) / qreal(duration()));
|
||||
sLayout->setCurrentWidgetIndex(0);
|
||||
delta = frontEndAngle * delta;
|
||||
frontRotation->setAngle(delta);
|
||||
QGraphicsWidget *w = targetWidget();
|
||||
if(w) {
|
||||
qreal delta;
|
||||
if (currentTime <= duration()/2) {
|
||||
delta = Animation::easingCurve().valueForProgress(
|
||||
(currentTime * 2) / qreal(duration()));
|
||||
m_sLayout->setCurrentWidgetIndex(0);
|
||||
delta = m_frontEndAngle * delta;
|
||||
m_frontRotation->setAngle(delta);
|
||||
} else {
|
||||
delta = Animation::easingCurve().valueForProgress(
|
||||
(currentTime/2) / qreal(duration()));
|
||||
sLayout->setCurrentWidgetIndex(1);
|
||||
delta = backEndAngle * delta;
|
||||
backRotation->setAngle(delta);
|
||||
m_sLayout->setCurrentWidgetIndex(1);
|
||||
delta = m_backEndAngle * delta;
|
||||
m_backRotation->setAngle(delta);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ class RotationStackedAnimation : public Animation
|
||||
Q_PROPERTY(QGraphicsWidget* backWidget READ backWidget WRITE setBackWidget)
|
||||
|
||||
public:
|
||||
RotationStackedAnimation(QObject *parent = 0);
|
||||
explicit RotationStackedAnimation(QObject *parent = 0);
|
||||
|
||||
~RotationStackedAnimation();
|
||||
|
||||
@ -104,23 +104,23 @@ private:
|
||||
/**
|
||||
* Animation direction: where the animation will move.
|
||||
*/
|
||||
Direction animDirection;
|
||||
MovementDirection m_animDirection;
|
||||
/** Initial rotation angle from front widget */
|
||||
int frontStartAngle;
|
||||
int m_frontStartAngle;
|
||||
/** End value of the rotation angle of the front widget */
|
||||
int frontEndAngle;
|
||||
int m_frontEndAngle;
|
||||
/** Initial rotation angle from back widget */
|
||||
int backStartAngle;
|
||||
int m_backStartAngle;
|
||||
/** End value of the rotation angle of the back widget */
|
||||
int backEndAngle;
|
||||
int m_backEndAngle;
|
||||
/** Object the animation(s) should act upon. */
|
||||
QWeakPointer<QGraphicsWidget> m_backWidget;
|
||||
/** Back Widget Rotation transform object */
|
||||
QGraphicsRotation *backRotation;
|
||||
QGraphicsRotation *m_backRotation;
|
||||
/** Front Widget Rotation transform object */
|
||||
QGraphicsRotation *frontRotation;
|
||||
QGraphicsRotation *m_frontRotation;
|
||||
/** rotation stacked layout where the widget would be added */
|
||||
StackedLayout *sLayout;
|
||||
StackedLayout *m_sLayout;
|
||||
|
||||
};
|
||||
} // Plasma
|
||||
|
@ -40,17 +40,17 @@ SlideAnimation::~SlideAnimation()
|
||||
}
|
||||
|
||||
SlideAnimation::SlideAnimation(QObject *parent,
|
||||
Direction direction,
|
||||
MovementDirection direction,
|
||||
qreal distance) : Animation(parent)
|
||||
{
|
||||
setMovementDirection(direction);
|
||||
setDistance(distance);
|
||||
Animation::setEasingCurveType(QEasingCurve::OutCirc);
|
||||
setEasingCurve(QEasingCurve::OutCirc);
|
||||
}
|
||||
|
||||
void SlideAnimation::setMovementDirection(const qint8 &direction)
|
||||
{
|
||||
m_animDirection = static_cast<Direction>(direction);
|
||||
m_animDirection = static_cast<MovementDirection>(direction);
|
||||
}
|
||||
|
||||
qint8 SlideAnimation::movementDirection() const
|
||||
|
@ -46,8 +46,7 @@ class SlideAnimation : public Animation
|
||||
Q_PROPERTY(qreal distance READ distance WRITE setDistance)
|
||||
|
||||
public:
|
||||
SlideAnimation(QObject *parent = 0,
|
||||
Direction direction = MoveUp, qreal distance = 0);
|
||||
explicit SlideAnimation(QObject *parent = 0, MovementDirection direction = MoveUp, qreal distance = 0);
|
||||
~SlideAnimation();
|
||||
|
||||
/**
|
||||
@ -80,7 +79,7 @@ private:
|
||||
/**
|
||||
* Animation direction: where the animation will move.
|
||||
*/
|
||||
Direction m_animDirection;
|
||||
MovementDirection m_animDirection;
|
||||
|
||||
/**
|
||||
* Animation distance: displacement factor for animations where
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
class StackedLayout : public QGraphicsLayout {
|
||||
public:
|
||||
StackedLayout(QGraphicsLayoutItem *parent = 0);
|
||||
explicit StackedLayout(QGraphicsLayoutItem *parent = 0);
|
||||
~StackedLayout();
|
||||
|
||||
void setGeometry(const QRectF &rect);
|
||||
|
@ -41,7 +41,7 @@ class ZoomAnimation : public Animation
|
||||
Q_PROPERTY(qreal zoom READ zoom WRITE setZoom)
|
||||
|
||||
public:
|
||||
ZoomAnimation(QObject *parent = 0);
|
||||
explicit ZoomAnimation(QObject *parent = 0);
|
||||
virtual ~ZoomAnimation();
|
||||
|
||||
qreal zoom() const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user