diff --git a/animations/animation.cpp b/animations/animation.cpp index 3cdaa586a..2a0ac8d9e 100644 --- a/animations/animation.cpp +++ b/animations/animation.cpp @@ -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() diff --git a/animations/animation.h b/animations/animation.h index 4819a22a7..bec96ece8 100644 --- a/animations/animation.h +++ b/animations/animation.h @@ -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: /** diff --git a/animations/fade_p.h b/animations/fade_p.h index 92d52c2f1..fd67c2622 100644 --- a/animations/fade_p.h +++ b/animations/fade_p.h @@ -46,7 +46,8 @@ class FadeAnimation : public Animation public: /** Default constructor */ - FadeAnimation(QObject *parent = 0); + explicit FadeAnimation(QObject *parent = 0); + /** Destructor */ virtual ~FadeAnimation(); diff --git a/animations/geometry_p.h b/animations/geometry_p.h index 897c27155..aa698eefa 100644 --- a/animations/geometry_p.h +++ b/animations/geometry_p.h @@ -44,7 +44,8 @@ class GeometryAnimation : public Animation public: /** Default constructor */ - GeometryAnimation(QObject *parent = 0); + explicit GeometryAnimation(QObject *parent = 0); + /** Destructor */ virtual ~GeometryAnimation(); diff --git a/animations/grow_p.h b/animations/grow_p.h index 21dd2b04b..ce663dcff 100644 --- a/animations/grow_p.h +++ b/animations/grow_p.h @@ -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(){}; diff --git a/animations/pulser_p.h b/animations/pulser_p.h index 89e5c65f4..af30be7d9 100644 --- a/animations/pulser_p.h +++ b/animations/pulser_p.h @@ -45,7 +45,8 @@ class PulseAnimation : public Animation public: /** Default Constructor */ - PulseAnimation(QObject *parent = 0); + explicit PulseAnimation(QObject *parent = 0); + /** Destructor */ ~PulseAnimation(); diff --git a/animations/pulsershadow_p.h b/animations/pulsershadow_p.h index 7cfb05a73..81d032734 100644 --- a/animations/pulsershadow_p.h +++ b/animations/pulsershadow_p.h @@ -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); diff --git a/animations/rotation.cpp b/animations/rotation.cpp index 99430e47a..a4fd4e943 100644 --- a/animations/rotation.cpp +++ b/animations/rotation.cpp @@ -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); diff --git a/animations/rotation_p.h b/animations/rotation_p.h index e4123e949..d10d16471 100644 --- a/animations/rotation_p.h +++ b/animations/rotation_p.h @@ -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(); diff --git a/animations/rotationstacked.cpp b/animations/rotationstacked.cpp index e021c8fa3..1c2acc168 100644 --- a/animations/rotationstacked.cpp +++ b/animations/rotationstacked.cpp @@ -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); + m_animDirection = static_cast(direction); } qint8 RotationStackedAnimation::movementDirection() const { - return static_cast(animDirection); + return static_cast(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 backTransformation; QList 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); } } } diff --git a/animations/rotationstacked_p.h b/animations/rotationstacked_p.h index 265074aa4..61466597d 100644 --- a/animations/rotationstacked_p.h +++ b/animations/rotationstacked_p.h @@ -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 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 diff --git a/animations/slide.cpp b/animations/slide.cpp index 7b5764848..000565f74 100644 --- a/animations/slide.cpp +++ b/animations/slide.cpp @@ -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); + m_animDirection = static_cast(direction); } qint8 SlideAnimation::movementDirection() const diff --git a/animations/slide_p.h b/animations/slide_p.h index 84a298159..2ad31463b 100644 --- a/animations/slide_p.h +++ b/animations/slide_p.h @@ -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 diff --git a/animations/stackedlayout.h b/animations/stackedlayout.h index 274ac3023..01f156cf9 100644 --- a/animations/stackedlayout.h +++ b/animations/stackedlayout.h @@ -23,7 +23,7 @@ class StackedLayout : public QGraphicsLayout { public: - StackedLayout(QGraphicsLayoutItem *parent = 0); + explicit StackedLayout(QGraphicsLayoutItem *parent = 0); ~StackedLayout(); void setGeometry(const QRectF &rect); diff --git a/animations/zoom_p.h b/animations/zoom_p.h index ae91760af..c51b0a7ee 100644 --- a/animations/zoom_p.h +++ b/animations/zoom_p.h @@ -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;