diff --git a/animations/animation.cpp b/animations/animation.cpp index bd1739eb4..7c8499a79 100644 --- a/animations/animation.cpp +++ b/animations/animation.cpp @@ -69,12 +69,17 @@ QGraphicsWidget* Animation::widgetToAnimate() return d->animObject.data(); } -void Animation::setEasingCurve(QEasingCurve easingCurve) +void Animation::setEasingCurveType(QEasingCurve::Type type) { - d->easingCurve = easingCurve; + d->easingCurve.setType(type); } -QEasingCurve Animation::easingCurve() const +QEasingCurve::Type Animation::easingCurveType() const +{ + return d->easingCurve.type(); +} + +QEasingCurve& Animation::easingCurve() { return d->easingCurve; } diff --git a/animations/animation.h b/animations/animation.h index 732b57948..ee79dcf65 100644 --- a/animations/animation.h +++ b/animations/animation.h @@ -31,6 +31,7 @@ #include #include #include +#include namespace Plasma { @@ -46,7 +47,7 @@ class PLASMA_EXPORT Animation : public QAbstractAnimation Q_OBJECT Q_PROPERTY(int duration READ duration WRITE setDuration) - Q_PROPERTY(QEasingCurve easingCurve READ easingCurve WRITE setEasingCurve) + Q_PROPERTY(QEasingCurve::Type easingCurveType READ easingCurveType WRITE setEasingCurveType) Q_PROPERTY(QGraphicsWidget *widgetToAnimate READ widgetToAnimate WRITE setWidgetToAnimate) public: @@ -82,12 +83,12 @@ public: /** * Set the animation easing curve type */ - void setEasingCurve(QEasingCurve easingCurve); + void setEasingCurveType(QEasingCurve::Type type); /** * Get the animation easing curve type */ - QEasingCurve easingCurve() const; + QEasingCurve::Type easingCurveType() const; protected: @@ -99,6 +100,8 @@ protected: virtual void updateCurrentTime(int currentTime); + QEasingCurve &easingCurve(); + private: AnimationPrivate *const d; diff --git a/animations/fade.cpp b/animations/fade.cpp index 070072927..0d053031b 100644 --- a/animations/fade.cpp +++ b/animations/fade.cpp @@ -67,6 +67,7 @@ void FadeAnimation::setWidgetToAnimate(QGraphicsWidget *widget) if (widget) { widget->setOpacity(m_startOpacity); } + } void FadeAnimation::updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState) @@ -89,7 +90,7 @@ void FadeAnimation::updateCurrentTime(int currentTime) if (w) { qreal delta = currentTime / qreal(duration()); delta = (m_startOpacity - m_targetOpacity) * - easingCurve().valueForProgress(delta); + Animation::easingCurve().valueForProgress(delta); w->setOpacity(m_startOpacity - delta); } diff --git a/animations/grow.cpp b/animations/grow.cpp index 3378ffce2..d665ada79 100644 --- a/animations/grow.cpp +++ b/animations/grow.cpp @@ -44,7 +44,7 @@ void GrowAnimation::updateCurrentTime(int currentTime) { QGraphicsWidget *w = widgetToAnimate(); if (w && state() == QAbstractAnimation::Running) { - qreal delta = easingCurve().valueForProgress( + qreal delta = Animation::easingCurve().valueForProgress( currentTime / qreal(duration())); QRectF geometry; geometry.setTopLeft(m_startGeometry.topLeft() * (1-delta) + (m_targetGeometry.topLeft() * delta)); diff --git a/animations/grow_p.h b/animations/grow_p.h index d69734581..3f19a0c5a 100644 --- a/animations/grow_p.h +++ b/animations/grow_p.h @@ -58,7 +58,6 @@ protected: private: qreal m_animFactor; - QRectF m_startGeometry; QRectF m_targetGeometry; }; diff --git a/animations/slide.cpp b/animations/slide.cpp index 4b762be8a..6adb84971 100644 --- a/animations/slide.cpp +++ b/animations/slide.cpp @@ -41,8 +41,7 @@ SlideAnimation::~SlideAnimation() SlideAnimation::SlideAnimation(QObject *parent, AnimationDirection direction, - qreal distance) - : Animation(parent) + qreal distance) : Animation(parent) { setMovementDirection(direction); setDistance(distance); @@ -62,7 +61,7 @@ void SlideAnimation::updateCurrentTime(int currentTime) { QGraphicsWidget *w = widgetToAnimate(); if (w && state() == QAbstractAnimation::Running) { - qreal delta = easingCurve().valueForProgress( + qreal delta = Animation::easingCurve().valueForProgress( currentTime / qreal(duration())); w->setPos(m_startPos * (1-delta) + (m_targetPos * delta)); } diff --git a/animations/slide_p.h b/animations/slide_p.h index af523beb7..ebc6e77a8 100644 --- a/animations/slide_p.h +++ b/animations/slide_p.h @@ -28,7 +28,6 @@ #include "plasma/plasma_export.h" #include "plasma/plasma.h" - namespace Plasma { @@ -88,7 +87,6 @@ private: * there is change in the position of animated widget. */ qreal m_animDistance; - QPointF m_startPos; QPointF m_targetPos; }; diff --git a/private/abstractanimationprivate_p.h b/private/abstractanimationprivate_p.h index 25b7429be..3419bbb69 100644 --- a/private/abstractanimationprivate_p.h +++ b/private/abstractanimationprivate_p.h @@ -52,7 +52,7 @@ public: /** * Animation easing curve type */ - QEasingCurve::Type easingCurve; + QEasingCurve easingCurve; /** * Animation direction, the idea is to offer a way