plasma animations: removing custom animation. the animations done by custom can be done adding a property and using qpropertyanimation

svn path=/trunk/KDE/kdelibs/; revision=1073191
This commit is contained in:
Igor Trindade Oliveira 2010-01-11 20:06:14 +00:00
parent ee374de18f
commit e2cf011103
5 changed files with 1 additions and 187 deletions

View File

@ -59,7 +59,6 @@ set(plasma_LIB_SRCS
animations/stackedlayout.cpp
animations/geometry.cpp
animations/zoom.cpp
animations/customanimation.cpp
applet.cpp
configloader.cpp
containment.cpp

View File

@ -1,114 +0,0 @@
/////////////////////////////////////////////////////////////////////////
// customanimation.cpp //
// //
// Copyright (C) 2010 Igor Oliveira <igor.oliveira@openbossa.org> //
// Copyright (C) 2010 Adenilson Cavalcanti <cavalcantii@gmail.com //
// //
// This library is free software; you can redistribute it and/or //
// modify it under the terms of the GNU Lesser General Public //
// License as published by the Free Software Foundation; either //
// version 2.1 of the License, or (at your option) any later version. //
// //
// This library 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 //
// Lesser General Public License for more details. //
// //
// You should have received a copy of the GNU Lesser General Public //
// License along with this library; if not, write to the Free Software //
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA //
// 02110-1301 USA //
/////////////////////////////////////////////////////////////////////////
#include "customanimation_p.h"
#include <QString>
namespace Plasma
{
CustomAnimation::CustomAnimation(QObject *parent)
: Animation(parent)
{
}
QString CustomAnimation::callback() const
{
return m_method;
}
void CustomAnimation::setCallback(const QString &slot)
{
m_method = slot;
}
QVariant CustomAnimation::startValue() const
{
return m_startValue;
}
void CustomAnimation::setStartValue(const QVariant &value)
{
m_startValue = value;
}
QVariant CustomAnimation::endValue() const
{
return m_endValue;
}
void CustomAnimation::setEndValue(const QVariant &value)
{
m_endValue = value;
}
void CustomAnimation::updateCurrentTime(int currentTime)
{
QGraphicsWidget *obj = targetWidget();
if (obj) {
qreal delta = currentTime / qreal(duration());
delta = Animation::easingCurve().valueForProgress(delta);
const QVariant retValue = interpolate(startValue(), endValue(), delta);
QMetaObject::invokeMethod(obj, m_method.toUtf8().data(), Q_ARG(QVariant, retValue));
}
Animation::updateCurrentTime(currentTime);
}
QVariant CustomAnimation::interpolate(const QVariant &start, const QVariant &end, qreal delta)
{
QVariant retValue;
if (start.type() != end.type()) {
return retValue;
}
if (start.type() == QVariant::Double) {
qreal realStartValue = start.toReal();
qreal realEndValue = end.toReal();
qreal retRealValue = (realStartValue - realEndValue) * delta;
retValue = QVariant(retRealValue);
} else if (start.type() == QVariant::Int) {
int intStartValue = start.toInt();
int intEndValue = end.toInt();
int retIntValue = (intStartValue - intEndValue) * delta;
retValue = QVariant(retIntValue);
} else if (start.type() == QVariant::RectF) {
QRectF rectfStartValue = start.toRectF();
QRectF rectfEndValue = end.toRectF();
QRectF retRectfValue = QRectF((rectfStartValue.x() - rectfEndValue.x()) * delta,
(rectfStartValue.y() - rectfEndValue.x()) * delta,
(rectfStartValue.width() - rectfEndValue.width()) * delta,
(rectfStartValue.height() - rectfEndValue.height()) * delta);
retValue = QVariant(retRectfValue);
}
return retValue;
}
}

View File

@ -1,65 +0,0 @@
/*********************************************************************/
/* */
/* Copyright (C) 2010 Igor Oliveira <igor.oliveira@openbossa.org> */
/* Copyright (C) 2010 Adenilson Cavalcanti <cavalcantii@gmail.com> */
/* */
/* This program is free software; you can redistribute it and/or */
/* modify it under the terms of the GNU General Public License */
/* as published by the Free Software Foundation; either version 2 */
/* of the License, 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 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. */
/*********************************************************************/
#ifndef PLASMA_ANIMATIONS_CUSTOMANIMATION_H
#define PLASMA_ANIMATIONS_CUSTOMANIMATION_H
#include <plasma/animations/animation.h>
#include <plasma/plasma_export.h>
class QString;
namespace Plasma
{
class CustomAnimation : public Animation
{
Q_OBJECT
Q_PROPERTY(QString callback READ callback WRITE setCallback)
Q_PROPERTY(QVariant startValue READ startValue WRITE setStartValue)
Q_PROPERTY(QVariant endValue READ endValue WRITE setEndValue)
public:
CustomAnimation(QObject *parent = 0);
QString callback() const;
void setCallback(const QString &method);
QVariant startValue() const;
void setStartValue(const QVariant &value);
QVariant endValue() const;
void setEndValue(const QVariant &value);
protected:
void updateCurrentTime(int currentTime);
private:
QVariant interpolate(const QVariant &start, const QVariant &end, qreal delta);
private:
QString m_method;
QVariant m_startValue;
QVariant m_endValue;
};
}
#endif

View File

@ -29,7 +29,6 @@
#include "animations/rotationstacked_p.h"
#include "animations/geometry_p.h"
#include "animations/zoom_p.h"
#include "animations/customanimation_p.h"
namespace Plasma
{
@ -71,10 +70,6 @@ Plasma::Animation* Animator::create(Animator::Animation type, QObject *parent)
result = new Plasma::ZoomAnimation(parent);
break;
case CustomAnimation:
result = new Plasma::CustomAnimation(parent);
break;
default:
kDebug() << "Unsupported animation type.";
}

View File

@ -65,8 +65,7 @@ public:
RotationStackedAnimation, /*<< for flipping one object with another */
SlideAnimation, /*<< Move the position of animated object */
GeometryAnimation, /*<< Geometry animation*/
ZoomAnimation, /*<<Zoom animation */
CustomAnimation
ZoomAnimation /*<<Zoom animation */
};
enum CurveShape {