2007-06-08 07:24:19 +02:00
|
|
|
/*
|
2007-08-06 13:20:02 +02:00
|
|
|
* Copyright 2007 Aaron Seigo <aseigo@kde.org>
|
2007-07-06 18:26:48 +02:00
|
|
|
* 2007 Alexis Ménard <darktears31@gmail.com>
|
2007-06-08 07:24:19 +02:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
2007-09-14 21:06:18 +02:00
|
|
|
* 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.
|
2007-06-08 07:24:19 +02:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2008-04-25 05:23:31 +02:00
|
|
|
#include "animator.h"
|
2007-06-08 07:24:19 +02:00
|
|
|
|
|
|
|
#include <QGraphicsItem>
|
2008-09-10 22:51:53 +02:00
|
|
|
#include <QTimeLine>
|
2007-06-08 07:24:19 +02:00
|
|
|
|
|
|
|
#include <KConfig>
|
|
|
|
#include <KConfigGroup>
|
|
|
|
#include <KService>
|
|
|
|
#include <KServiceTypeTrader>
|
2008-02-26 01:53:54 +01:00
|
|
|
#include <KGlobalSettings>
|
2007-06-08 07:24:19 +02:00
|
|
|
|
2008-04-25 05:17:00 +02:00
|
|
|
#include "animationdriver.h"
|
2007-06-08 07:24:19 +02:00
|
|
|
|
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
|
2008-09-20 07:46:45 +02:00
|
|
|
static const int MIN_TICK_RATE_INT = 10;
|
|
|
|
static const qreal MIN_TICK_RATE = 10;
|
2007-06-25 08:01:34 +02:00
|
|
|
|
2007-06-08 07:24:19 +02:00
|
|
|
struct AnimationState
|
|
|
|
{
|
2008-02-13 05:06:41 +01:00
|
|
|
QGraphicsItem *item;
|
|
|
|
QObject *qobj;
|
2008-04-25 05:11:59 +02:00
|
|
|
Animator::Animation animation;
|
|
|
|
Animator::CurveShape curve;
|
2007-06-25 08:01:34 +02:00
|
|
|
int interval;
|
|
|
|
int currentInterval;
|
2007-06-19 23:56:03 +02:00
|
|
|
int frames;
|
2007-06-25 08:01:34 +02:00
|
|
|
int currentFrame;
|
2008-04-30 01:16:33 +02:00
|
|
|
int id;
|
2007-06-19 23:56:03 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ElementAnimationState
|
|
|
|
{
|
2008-02-13 05:06:41 +01:00
|
|
|
QGraphicsItem *item;
|
2008-02-14 18:09:00 +01:00
|
|
|
QObject *qobj;
|
2008-04-25 05:11:59 +02:00
|
|
|
Animator::CurveShape curve;
|
|
|
|
Animator::Animation animation;
|
2007-06-25 08:01:34 +02:00
|
|
|
int interval;
|
|
|
|
int currentInterval;
|
2007-06-19 23:56:03 +02:00
|
|
|
int frames;
|
|
|
|
int currentFrame;
|
|
|
|
int id;
|
|
|
|
QPixmap pixmap;
|
2007-06-08 07:24:19 +02:00
|
|
|
};
|
|
|
|
|
2007-07-04 11:36:50 +02:00
|
|
|
struct MovementState
|
|
|
|
{
|
2008-02-13 05:06:41 +01:00
|
|
|
QGraphicsItem *item;
|
|
|
|
QObject *qobj;
|
2008-04-25 05:11:59 +02:00
|
|
|
Animator::CurveShape curve;
|
|
|
|
Animator::Movement movement;
|
2007-07-04 11:36:50 +02:00
|
|
|
int interval;
|
|
|
|
int currentInterval;
|
|
|
|
int frames;
|
|
|
|
int currentFrame;
|
2007-10-11 22:19:51 +02:00
|
|
|
QPoint start;
|
2007-07-04 11:36:50 +02:00
|
|
|
QPoint destination;
|
2008-04-30 01:16:33 +02:00
|
|
|
int id;
|
2007-07-04 11:36:50 +02:00
|
|
|
};
|
|
|
|
|
2007-10-12 09:25:24 +02:00
|
|
|
struct CustomAnimationState
|
|
|
|
{
|
2008-04-25 05:11:59 +02:00
|
|
|
Animator::CurveShape curve;
|
2007-10-12 09:25:24 +02:00
|
|
|
int frames;
|
|
|
|
int currentFrame;
|
|
|
|
int interval;
|
|
|
|
int currentInterval;
|
2008-04-24 23:26:36 +02:00
|
|
|
int id;
|
2008-10-12 00:48:38 +02:00
|
|
|
QObject *receiver;
|
|
|
|
char *slot;
|
2007-10-12 09:25:24 +02:00
|
|
|
};
|
|
|
|
|
2008-07-01 20:56:43 +02:00
|
|
|
class AnimatorPrivate
|
2007-06-08 07:24:19 +02:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2008-07-01 20:56:43 +02:00
|
|
|
AnimatorPrivate()
|
2008-04-25 05:11:59 +02:00
|
|
|
: driver(0),
|
2007-06-25 08:01:34 +02:00
|
|
|
animId(0),
|
|
|
|
timerId(0)
|
2007-06-08 07:24:19 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-07-01 20:56:43 +02:00
|
|
|
~AnimatorPrivate()
|
2007-06-08 07:24:19 +02:00
|
|
|
{
|
2007-06-25 08:01:34 +02:00
|
|
|
qDeleteAll(animatedItems);
|
|
|
|
qDeleteAll(animatedElements);
|
2007-10-12 09:25:24 +02:00
|
|
|
qDeleteAll(movingItems);
|
|
|
|
|
2008-04-24 23:26:36 +02:00
|
|
|
QMutableMapIterator<int, CustomAnimationState*> it(customAnims);
|
2007-10-12 09:25:24 +02:00
|
|
|
while (it.hasNext()) {
|
|
|
|
delete it.value()->slot;
|
|
|
|
delete it.value();
|
|
|
|
it.remove();
|
|
|
|
}
|
|
|
|
|
2007-06-25 08:01:34 +02:00
|
|
|
// Animator is a QObject
|
|
|
|
// and we don't own the items
|
|
|
|
}
|
|
|
|
|
2008-09-10 22:51:53 +02:00
|
|
|
qreal calculateProgress(int time, int duration, Animator::CurveShape curve)
|
2007-10-12 09:25:24 +02:00
|
|
|
{
|
2008-02-26 01:53:54 +01:00
|
|
|
if (!(KGlobalSettings::graphicEffectsLevel() & KGlobalSettings::SimpleAnimationEffects)) {
|
|
|
|
return qreal(1.0);
|
|
|
|
}
|
|
|
|
|
2008-09-10 22:51:53 +02:00
|
|
|
timeline.setCurveShape(static_cast<QTimeLine::CurveShape>(curve));
|
|
|
|
timeline.setDuration(duration);
|
|
|
|
qreal progress = timeline.valueForTime(time);
|
2007-10-12 09:25:24 +02:00
|
|
|
return progress;
|
|
|
|
}
|
|
|
|
|
2008-10-12 00:48:38 +02:00
|
|
|
void performAnimation(qreal amount, const AnimationState *state)
|
2007-06-25 08:01:34 +02:00
|
|
|
{
|
|
|
|
switch (state->animation) {
|
2008-10-12 00:48:38 +02:00
|
|
|
case Animator::AppearAnimation:
|
|
|
|
driver->itemAppear(amount, state->item);
|
|
|
|
break;
|
|
|
|
case Animator::DisappearAnimation:
|
|
|
|
driver->itemDisappear(amount, state->item);
|
|
|
|
if (amount >= 1) {
|
|
|
|
state->item->hide();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Animator::ActivateAnimation:
|
|
|
|
driver->itemActivated(amount, state->item);
|
|
|
|
break;
|
2007-06-25 08:01:34 +02:00
|
|
|
}
|
2007-06-08 07:24:19 +02:00
|
|
|
}
|
2007-07-27 18:34:01 +02:00
|
|
|
|
2008-10-12 00:48:38 +02:00
|
|
|
void performMovement(qreal amount, const MovementState *state)
|
2007-07-06 18:26:48 +02:00
|
|
|
{
|
|
|
|
switch (state->movement) {
|
2008-04-25 05:11:59 +02:00
|
|
|
case Animator::SlideInMovement:
|
|
|
|
case Animator::FastSlideInMovement:
|
2008-04-24 23:06:08 +02:00
|
|
|
//kDebug() << "performMovement, SlideInMovement";
|
2008-04-25 05:11:59 +02:00
|
|
|
driver->itemSlideIn(amount, state->item, state->start, state->destination);
|
2007-07-06 18:26:48 +02:00
|
|
|
break;
|
2008-04-25 05:11:59 +02:00
|
|
|
case Animator::SlideOutMovement:
|
|
|
|
case Animator::FastSlideOutMovement:
|
2008-04-24 23:06:08 +02:00
|
|
|
//kDebug() << "performMovement, SlideOutMovement";
|
2008-04-25 05:11:59 +02:00
|
|
|
driver->itemSlideOut(amount, state->item, state->start, state->destination);
|
2007-07-06 18:26:48 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2008-02-26 01:53:54 +01:00
|
|
|
|
2008-04-30 01:24:09 +02:00
|
|
|
void init(Animator *q);
|
2008-04-30 01:27:17 +02:00
|
|
|
void animatedItemDestroyed(QObject*);
|
|
|
|
void movingItemDestroyed(QObject*);
|
|
|
|
void animatedElementDestroyed(QObject*);
|
|
|
|
void customAnimReceiverDestroyed(QObject*);
|
2008-04-30 01:24:09 +02:00
|
|
|
|
2008-10-12 00:48:38 +02:00
|
|
|
AnimationDriver *driver;
|
2007-06-19 23:56:03 +02:00
|
|
|
int animId;
|
2007-06-25 08:01:34 +02:00
|
|
|
int timerId;
|
|
|
|
QTime time;
|
2008-09-10 22:51:53 +02:00
|
|
|
QTimeLine timeline;
|
2007-06-08 07:24:19 +02:00
|
|
|
|
|
|
|
//TODO: eventually perhaps we should allow multiple animations simulataneously
|
|
|
|
// which would imply changing this to a QMap<QGraphicsItem*, QList<QTimeLine*> >
|
|
|
|
// and really making the code fun ;)
|
2007-06-25 08:01:34 +02:00
|
|
|
QMap<QGraphicsItem*, AnimationState*> animatedItems;
|
2007-07-04 11:36:50 +02:00
|
|
|
QMap<QGraphicsItem*, MovementState*> movingItems;
|
2008-04-24 23:26:36 +02:00
|
|
|
QMap<int, ElementAnimationState*> animatedElements;
|
|
|
|
QMap<int, CustomAnimationState*> customAnims;
|
2007-06-08 07:24:19 +02:00
|
|
|
};
|
|
|
|
|
2008-04-25 05:11:59 +02:00
|
|
|
class AnimatorSingleton
|
2007-06-17 22:05:43 +02:00
|
|
|
{
|
|
|
|
public:
|
2008-04-25 05:11:59 +02:00
|
|
|
Animator self;
|
2007-06-17 22:05:43 +02:00
|
|
|
};
|
|
|
|
|
2008-09-10 22:51:53 +02:00
|
|
|
K_GLOBAL_STATIC(AnimatorSingleton, privateSelf)
|
2007-06-17 22:05:43 +02:00
|
|
|
|
2008-10-12 00:48:38 +02:00
|
|
|
Animator *Animator::self()
|
2007-06-17 22:05:43 +02:00
|
|
|
{
|
|
|
|
return &privateSelf->self;
|
|
|
|
}
|
|
|
|
|
2008-10-12 00:48:38 +02:00
|
|
|
Animator::Animator(QObject *parent)
|
2007-06-08 07:24:19 +02:00
|
|
|
: QObject(parent),
|
2008-07-01 20:56:43 +02:00
|
|
|
d(new AnimatorPrivate)
|
2007-06-08 07:24:19 +02:00
|
|
|
{
|
2008-04-30 01:24:09 +02:00
|
|
|
d->init(this);
|
2007-06-08 07:24:19 +02:00
|
|
|
}
|
|
|
|
|
2008-04-25 05:11:59 +02:00
|
|
|
Animator::~Animator()
|
2007-06-08 07:24:19 +02:00
|
|
|
{
|
|
|
|
delete d;
|
|
|
|
}
|
|
|
|
|
2008-10-12 00:48:38 +02:00
|
|
|
void AnimatorPrivate::animatedItemDestroyed(QObject *o)
|
2007-06-08 07:24:19 +02:00
|
|
|
{
|
2008-02-13 05:06:41 +01:00
|
|
|
//kDebug() << "testing for" << (void*)o;
|
2008-04-30 01:27:17 +02:00
|
|
|
QMutableMapIterator<QGraphicsItem*, AnimationState*> it(animatedItems);
|
2008-02-13 05:06:41 +01:00
|
|
|
while (it.hasNext()) {
|
|
|
|
it.next();
|
|
|
|
//kDebug() << "comparing against" << it.value()->qobj;
|
|
|
|
if (it.value()->qobj == o) {
|
|
|
|
kDebug() << "found deleted animated item";
|
|
|
|
delete it.value();
|
|
|
|
it.remove();
|
|
|
|
}
|
2007-07-04 11:36:50 +02:00
|
|
|
}
|
2008-02-14 18:09:00 +01:00
|
|
|
}
|
2007-07-04 11:36:50 +02:00
|
|
|
|
2008-10-12 00:48:38 +02:00
|
|
|
void AnimatorPrivate::movingItemDestroyed(QObject *o)
|
2008-02-14 18:09:00 +01:00
|
|
|
{
|
2008-04-30 01:27:17 +02:00
|
|
|
QMutableMapIterator<QGraphicsItem*, MovementState*> it(movingItems);
|
2008-02-14 18:09:00 +01:00
|
|
|
while (it.hasNext()) {
|
2008-02-13 05:06:41 +01:00
|
|
|
it.next();
|
|
|
|
if (it.value()->qobj == o) {
|
2008-02-14 18:09:00 +01:00
|
|
|
delete it.value();
|
|
|
|
it.remove();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-12 00:48:38 +02:00
|
|
|
void AnimatorPrivate::animatedElementDestroyed(QObject *o)
|
2008-02-14 18:09:00 +01:00
|
|
|
{
|
2008-04-30 01:27:17 +02:00
|
|
|
QMutableMapIterator<int, ElementAnimationState*> it(animatedElements);
|
2008-02-14 18:09:00 +01:00
|
|
|
while (it.hasNext()) {
|
|
|
|
it.next();
|
|
|
|
if (it.value()->qobj == o) {
|
|
|
|
delete it.value();
|
|
|
|
it.remove();
|
2008-02-13 05:06:41 +01:00
|
|
|
}
|
2007-06-08 07:24:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-12 00:48:38 +02:00
|
|
|
void AnimatorPrivate::customAnimReceiverDestroyed(QObject *o)
|
2007-10-12 09:25:24 +02:00
|
|
|
{
|
2008-04-30 01:27:17 +02:00
|
|
|
QMutableMapIterator<int, CustomAnimationState*> it(customAnims);
|
2007-10-12 09:25:24 +02:00
|
|
|
while (it.hasNext()) {
|
|
|
|
if (it.next().value()->receiver == o) {
|
|
|
|
delete it.value()->slot;
|
|
|
|
delete it.value();
|
|
|
|
it.remove();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-12 00:48:38 +02:00
|
|
|
int Animator::animateItem(QGraphicsItem *item, Animation animation)
|
2007-06-08 07:24:19 +02:00
|
|
|
{
|
2008-01-08 02:25:09 +01:00
|
|
|
//kDebug();
|
2007-06-25 08:01:34 +02:00
|
|
|
// get rid of any existing animations on this item.
|
|
|
|
//TODO: shoudl we allow multiple anims per item?
|
|
|
|
QMap<QGraphicsItem*, AnimationState*>::iterator it = d->animatedItems.find(item);
|
|
|
|
if (it != d->animatedItems.end()) {
|
2007-06-08 07:24:19 +02:00
|
|
|
delete it.value();
|
2007-06-25 08:01:34 +02:00
|
|
|
d->animatedItems.erase(it);
|
2007-06-08 07:24:19 +02:00
|
|
|
}
|
|
|
|
|
2008-04-27 11:02:18 +02:00
|
|
|
int frames = d->driver->animationFps(animation);
|
2007-06-08 07:24:19 +02:00
|
|
|
|
|
|
|
if (frames < 1) {
|
2007-06-25 08:01:34 +02:00
|
|
|
// evidently this animator doesn't have an implementation
|
|
|
|
// for this Animation
|
2008-04-30 01:16:33 +02:00
|
|
|
return -1;
|
2007-06-08 07:24:19 +02:00
|
|
|
}
|
|
|
|
|
2008-09-22 20:34:58 +02:00
|
|
|
int duration = d->driver->animationDuration(animation);
|
|
|
|
|
2008-10-12 00:48:38 +02:00
|
|
|
AnimationState *state = new AnimationState;
|
2008-04-30 01:16:33 +02:00
|
|
|
state->id = ++d->animId;
|
2007-06-25 08:01:34 +02:00
|
|
|
state->item = item;
|
|
|
|
state->animation = animation;
|
2008-04-25 05:11:59 +02:00
|
|
|
state->curve = d->driver->animationCurve(animation);
|
2008-09-22 20:34:58 +02:00
|
|
|
state->frames = qMax(1.0, frames * (duration / 1000.0));
|
2007-06-25 08:01:34 +02:00
|
|
|
state->currentFrame = 0;
|
2008-09-20 03:02:20 +02:00
|
|
|
state->interval = d->driver->animationDuration(animation) / qreal(state->frames);
|
|
|
|
state->interval = qMax(MIN_TICK_RATE_INT, state->interval - (state->interval % MIN_TICK_RATE_INT));
|
2007-06-25 08:01:34 +02:00
|
|
|
state->currentInterval = state->interval;
|
2008-02-13 05:06:41 +01:00
|
|
|
state->qobj = dynamic_cast<QObject*>(item);
|
|
|
|
|
2008-10-12 00:48:38 +02:00
|
|
|
if (state->qobj) {
|
|
|
|
//kDebug() << "!!!!!!!!!!!!!!!!!!!!!!!!! got us an object!";
|
|
|
|
disconnect(state->qobj, SIGNAL(destroyed(QObject*)),
|
|
|
|
this, SLOT(animatedItemDestroyed(QObject*)));
|
|
|
|
connect(state->qobj, SIGNAL(destroyed(QObject*)),
|
|
|
|
this, SLOT(animatedItemDestroyed(QObject*)));
|
|
|
|
}
|
2007-06-25 08:01:34 +02:00
|
|
|
|
|
|
|
d->animatedItems[item] = state;
|
|
|
|
d->performAnimation(0, state);
|
|
|
|
|
|
|
|
if (!d->timerId) {
|
2007-10-12 22:26:07 +02:00
|
|
|
d->timerId = startTimer(MIN_TICK_RATE);
|
2007-06-25 08:01:34 +02:00
|
|
|
d->time.restart();
|
2007-06-08 07:24:19 +02:00
|
|
|
}
|
2008-04-30 01:16:33 +02:00
|
|
|
|
|
|
|
return state->id;
|
2007-06-08 07:24:19 +02:00
|
|
|
}
|
|
|
|
|
2008-10-12 00:48:38 +02:00
|
|
|
int Animator::moveItem(QGraphicsItem *item, Movement movement, const QPoint &destination)
|
2007-07-04 11:36:50 +02:00
|
|
|
{
|
2008-01-08 02:25:09 +01:00
|
|
|
//kDebug();
|
2007-07-06 18:26:48 +02:00
|
|
|
QMap<QGraphicsItem*, MovementState*>::iterator it = d->movingItems.find(item);
|
|
|
|
if (it != d->movingItems.end()) {
|
|
|
|
delete it.value();
|
|
|
|
d->movingItems.erase(it);
|
|
|
|
}
|
|
|
|
|
2008-04-27 11:02:18 +02:00
|
|
|
int frames = d->driver->movementAnimationFps(movement);
|
2008-01-22 00:55:28 +01:00
|
|
|
if (frames <= 1) {
|
2007-07-06 18:26:48 +02:00
|
|
|
// evidently this animator doesn't have an implementation
|
|
|
|
// for this Animation
|
2008-04-30 01:16:33 +02:00
|
|
|
return -1;
|
2007-07-06 18:26:48 +02:00
|
|
|
}
|
|
|
|
|
2008-10-12 00:48:38 +02:00
|
|
|
MovementState *state = new MovementState;
|
2008-04-30 01:16:33 +02:00
|
|
|
state->id = ++d->animId;
|
2007-10-11 22:19:51 +02:00
|
|
|
state->destination = destination;
|
|
|
|
state->start = item->pos().toPoint();
|
2007-07-06 18:26:48 +02:00
|
|
|
state->item = item;
|
|
|
|
state->movement = movement;
|
2008-04-25 05:11:59 +02:00
|
|
|
state->curve = d->driver->movementAnimationCurve(movement);
|
2007-07-06 18:26:48 +02:00
|
|
|
//TODO: variance in times based on the value of animation
|
2008-05-21 07:12:40 +02:00
|
|
|
int duration = d->driver->movementAnimationDuration(movement);
|
2008-09-22 20:34:58 +02:00
|
|
|
state->frames = qMax(1.0, frames * (duration / 1000.0));
|
2007-07-06 18:26:48 +02:00
|
|
|
state->currentFrame = 0;
|
2008-09-20 03:02:20 +02:00
|
|
|
state->interval = duration / qreal(state->frames);
|
2008-09-10 20:42:11 +02:00
|
|
|
state->interval = qMax(MIN_TICK_RATE_INT, state->interval - (state->interval % MIN_TICK_RATE_INT));
|
2008-05-21 07:12:40 +02:00
|
|
|
// state->interval = (state->interval / MIN_TICK_RATE) * MIN_TICK_RATE;
|
2008-09-10 20:42:11 +02:00
|
|
|
// kDebug() << "interval of" << state->interval << state->frames << duration << frames;
|
2007-07-06 18:26:48 +02:00
|
|
|
state->currentInterval = state->interval;
|
2008-02-13 05:06:41 +01:00
|
|
|
state->qobj = dynamic_cast<QObject*>(item);
|
|
|
|
|
|
|
|
if (state->qobj) {
|
2008-02-14 18:09:00 +01:00
|
|
|
disconnect(state->qobj, SIGNAL(destroyed(QObject*)), this, SLOT(movingItemDestroyed(QObject*)));
|
|
|
|
connect(state->qobj, SIGNAL(destroyed(QObject*)), this, SLOT(movingItemDestroyed(QObject*)));
|
2008-02-13 05:06:41 +01:00
|
|
|
}
|
2007-07-06 18:26:48 +02:00
|
|
|
|
|
|
|
d->movingItems[item] = state;
|
|
|
|
d->performMovement(0, state);
|
|
|
|
|
|
|
|
if (!d->timerId) {
|
2007-10-12 22:26:07 +02:00
|
|
|
d->timerId = startTimer(MIN_TICK_RATE);
|
2007-07-06 18:26:48 +02:00
|
|
|
d->time.restart();
|
|
|
|
}
|
2008-04-30 01:16:33 +02:00
|
|
|
|
|
|
|
return state->id;
|
2007-07-04 11:36:50 +02:00
|
|
|
}
|
|
|
|
|
2008-04-25 05:11:59 +02:00
|
|
|
int Animator::customAnimation(int frames, int duration, Animator::CurveShape curve,
|
2008-10-12 00:48:38 +02:00
|
|
|
QObject *receiver, const char *slot)
|
2007-10-12 09:25:24 +02:00
|
|
|
{
|
|
|
|
if (frames < 1 || duration < 1 || !receiver || !slot) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
CustomAnimationState *state = new CustomAnimationState;
|
|
|
|
state->id = ++d->animId;
|
|
|
|
state->frames = frames;
|
|
|
|
state->currentFrame = 0;
|
|
|
|
state->curve = curve;
|
|
|
|
state->interval = duration / qreal(state->frames);
|
2008-09-20 03:02:20 +02:00
|
|
|
state->interval = qMax(MIN_TICK_RATE_INT, state->interval - (state->interval % MIN_TICK_RATE_INT));
|
2007-10-12 09:25:24 +02:00
|
|
|
state->currentInterval = state->interval;
|
|
|
|
state->receiver = receiver;
|
|
|
|
state->slot = qstrdup(slot);
|
|
|
|
|
|
|
|
d->customAnims[state->id] = state;
|
|
|
|
|
2008-02-14 18:09:00 +01:00
|
|
|
disconnect(receiver, SIGNAL(destroyed(QObject*)),
|
|
|
|
this, SLOT(customAnimReceiverDestroyed(QObject*)));
|
2007-10-12 22:26:07 +02:00
|
|
|
connect(receiver, SIGNAL(destroyed(QObject*)),
|
2007-10-12 09:25:24 +02:00
|
|
|
this, SLOT(customAnimReceiverDestroyed(QObject*)));
|
|
|
|
|
2008-05-17 19:27:18 +02:00
|
|
|
// try with only progress as argument
|
|
|
|
if (!QMetaObject::invokeMethod(receiver, slot, Q_ARG(qreal, 0))) {
|
|
|
|
//try to pass also the animation id
|
|
|
|
QMetaObject::invokeMethod(receiver, slot, Q_ARG(qreal, 0), Q_ARG(int, state->id));
|
|
|
|
}
|
2007-10-12 09:25:24 +02:00
|
|
|
|
|
|
|
if (!d->timerId) {
|
2007-10-12 22:26:07 +02:00
|
|
|
d->timerId = startTimer(MIN_TICK_RATE);
|
2007-10-12 09:25:24 +02:00
|
|
|
d->time.restart();
|
|
|
|
}
|
|
|
|
|
|
|
|
return state->id;
|
|
|
|
}
|
|
|
|
|
2008-04-25 05:11:59 +02:00
|
|
|
void Animator::stopCustomAnimation(int id)
|
2007-10-12 09:25:24 +02:00
|
|
|
{
|
2008-04-24 23:26:36 +02:00
|
|
|
QMap<int, CustomAnimationState*>::iterator it = d->customAnims.find(id);
|
2007-10-12 09:25:24 +02:00
|
|
|
if (it != d->customAnims.end()) {
|
2007-11-22 21:30:24 +01:00
|
|
|
delete [] it.value()->slot;
|
2007-10-12 09:25:24 +02:00
|
|
|
delete it.value();
|
|
|
|
d->customAnims.erase(it);
|
|
|
|
}
|
2008-01-08 02:25:09 +01:00
|
|
|
//kDebug() << "stopCustomAnimation(AnimId " << id << ") done";
|
2007-10-12 09:25:24 +02:00
|
|
|
}
|
|
|
|
|
2008-04-30 01:16:33 +02:00
|
|
|
void Animator::stopItemAnimation(int id)
|
|
|
|
{
|
|
|
|
QMutableMapIterator<QGraphicsItem*, AnimationState*> it(d->animatedItems);
|
|
|
|
while (it.hasNext()) {
|
|
|
|
it.next();
|
|
|
|
if (it.value()->id == id) {
|
|
|
|
delete it.value();
|
|
|
|
it.remove();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Animator::stopItemMovement(int id)
|
|
|
|
{
|
|
|
|
QMutableMapIterator<QGraphicsItem*, MovementState*> it(d->movingItems);
|
|
|
|
while (it.hasNext()) {
|
|
|
|
it.next();
|
|
|
|
if (it.value()->id == id) {
|
|
|
|
delete it.value();
|
|
|
|
it.remove();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-25 05:11:59 +02:00
|
|
|
int Animator::animateElement(QGraphicsItem *item, Animation animation)
|
2007-06-19 23:56:03 +02:00
|
|
|
{
|
2008-01-08 02:25:09 +01:00
|
|
|
//kDebug() << "startElementAnimation(AnimId " << animation << ")";
|
2008-09-22 20:34:58 +02:00
|
|
|
int frames = d->driver->elementAnimationFps(animation);
|
|
|
|
int duration = d->driver->animationDuration(animation);
|
|
|
|
|
2007-06-25 08:01:34 +02:00
|
|
|
ElementAnimationState *state = new ElementAnimationState;
|
|
|
|
state->item = item;
|
2008-04-25 05:11:59 +02:00
|
|
|
state->curve = d->driver->elementAnimationCurve(animation);
|
2007-06-25 08:01:34 +02:00
|
|
|
state->animation = animation;
|
2008-09-22 20:34:58 +02:00
|
|
|
state->frames = qMax(1.0, frames * (duration / 1000.0));
|
2007-06-25 08:01:34 +02:00
|
|
|
state->currentFrame = 0;
|
2008-09-22 20:34:58 +02:00
|
|
|
state->interval = duration / qreal(state->frames);
|
2008-09-20 03:02:20 +02:00
|
|
|
state->interval = qMax(MIN_TICK_RATE_INT, state->interval - (state->interval % MIN_TICK_RATE_INT));
|
2007-06-25 08:01:34 +02:00
|
|
|
state->currentInterval = state->interval;
|
|
|
|
state->id = ++d->animId;
|
2008-02-14 18:09:00 +01:00
|
|
|
state->qobj = dynamic_cast<QObject*>(item);
|
|
|
|
|
2008-10-12 00:48:38 +02:00
|
|
|
if (state->qobj) {
|
|
|
|
disconnect(state->qobj, SIGNAL(destroyed(QObject*)),
|
|
|
|
this, SLOT(animatedElementDestroyed(QObject*)));
|
|
|
|
connect(state->qobj, SIGNAL(destroyed(QObject*)),
|
|
|
|
this, SLOT(animatedElementDestroyed(QObject*)));
|
|
|
|
}
|
2007-06-25 08:01:34 +02:00
|
|
|
|
2008-10-12 00:48:38 +02:00
|
|
|
//kDebug() << "animateElement " << animation << ", interval: "
|
|
|
|
// << state->interval << ", frames: " << state->frames;
|
2007-06-25 08:01:34 +02:00
|
|
|
bool needTimer = true;
|
|
|
|
if (state->frames < 1) {
|
|
|
|
state->frames = 1;
|
|
|
|
state->currentFrame = 1;
|
|
|
|
needTimer = false;
|
2007-06-19 23:56:03 +02:00
|
|
|
}
|
|
|
|
|
2007-06-25 08:01:34 +02:00
|
|
|
d->animatedElements[state->id] = state;
|
2008-10-12 00:48:38 +02:00
|
|
|
|
2008-01-08 02:25:09 +01:00
|
|
|
//kDebug() << "startElementAnimation(AnimId " << animation << ") returning " << state->id;
|
2007-06-25 08:01:34 +02:00
|
|
|
if (needTimer && !d->timerId) {
|
|
|
|
// start a 20fps timer;
|
|
|
|
//TODO: should be started at the maximum frame rate needed only?
|
2007-10-12 22:26:07 +02:00
|
|
|
d->timerId = startTimer(MIN_TICK_RATE);
|
2007-06-25 08:01:34 +02:00
|
|
|
d->time.restart();
|
|
|
|
}
|
|
|
|
return state->id;
|
2007-06-19 23:56:03 +02:00
|
|
|
}
|
|
|
|
|
2008-04-25 05:11:59 +02:00
|
|
|
void Animator::stopElementAnimation(int id)
|
2007-06-19 23:56:03 +02:00
|
|
|
{
|
2008-04-24 23:26:36 +02:00
|
|
|
QMap<int, ElementAnimationState*>::iterator it = d->animatedElements.find(id);
|
2007-06-25 08:01:34 +02:00
|
|
|
if (it != d->animatedElements.end()) {
|
|
|
|
delete it.value();
|
|
|
|
d->animatedElements.erase(it);
|
2007-06-19 23:56:03 +02:00
|
|
|
}
|
2008-01-08 02:25:09 +01:00
|
|
|
//kDebug() << "stopElementAnimation(AnimId " << id << ") done";
|
2007-06-19 23:56:03 +02:00
|
|
|
}
|
|
|
|
|
2008-04-25 05:11:59 +02:00
|
|
|
void Animator::setInitialPixmap(int id, const QPixmap &pixmap)
|
2007-06-19 23:56:03 +02:00
|
|
|
{
|
2008-04-24 23:26:36 +02:00
|
|
|
QMap<int, ElementAnimationState*>::iterator it = d->animatedElements.find(id);
|
2007-06-19 23:56:03 +02:00
|
|
|
|
2007-06-25 08:01:34 +02:00
|
|
|
if (it == d->animatedElements.end()) {
|
2008-10-12 12:20:02 +02:00
|
|
|
kDebug() << "No entry found for id " << id;
|
2007-06-19 23:56:03 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-06-25 08:01:34 +02:00
|
|
|
it.value()->pixmap = pixmap;
|
2007-06-19 23:56:03 +02:00
|
|
|
}
|
|
|
|
|
2008-04-25 05:11:59 +02:00
|
|
|
QPixmap Animator::currentPixmap(int id)
|
2007-06-19 23:56:03 +02:00
|
|
|
{
|
2008-04-24 23:26:36 +02:00
|
|
|
QMap<int, ElementAnimationState*>::const_iterator it = d->animatedElements.find(id);
|
2007-06-19 23:56:03 +02:00
|
|
|
|
2007-06-25 08:01:34 +02:00
|
|
|
if (it == d->animatedElements.constEnd()) {
|
2008-04-25 05:11:59 +02:00
|
|
|
//kDebug() << "Animator::currentPixmap(" << id << ") found no entry for it!";
|
2007-06-19 23:56:03 +02:00
|
|
|
return QPixmap();
|
|
|
|
}
|
|
|
|
|
2008-10-12 00:48:38 +02:00
|
|
|
ElementAnimationState *state = it.value();
|
2008-09-10 22:51:53 +02:00
|
|
|
qreal progress = d->calculateProgress(state->currentFrame * state->interval,
|
|
|
|
state->frames * state->interval,
|
|
|
|
state->curve);
|
2008-04-25 05:11:59 +02:00
|
|
|
//kDebug() << "Animator::currentPixmap(" << id << " at " << progress;
|
2007-06-19 23:56:03 +02:00
|
|
|
|
2007-06-25 08:01:34 +02:00
|
|
|
switch (state->animation) {
|
2008-04-25 00:30:53 +02:00
|
|
|
case AppearAnimation:
|
2008-04-25 05:11:59 +02:00
|
|
|
return d->driver->elementAppear(progress, state->pixmap);
|
2007-06-19 23:56:03 +02:00
|
|
|
break;
|
2008-04-25 00:30:53 +02:00
|
|
|
case DisappearAnimation:
|
2008-04-25 05:11:59 +02:00
|
|
|
return d->driver->elementDisappear(progress, state->pixmap);
|
2007-06-19 23:56:03 +02:00
|
|
|
break;
|
2008-04-25 05:17:00 +02:00
|
|
|
case ActivateAnimation:
|
|
|
|
break;
|
2007-06-19 23:56:03 +02:00
|
|
|
}
|
|
|
|
|
2007-06-25 08:01:34 +02:00
|
|
|
return state->pixmap;
|
2007-06-19 23:56:03 +02:00
|
|
|
}
|
|
|
|
|
2008-04-25 05:11:59 +02:00
|
|
|
bool Animator::isAnimating() const
|
2008-04-14 20:04:34 +02:00
|
|
|
{
|
|
|
|
return (!d->animatedItems.isEmpty() ||
|
|
|
|
!d->movingItems.isEmpty() ||
|
|
|
|
!d->animatedElements.isEmpty() ||
|
|
|
|
!d->customAnims.isEmpty());
|
|
|
|
}
|
|
|
|
|
2008-04-25 05:11:59 +02:00
|
|
|
void Animator::timerEvent(QTimerEvent *event)
|
2007-06-19 23:56:03 +02:00
|
|
|
{
|
2007-06-25 08:01:34 +02:00
|
|
|
Q_UNUSED(event)
|
|
|
|
bool animationsRemain = false;
|
2007-10-12 22:26:07 +02:00
|
|
|
int elapsed = MIN_TICK_RATE;
|
2007-06-25 08:01:34 +02:00
|
|
|
if (d->time.elapsed() > elapsed) {
|
|
|
|
elapsed = d->time.elapsed();
|
2007-06-19 23:56:03 +02:00
|
|
|
}
|
2007-06-25 08:01:34 +02:00
|
|
|
d->time.restart();
|
2008-01-08 02:25:09 +01:00
|
|
|
//kDebug() << "timeEvent, elapsed time: " << elapsed;
|
2007-06-25 08:01:34 +02:00
|
|
|
|
2008-10-12 00:48:38 +02:00
|
|
|
foreach (AnimationState *state, d->animatedItems) {
|
2007-06-25 08:01:34 +02:00
|
|
|
if (state->currentInterval <= elapsed) {
|
|
|
|
// we need to step forward!
|
2008-10-12 00:48:38 +02:00
|
|
|
state->currentFrame +=
|
|
|
|
(KGlobalSettings::graphicEffectsLevel() & KGlobalSettings::SimpleAnimationEffects) ?
|
|
|
|
qMax(1, elapsed / state->interval) : state->frames - state->currentFrame;
|
2007-06-25 08:01:34 +02:00
|
|
|
|
|
|
|
if (state->currentFrame < state->frames) {
|
2008-09-10 22:51:53 +02:00
|
|
|
qreal progress = d->calculateProgress(state->currentFrame * state->interval,
|
|
|
|
state->frames * state->interval,
|
|
|
|
state->curve);
|
2007-07-06 18:26:48 +02:00
|
|
|
d->performAnimation(progress, state);
|
2007-06-25 08:01:34 +02:00
|
|
|
state->currentInterval = state->interval;
|
|
|
|
animationsRemain = true;
|
|
|
|
} else {
|
|
|
|
d->performAnimation(1, state);
|
|
|
|
d->animatedItems.erase(d->animatedItems.find(state->item));
|
2008-04-24 22:16:40 +02:00
|
|
|
emit animationFinished(state->item, state->animation);
|
2007-06-25 08:01:34 +02:00
|
|
|
delete state;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
state->currentInterval -= elapsed;
|
|
|
|
animationsRemain = true;
|
|
|
|
}
|
2007-06-19 23:56:03 +02:00
|
|
|
}
|
|
|
|
|
2008-10-12 00:48:38 +02:00
|
|
|
foreach (MovementState *state, d->movingItems) {
|
2007-07-06 18:26:48 +02:00
|
|
|
if (state->currentInterval <= elapsed) {
|
|
|
|
// we need to step forward!
|
2008-10-12 00:48:38 +02:00
|
|
|
state->currentFrame +=
|
|
|
|
(KGlobalSettings::graphicEffectsLevel() & KGlobalSettings::SimpleAnimationEffects) ?
|
|
|
|
qMax(1, elapsed / state->interval) : state->frames - state->currentFrame;
|
2007-07-06 18:26:48 +02:00
|
|
|
|
|
|
|
if (state->currentFrame < state->frames) {
|
2008-05-21 07:12:40 +02:00
|
|
|
//kDebug() << "movement";
|
2008-09-10 22:51:53 +02:00
|
|
|
qreal progress = d->calculateProgress(state->currentFrame * state->interval,
|
|
|
|
state->frames * state->interval,
|
|
|
|
state->curve);
|
|
|
|
d->performMovement(progress, state);
|
2007-07-06 18:26:48 +02:00
|
|
|
animationsRemain = true;
|
|
|
|
} else {
|
2008-05-21 07:12:40 +02:00
|
|
|
//kDebug() << "movement";
|
2007-07-06 18:26:48 +02:00
|
|
|
d->performMovement(1, state);
|
|
|
|
d->movingItems.erase(d->movingItems.find(state->item));
|
2008-04-24 22:16:40 +02:00
|
|
|
emit movementFinished(state->item);
|
2007-07-06 18:26:48 +02:00
|
|
|
delete state;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
state->currentInterval -= elapsed;
|
|
|
|
animationsRemain = true;
|
|
|
|
}
|
2007-07-04 11:36:50 +02:00
|
|
|
}
|
|
|
|
|
2008-10-12 00:48:38 +02:00
|
|
|
foreach (ElementAnimationState *state, d->animatedElements) {
|
2007-06-25 08:01:34 +02:00
|
|
|
if (state->currentFrame == state->frames) {
|
2008-10-12 00:48:38 +02:00
|
|
|
//kDebug() << "skipping" << state->id << "as its already at frame"
|
|
|
|
// << state->currentFrame << "of" << state->frames;
|
2007-06-25 08:01:34 +02:00
|
|
|
// since we keep element animations around until they are
|
|
|
|
// removed, we will end up with finished animations in the queue;
|
|
|
|
// just skip them
|
|
|
|
//TODO: should we move them to a separate QMap?
|
|
|
|
continue;
|
|
|
|
}
|
2007-06-19 23:56:03 +02:00
|
|
|
|
2007-06-25 08:01:34 +02:00
|
|
|
if (state->currentInterval <= elapsed) {
|
|
|
|
// we need to step forward!
|
2008-10-12 00:48:38 +02:00
|
|
|
/*kDebug() << "stepping forwards element anim " << state->id
|
|
|
|
<< " from " << state->currentFrame
|
|
|
|
<< " by " << qMax(1, elapsed / state->interval) << " to "
|
|
|
|
<< state->currentFrame + qMax(1, elapsed / state->interval) << endl;*/
|
|
|
|
state->currentFrame +=
|
|
|
|
(KGlobalSettings::graphicEffectsLevel() & KGlobalSettings::SimpleAnimationEffects) ?
|
|
|
|
qMax(1, elapsed / state->interval) : state->frames - state->currentFrame;
|
2008-09-10 22:51:53 +02:00
|
|
|
|
2008-07-13 20:38:56 +02:00
|
|
|
state->item->update();
|
2007-06-25 08:01:34 +02:00
|
|
|
if (state->currentFrame < state->frames) {
|
|
|
|
state->currentInterval = state->interval;
|
|
|
|
animationsRemain = true;
|
2008-02-12 06:51:43 +01:00
|
|
|
} else {
|
2008-02-14 18:09:00 +01:00
|
|
|
d->animatedElements.remove(state->id);
|
2008-04-24 22:16:40 +02:00
|
|
|
emit elementAnimationFinished(state->id);
|
2008-02-12 06:51:43 +01:00
|
|
|
delete state;
|
2007-06-25 08:01:34 +02:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
state->currentInterval -= elapsed;
|
2007-10-12 09:25:24 +02:00
|
|
|
animationsRemain = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach (CustomAnimationState *state, d->customAnims) {
|
|
|
|
if (state->currentInterval <= elapsed) {
|
|
|
|
// advance the frame
|
2008-10-12 00:48:38 +02:00
|
|
|
state->currentFrame +=
|
|
|
|
(KGlobalSettings::graphicEffectsLevel() & KGlobalSettings::SimpleAnimationEffects) ?
|
|
|
|
qMax(1, elapsed / state->interval) : state->frames - state->currentFrame;
|
|
|
|
/*kDebug() << "custom anim for" << state->receiver
|
|
|
|
<< "to slot" << state->slot
|
|
|
|
<< "with interval of" << state->interval
|
|
|
|
<< "at frame" << state->currentFrame;*/
|
2007-10-12 09:25:24 +02:00
|
|
|
|
|
|
|
if (state->currentFrame < state->frames) {
|
2007-10-13 00:45:41 +02:00
|
|
|
//kDebug () << "not the final frame";
|
2007-10-12 09:25:24 +02:00
|
|
|
//TODO: calculate a proper interval based on the curve
|
|
|
|
state->currentInterval = state->interval;
|
|
|
|
animationsRemain = true;
|
|
|
|
// signal the object
|
2008-05-17 19:27:18 +02:00
|
|
|
// try with only progress as argument
|
2008-09-10 22:51:53 +02:00
|
|
|
qreal progress = d->calculateProgress(state->currentFrame * state->interval,
|
|
|
|
state->frames * state->interval,
|
|
|
|
state->curve);
|
|
|
|
if (!QMetaObject::invokeMethod(state->receiver, state->slot, Q_ARG(qreal, progress))) {
|
2008-05-17 19:27:18 +02:00
|
|
|
//if fails try to add the animation id
|
2008-09-10 22:51:53 +02:00
|
|
|
QMetaObject::invokeMethod(state->receiver, state->slot, Q_ARG(qreal, progress),
|
|
|
|
Q_ARG(int, state->id));
|
2008-05-17 19:27:18 +02:00
|
|
|
}
|
2007-10-12 09:25:24 +02:00
|
|
|
} else {
|
2008-05-17 19:27:18 +02:00
|
|
|
if (!QMetaObject::invokeMethod(state->receiver, state->slot, Q_ARG(qreal, 1))) {
|
|
|
|
QMetaObject::invokeMethod(state->receiver, state->slot, Q_ARG(qreal, 1), Q_ARG(int, state->id));
|
|
|
|
}
|
2007-10-12 09:25:24 +02:00
|
|
|
d->customAnims.erase(d->customAnims.find(state->id));
|
2008-04-24 22:16:40 +02:00
|
|
|
emit customAnimationFinished(state->id);
|
2007-11-22 21:30:24 +01:00
|
|
|
delete [] state->slot;
|
2007-10-12 09:25:24 +02:00
|
|
|
delete state;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
state->currentInterval -= elapsed;
|
2007-06-25 08:01:34 +02:00
|
|
|
animationsRemain = true;
|
|
|
|
}
|
2007-06-19 23:56:03 +02:00
|
|
|
}
|
|
|
|
|
2007-06-25 08:01:34 +02:00
|
|
|
if (!animationsRemain && d->timerId) {
|
|
|
|
killTimer(d->timerId);
|
|
|
|
d->timerId = 0;
|
2007-06-19 23:56:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-01 20:56:43 +02:00
|
|
|
void AnimatorPrivate::init(Animator *q)
|
2007-06-08 07:24:19 +02:00
|
|
|
{
|
2008-04-30 01:24:09 +02:00
|
|
|
//FIXME: usage between different applications?
|
2007-06-08 07:24:19 +02:00
|
|
|
KConfig c("plasmarc");
|
2008-04-25 05:11:59 +02:00
|
|
|
KConfigGroup cg(&c, "Animator");
|
|
|
|
QString pluginName = cg.readEntry("driver", "default");
|
2007-06-08 07:24:19 +02:00
|
|
|
|
|
|
|
if (!pluginName.isEmpty()) {
|
|
|
|
QString constraint = QString("[X-KDE-PluginInfo-Name] == '%1'").arg(pluginName);
|
|
|
|
KService::List offers = KServiceTypeTrader::self()->query("Plasma/Animator", constraint);
|
|
|
|
|
|
|
|
if (!offers.isEmpty()) {
|
2007-08-29 05:06:48 +02:00
|
|
|
QString error;
|
2008-07-17 18:26:29 +02:00
|
|
|
|
|
|
|
KPluginLoader plugin(*offers.first());
|
|
|
|
|
2008-10-12 00:48:38 +02:00
|
|
|
if (Plasma::isPluginVersionCompatible(plugin.pluginVersion())) {
|
2008-07-17 18:26:29 +02:00
|
|
|
driver = offers.first()->createInstance<Plasma::AnimationDriver>(0, QVariantList(), &error);
|
2008-10-12 00:48:38 +02:00
|
|
|
}
|
2008-07-17 18:26:29 +02:00
|
|
|
|
2008-04-30 01:24:09 +02:00
|
|
|
if (!driver) {
|
2008-10-12 00:48:38 +02:00
|
|
|
kDebug() << "Could not load requested animator "
|
|
|
|
<< offers.first() << ". Error given: " << error;
|
2007-08-29 05:06:48 +02:00
|
|
|
}
|
2007-06-08 07:24:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-30 01:24:09 +02:00
|
|
|
if (!driver) {
|
|
|
|
driver = new AnimationDriver(q);
|
2007-06-08 07:24:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Plasma
|
|
|
|
|
2008-04-25 05:23:31 +02:00
|
|
|
#include <animator.moc>
|