From 8b9830dc2b2e92d93d627d226f67bf19d0cc0275 Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Tue, 20 Oct 2009 21:14:46 +0000 Subject: [PATCH] API cleanups svn path=/trunk/KDE/kdelibs/; revision=1038232 --- animations/abstractanimation.cpp | 24 ++++++++++++------------ animations/abstractanimation.h | 28 ++++++++++++++-------------- animations/animation.cpp | 2 +- animations/expand.cpp | 16 ++++++++-------- animations/fade.cpp | 2 +- animations/grow.cpp | 2 +- animations/pulser.cpp | 4 ++-- animations/rotation.cpp | 2 +- animations/slide.cpp | 22 +++++++++++----------- private/abstractanimationprivate_p.h | 5 +++-- private/focusindicator.cpp | 6 ++++-- 11 files changed, 58 insertions(+), 55 deletions(-) diff --git a/animations/abstractanimation.cpp b/animations/abstractanimation.cpp index 9ccf2f697..ea6a11f14 100644 --- a/animations/abstractanimation.cpp +++ b/animations/abstractanimation.cpp @@ -37,14 +37,14 @@ AbstractAnimation::~AbstractAnimation() delete d; } -void AbstractAnimation::setWidget(QGraphicsWidget* receiver) +void AbstractAnimation::setAnimatedWidget(QGraphicsWidget* receiver) { d->animObject = receiver; } -QGraphicsWidget* AbstractAnimation::animatedObject() +QGraphicsWidget* AbstractAnimation::animatedWidget() { - return d->animObject; + return d->animObject.data(); } void AbstractAnimation::setEasingCurveType(QEasingCurve::Type easingCurve) @@ -57,32 +57,32 @@ QEasingCurve::Type AbstractAnimation::easingCurveType() const return d->easingCurve; } -void AbstractAnimation::setAnimationDirection(AnimationDirection animationDirection) +void AbstractAnimation::setDirection(AnimationDirection direction) { - d->animDirection = animationDirection; + d->animDirection = direction; } -AnimationDirection AbstractAnimation::animationDirection() const +AnimationDirection AbstractAnimation::direction() const { return d->animDirection; } -void AbstractAnimation::setAnimationDistance(qreal animationDistance) +void AbstractAnimation::setDistance(qreal distance) { - d->animDistance = animationDistance; + d->animDistance = distance; } -qreal AbstractAnimation::animationDistance() const +qreal AbstractAnimation::distance() const { return d->animDistance; } -void AbstractAnimation::setAnimationVisible(bool animationVisible) +void AbstractAnimation::setVisible(bool isVisible) { - d->animVisible = animationVisible; + d->animVisible = isVisible; } -bool AbstractAnimation::animationVisible() const +bool AbstractAnimation::isVisible() const { return d->animVisible; } diff --git a/animations/abstractanimation.h b/animations/abstractanimation.h index 3ff62e346..45136b076 100644 --- a/animations/abstractanimation.h +++ b/animations/abstractanimation.h @@ -47,9 +47,9 @@ class PLASMA_EXPORT AbstractAnimation : public QObject Q_OBJECT Q_PROPERTY(QEasingCurve::Type easingCurveType READ easingCurveType WRITE setEasingCurveType) - Q_PROPERTY(AnimationDirection animationDirection READ animationDirection WRITE setAnimationDirection) - Q_PROPERTY(qreal animationDistance READ animationDistance WRITE setAnimationDistance) - Q_PROPERTY(bool animationVisible READ animationVisible WRITE setAnimationVisible) + Q_PROPERTY(AnimationDirection direction READ direction WRITE setDirection) + Q_PROPERTY(qreal distance READ distance WRITE setDistance) + Q_PROPERTY(bool isVisible READ isVisible WRITE setVisible) public: @@ -60,7 +60,7 @@ public: * Set the widget on which the animation is to be performed. * @arg receiver The QGraphicsWidget to be animated. */ - virtual void setWidget(QGraphicsWidget* receiver); + virtual void setAnimatedWidget(QGraphicsWidget* receiver); /** * Take an AbstractAnimation and turn it into a @@ -80,36 +80,36 @@ public: /** * Set the animation direction - * @arg animationDirection animation direction + * @arg direction animation direction */ - void setAnimationDirection(AnimationDirection animationDirection); + void setDirection(AnimationDirection direction); /** * Get the animation direction */ - AnimationDirection animationDirection() const; + AnimationDirection direction() const; /** * Set the animation distance - * @animationDistance animation distance + * @distance animation distance */ - void setAnimationDistance(qreal animationDistance); + void setDistance(qreal distance); /** * Get the animation distance */ - qreal animationDistance() const; + qreal distance() const; /** * set the animation visibility - * @arg animationVisible animation visibility + * @arg isVisible animation visibility */ - void setAnimationVisible(bool animationVisible); + void setVisible(bool isVisible); /** * get the animation visibility */ - bool animationVisible() const; + bool isVisible() const; public slots: @@ -119,7 +119,7 @@ public slots: virtual void start() = 0; protected: - QGraphicsWidget *animatedObject(); + QGraphicsWidget *animatedWidget(); private: AbstractAnimationPrivate *d; diff --git a/animations/animation.cpp b/animations/animation.cpp index 3521addb2..efa2b6e11 100644 --- a/animations/animation.cpp +++ b/animations/animation.cpp @@ -75,7 +75,7 @@ void Animation::start() QAbstractAnimation* Animation::toQAbstractAnimation(QObject* parent) { //check if .setObject() was done - if (!animatedObject()) { + if (!animatedWidget()) { kDebug() << "Object not set."; return NULL; } diff --git a/animations/expand.cpp b/animations/expand.cpp index 03dda446e..1770475fc 100644 --- a/animations/expand.cpp +++ b/animations/expand.cpp @@ -27,33 +27,33 @@ namespace Plasma ExpandAnimation::ExpandAnimation(AnimationDirection direction, qreal distance) { - setAnimationDirection(direction); - setAnimationDistance(distance); + setDirection(direction); + setDistance(distance); } QAbstractAnimation* ExpandAnimation::render(QObject* parent){ //get current geometry values - QGraphicsWidget *m_object = animatedObject(); + QGraphicsWidget *m_object = animatedWidget(); QRectF geometry = m_object->geometry(); //compute new geometry values - switch (animationDirection()) { + switch (direction()) { case MoveUp: - geometry.setTop(geometry.y() - animationDistance()); + geometry.setTop(geometry.y() - distance()); break; case MoveRight: - geometry.setRight(geometry.x() + geometry.width() - 1 + animationDistance()); + geometry.setRight(geometry.x() + geometry.width() - 1 + distance()); break; case MoveDown: - geometry.setBottom(geometry.y() + geometry.height() - 1 + animationDistance()); + geometry.setBottom(geometry.y() + geometry.height() - 1 + distance()); break; case MoveLeft: - geometry.setLeft(geometry.x() - animationDistance()); + geometry.setLeft(geometry.x() - distance()); break; case MoveUpRight: diff --git a/animations/fade.cpp b/animations/fade.cpp index 399d225d2..5c9250246 100644 --- a/animations/fade.cpp +++ b/animations/fade.cpp @@ -33,7 +33,7 @@ FadeAnimation::FadeAnimation(qreal factor) QAbstractAnimation* FadeAnimation::render(QObject* parent){ //create animation - QGraphicsWidget *m_object = animatedObject(); + QGraphicsWidget *m_object = animatedWidget(); QPropertyAnimation* anim = new QPropertyAnimation(m_object, "opacity", parent); anim->setEndValue(m_animFactor); anim->setDuration(duration()); diff --git a/animations/grow.cpp b/animations/grow.cpp index edf9b2a18..678af7967 100644 --- a/animations/grow.cpp +++ b/animations/grow.cpp @@ -33,7 +33,7 @@ GrowAnimation::GrowAnimation(qreal factor) QAbstractAnimation* GrowAnimation::render(QObject* parent){ //get current geometry values - QGraphicsWidget *m_object = animatedObject(); + QGraphicsWidget *m_object = animatedWidget(); QRectF geometry = m_object->geometry(); qreal w = geometry.width(); qreal h = geometry.height(); diff --git a/animations/pulser.cpp b/animations/pulser.cpp index 8d8df48db..bb3ba8d68 100644 --- a/animations/pulser.cpp +++ b/animations/pulser.cpp @@ -68,7 +68,7 @@ PulseAnimation::~PulseAnimation() void PulseAnimation::setCopy(QGraphicsWidget *copy) { - QGraphicsWidget *target = animatedObject(); + QGraphicsWidget *target = animatedWidget(); d->under = copy; if (d->under != target) { d->under->setParentItem(target); @@ -116,7 +116,7 @@ void PulseAnimation::resetPulser() void PulseAnimation::createAnimation(qreal duration, qreal scale) { - QGraphicsWidget *target = animatedObject(); + QGraphicsWidget *target = animatedWidget(); /* Fallback to parent widget if we don't have one 'shadow' widget */ if (!d->under) { setCopy(target); diff --git a/animations/rotation.cpp b/animations/rotation.cpp index 54374a66a..525397e3c 100644 --- a/animations/rotation.cpp +++ b/animations/rotation.cpp @@ -91,7 +91,7 @@ void RotationAnimation::setAngle(const qreal &angle) QPropertyAnimation *RotationAnimation::render(QObject *parent) { Q_UNUSED(parent); - QGraphicsWidget *m_object = animatedObject(); + QGraphicsWidget *m_object = animatedWidget(); QVector3D vector(0, 0, 0); diff --git a/animations/slide.cpp b/animations/slide.cpp index 10c508a71..917c669b4 100644 --- a/animations/slide.cpp +++ b/animations/slide.cpp @@ -27,35 +27,35 @@ namespace Plasma SlideAnimation::SlideAnimation(AnimationDirection direction, qreal distance) { - setAnimationDirection(direction); - setAnimationDistance(distance); - setAnimationVisible(true); + setDirection(direction); + setDistance(distance); + setVisible(true); } QAbstractAnimation* SlideAnimation::render(QObject* parent) { - QGraphicsWidget *m_object = animatedObject(); + QGraphicsWidget *m_object = animatedWidget(); qreal x = m_object->x(); qreal y = m_object->y(); qreal newX = x; qreal newY = y; - switch (animationDirection()) { + switch (direction()) { case MoveUp: - newY = y - animationDistance(); + newY = y - distance(); break; case MoveRight: - newX = x + animationDistance(); + newX = x + distance(); break; case MoveDown: - newY = y + animationDistance(); + newY = y + distance(); break; case MoveLeft: - newX = x - animationDistance(); + newX = x - distance(); break; case MoveUpRight: @@ -73,7 +73,7 @@ QAbstractAnimation* SlideAnimation::render(QObject* parent) //QObject::connect(anim, SIGNAL(finished()), anim, SLOT(deleteLater())); - if (animationVisible()) { + if (isVisible()) { QObject::connect(anim, SIGNAL(finished()), m_object, SLOT(show())); } else { QObject::connect(anim, SIGNAL(finished()), m_object, SLOT(hide())); @@ -85,7 +85,7 @@ QAbstractAnimation* SlideAnimation::render(QObject* parent) void SlideAnimation::setVisibleAtEnd(bool visibility) { - setAnimationVisible(visibility); + setVisible(visibility); } } //namespace Plasma diff --git a/private/abstractanimationprivate_p.h b/private/abstractanimationprivate_p.h index b0a18d44a..8a6a66374 100644 --- a/private/abstractanimationprivate_p.h +++ b/private/abstractanimationprivate_p.h @@ -21,7 +21,8 @@ #ifndef PLASMA_ANIMATIONPRIVATE_H #define PLASMA_ANIMATIONPRIVATE_H -#include +#include +#include namespace Plasma { @@ -32,7 +33,7 @@ public: /** * Object the animation(s) should act upon. */ - QGraphicsWidget* animObject; + QWeakPointer animObject; /** * Animation direction: where the animation will move. diff --git a/private/focusindicator.cpp b/private/focusindicator.cpp index 26a54b125..47786df28 100644 --- a/private/focusindicator.cpp +++ b/private/focusindicator.cpp @@ -40,9 +40,9 @@ FocusIndicator::FocusIndicator(QGraphicsWidget *parent) m_background->setCacheAllRenderedFrames(true); m_fadeIn = new FadeAnimation(1.0); - m_fadeIn->setWidget(this); + m_fadeIn->setAnimatedWidget(this); m_fadeOut = new FadeAnimation(0.0); - m_fadeOut->setWidget(this); + m_fadeOut->setAnimatedWidget(this); setOpacity(0); parent->installEventFilter(this); @@ -92,6 +92,8 @@ void FocusIndicator::resizeEvent(QGraphicsSceneResizeEvent *event) void FocusIndicator::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { + Q_UNUSED(option) + Q_UNUSED(widget) m_background->paintFrame(painter); }