2009-10-15 21:36:38 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2009 Mehmet Ali Akmanalp <makmanalp@wpi.edu>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Library General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this program; if not, write to the
|
|
|
|
* Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "abstractanimation.h"
|
2009-10-20 23:04:49 +02:00
|
|
|
#include "private/abstractanimationprivate_p.h"
|
2009-10-15 21:36:38 +02:00
|
|
|
|
2009-10-20 15:08:23 +02:00
|
|
|
#include <QEasingCurve>
|
|
|
|
|
2009-10-22 06:00:48 +02:00
|
|
|
#include <kdebug.h>
|
|
|
|
|
2009-10-15 21:36:38 +02:00
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
|
2009-10-22 06:00:48 +02:00
|
|
|
AbstractAnimationPrivate::AbstractAnimationPrivate()
|
2009-10-22 17:35:08 +02:00
|
|
|
: animVisible(true),
|
|
|
|
easingCurve(QEasingCurve::Linear),
|
2009-10-22 06:00:48 +02:00
|
|
|
forwards(true)
|
|
|
|
{
|
|
|
|
}
|
2009-10-17 19:02:28 +02:00
|
|
|
|
2009-10-21 06:15:04 +02:00
|
|
|
AbstractAnimation::AbstractAnimation(QObject *parent)
|
|
|
|
: QObject(parent),
|
|
|
|
d(new AbstractAnimationPrivate)
|
2009-10-16 18:36:22 +02:00
|
|
|
{
|
2009-10-15 21:36:38 +02:00
|
|
|
}
|
|
|
|
|
2009-10-16 18:36:22 +02:00
|
|
|
AbstractAnimation::~AbstractAnimation()
|
|
|
|
{
|
2009-10-17 19:02:28 +02:00
|
|
|
delete d;
|
2009-10-15 21:36:38 +02:00
|
|
|
}
|
|
|
|
|
2009-10-20 23:21:40 +02:00
|
|
|
void AbstractAnimation::setWidgetToAnimate(QGraphicsWidget* receiver)
|
2009-10-16 18:36:22 +02:00
|
|
|
{
|
2009-10-17 19:08:15 +02:00
|
|
|
d->animObject = receiver;
|
2009-10-23 20:39:57 +02:00
|
|
|
/* Changed the object, delete the animation */
|
|
|
|
delete d->animation.data();
|
|
|
|
d->animation.clear();
|
|
|
|
|
2009-10-15 21:36:38 +02:00
|
|
|
}
|
|
|
|
|
2009-10-20 23:21:40 +02:00
|
|
|
QGraphicsWidget* AbstractAnimation::widgetToAnimate()
|
2009-10-15 21:36:38 +02:00
|
|
|
{
|
2009-10-20 23:14:46 +02:00
|
|
|
return d->animObject.data();
|
2009-10-15 21:36:38 +02:00
|
|
|
}
|
|
|
|
|
2009-10-20 15:08:23 +02:00
|
|
|
void AbstractAnimation::setEasingCurveType(QEasingCurve::Type easingCurve)
|
|
|
|
{
|
|
|
|
d->easingCurve = easingCurve;
|
|
|
|
}
|
|
|
|
|
|
|
|
QEasingCurve::Type AbstractAnimation::easingCurveType() const
|
|
|
|
{
|
|
|
|
return d->easingCurve;
|
|
|
|
}
|
|
|
|
|
2009-10-22 06:00:48 +02:00
|
|
|
void AbstractAnimation::setForwards(bool forwards)
|
|
|
|
{
|
|
|
|
d->forwards = forwards;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool AbstractAnimation::forwards() const
|
|
|
|
{
|
|
|
|
return d->forwards;
|
|
|
|
}
|
|
|
|
|
2009-11-12 21:15:43 +01:00
|
|
|
void AbstractAnimation::setDirection(const qint8 &direction)
|
2009-10-20 17:53:53 +02:00
|
|
|
{
|
2009-11-13 01:18:17 +01:00
|
|
|
d->animDirection = static_cast<Plasma::AnimationDirection>(direction);
|
2009-10-20 17:53:53 +02:00
|
|
|
}
|
|
|
|
|
2009-11-12 21:15:43 +01:00
|
|
|
qint8 AbstractAnimation::direction() const
|
2009-10-20 17:53:53 +02:00
|
|
|
{
|
|
|
|
return d->animDirection;
|
|
|
|
}
|
|
|
|
|
2009-10-20 23:14:46 +02:00
|
|
|
void AbstractAnimation::setDistance(qreal distance)
|
2009-10-20 17:53:53 +02:00
|
|
|
{
|
2009-10-20 23:14:46 +02:00
|
|
|
d->animDistance = distance;
|
2009-10-20 17:53:53 +02:00
|
|
|
}
|
|
|
|
|
2009-10-20 23:14:46 +02:00
|
|
|
qreal AbstractAnimation::distance() const
|
2009-10-20 17:53:53 +02:00
|
|
|
{
|
|
|
|
return d->animDistance;
|
|
|
|
}
|
|
|
|
|
2009-10-20 23:14:46 +02:00
|
|
|
void AbstractAnimation::setVisible(bool isVisible)
|
2009-10-20 17:53:53 +02:00
|
|
|
{
|
2009-10-20 23:14:46 +02:00
|
|
|
d->animVisible = isVisible;
|
2009-10-20 17:53:53 +02:00
|
|
|
}
|
|
|
|
|
2009-10-20 23:14:46 +02:00
|
|
|
bool AbstractAnimation::isVisible() const
|
2009-10-20 17:53:53 +02:00
|
|
|
{
|
|
|
|
return d->animVisible;
|
|
|
|
}
|
|
|
|
|
2009-10-23 20:39:57 +02:00
|
|
|
QAbstractAnimation* AbstractAnimation::animation()
|
|
|
|
{
|
|
|
|
return d->animation.data();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AbstractAnimation::setAnimation(QAbstractAnimation *obj)
|
|
|
|
{
|
|
|
|
d->animation = obj;
|
|
|
|
}
|
|
|
|
|
2009-10-21 09:51:11 +02:00
|
|
|
void AbstractAnimation::start()
|
|
|
|
{
|
|
|
|
QAbstractAnimation* anim = toQAbstractAnimation(parent());
|
|
|
|
if (anim) {
|
2009-10-22 06:00:48 +02:00
|
|
|
anim->setDirection(d->forwards ? QAbstractAnimation::Forward :
|
|
|
|
QAbstractAnimation::Backward);
|
2009-10-23 20:39:57 +02:00
|
|
|
anim->start();
|
2009-10-21 09:51:11 +02:00
|
|
|
}
|
|
|
|
}
|
2009-10-21 07:32:04 +02:00
|
|
|
|
2009-10-15 21:36:38 +02:00
|
|
|
} //namespace Plasma
|
|
|
|
|
|
|
|
#include <../abstractanimation.moc>
|