* dptr
* use the qobject parent system instead of tracking it ourselves svn path=/trunk/KDE/kdelibs/; revision=1038329
This commit is contained in:
parent
27dbf07aec
commit
2a524aae11
@ -26,45 +26,65 @@
|
|||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
|
|
||||||
AnimationGroup::AnimationGroup(QObject* parent)
|
class AnimationGroupPrivate
|
||||||
: m_parent(parent),
|
|
||||||
m_parallel(false)
|
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Boolean determining if the animation is parallel. Default is false.
|
||||||
|
*/
|
||||||
|
bool parallel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map of AbstractAnimations to be run, by id.
|
||||||
|
*/
|
||||||
|
QList<AbstractAnimation *> anims;
|
||||||
|
};
|
||||||
|
|
||||||
|
AnimationGroup::AnimationGroup(QObject* parent)
|
||||||
|
: AbstractAnimation(parent),
|
||||||
|
d(new AnimationGroupPrivate)
|
||||||
|
{
|
||||||
|
d->parallel = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
AnimationGroup::~AnimationGroup()
|
AnimationGroup::~AnimationGroup()
|
||||||
{
|
{
|
||||||
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnimationGroup::setParallel(bool parallelness)
|
void AnimationGroup::setParallel(bool parallelness)
|
||||||
{
|
{
|
||||||
m_parallel = parallelness;
|
d->parallel = parallelness;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AnimationGroup::isParallel() const
|
bool AnimationGroup::isParallel() const
|
||||||
{
|
{
|
||||||
return m_parallel;
|
return d->parallel;
|
||||||
}
|
}
|
||||||
|
|
||||||
int AnimationGroup::add(AbstractAnimation* elem)
|
int AnimationGroup::add(AbstractAnimation* elem)
|
||||||
{
|
{
|
||||||
anims.insert(anims.count(), elem);
|
d->anims.insert(d->anims.count(), elem);
|
||||||
return anims.count();
|
return d->anims.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractAnimation* AnimationGroup::at(int id) const
|
AbstractAnimation* AnimationGroup::at(int id) const
|
||||||
{
|
{
|
||||||
return anims[id];
|
return d->anims.value(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnimationGroup::remove(int id)
|
void AnimationGroup::remove(int id)
|
||||||
{
|
{
|
||||||
anims.removeAt(id);
|
if (id >= d->anims.count() || id < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
d->anims.removeAt(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnimationGroup::start()
|
void AnimationGroup::start()
|
||||||
{
|
{
|
||||||
QAbstractAnimation* anim = toQAbstractAnimation(m_parent);
|
QAbstractAnimation* anim = toQAbstractAnimation(parent());
|
||||||
if (anim){
|
if (anim){
|
||||||
/* FIXME: why to create and delete all the animations
|
/* FIXME: why to create and delete all the animations
|
||||||
* every single time it runs?
|
* every single time it runs?
|
||||||
@ -76,21 +96,18 @@ void AnimationGroup::start()
|
|||||||
QAnimationGroup* AnimationGroup::toQAbstractAnimation(QObject* parent)
|
QAnimationGroup* AnimationGroup::toQAbstractAnimation(QObject* parent)
|
||||||
{
|
{
|
||||||
//if supplied, use parent given in args.
|
//if supplied, use parent given in args.
|
||||||
QObject* correctParent;
|
if (!parent){
|
||||||
if (parent){
|
parent = this->parent();
|
||||||
correctParent = parent;
|
|
||||||
} else {
|
|
||||||
correctParent = m_parent;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QAnimationGroup* g;
|
QAnimationGroup* g;
|
||||||
if (m_parallel) {
|
if (d->parallel) {
|
||||||
g = new QParallelAnimationGroup(correctParent);
|
g = new QParallelAnimationGroup(parent);
|
||||||
} else {
|
} else {
|
||||||
g = new QSequentialAnimationGroup(correctParent);
|
g = new QSequentialAnimationGroup(parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
QListIterator<AbstractAnimation*> it(anims);
|
QListIterator<AbstractAnimation*> it(d->anims);
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
//add with group as owner
|
//add with group as owner
|
||||||
g->addAnimation(it.next()->toQAbstractAnimation(g));
|
g->addAnimation(it.next()->toQAbstractAnimation(g));
|
||||||
|
@ -36,26 +36,22 @@
|
|||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
|
|
||||||
|
class AnimationGroupPrivate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief A group of Animations and / or AnimationGroups.
|
* @brief A group of Animations and / or AnimationGroups.
|
||||||
* @since 4.4
|
* @since 4.4
|
||||||
*/
|
*/
|
||||||
class PLASMA_EXPORT AnimationGroup : public AbstractAnimation
|
class PLASMA_EXPORT AnimationGroup : public AbstractAnimation
|
||||||
{
|
{
|
||||||
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(bool parallel READ isParallel WRITE setParallel)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
AnimationGroup(QObject* parent = 0);
|
AnimationGroup(QObject* parent = 0);
|
||||||
virtual ~AnimationGroup();
|
virtual ~AnimationGroup();
|
||||||
|
|
||||||
/**
|
|
||||||
* Start the animation.
|
|
||||||
*/
|
|
||||||
virtual void start();
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @arg parallelness whether the animation should be in parallel or not
|
* @arg parallelness whether the animation should be in parallel or not
|
||||||
*/
|
*/
|
||||||
@ -92,23 +88,14 @@ public:
|
|||||||
*/
|
*/
|
||||||
QAnimationGroup* toQAbstractAnimation(QObject* parent = 0);
|
QAnimationGroup* toQAbstractAnimation(QObject* parent = 0);
|
||||||
|
|
||||||
|
public Q_SLOTS:
|
||||||
|
/**
|
||||||
|
* Start the animation.
|
||||||
|
*/
|
||||||
|
virtual void start();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
AnimationGroupPrivate * const d;
|
||||||
/**
|
|
||||||
* Parent owner object to use in generated animations.
|
|
||||||
*/
|
|
||||||
QObject* m_parent;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Boolean determining if the animation is parallel. Default is false.
|
|
||||||
*/
|
|
||||||
bool m_parallel;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Map of AbstractAnimations to be run, by id.
|
|
||||||
*/
|
|
||||||
QList<AbstractAnimation *> anims;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user