API cleanups

svn path=/trunk/KDE/kdelibs/; revision=1038232
This commit is contained in:
Aaron J. Seigo 2009-10-20 21:14:46 +00:00
parent b29d0a79aa
commit 8b9830dc2b
11 changed files with 58 additions and 55 deletions

View File

@ -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;
}

View File

@ -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;

View File

@ -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;
}

View File

@ -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:

View File

@ -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());

View File

@ -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();

View File

@ -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);

View File

@ -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);

View File

@ -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

View File

@ -21,7 +21,8 @@
#ifndef PLASMA_ANIMATIONPRIVATE_H
#define PLASMA_ANIMATIONPRIVATE_H
#include <QEasingCurve>
#include <QEasingCurve>
#include <QWeakPointer>
namespace Plasma
{
@ -32,7 +33,7 @@ public:
/**
* Object the animation(s) should act upon.
*/
QGraphicsWidget* animObject;
QWeakPointer<QGraphicsWidget> animObject;
/**
* Animation direction: where the animation will move.

View File

@ -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);
}