make animation groups work again in javascript by subclassing the Qt classes and making the interesting methods scriptable in the subclasses and calling the parent class implementations.

svn path=/trunk/KDE/kdebase/runtime/; revision=1062484
This commit is contained in:
Aaron J. Seigo 2009-12-14 21:54:23 +00:00
parent 49f3bb58da
commit 52aaea24e7
4 changed files with 131 additions and 2 deletions

View File

@ -2,6 +2,7 @@
set(simple_javascript_engine_SRCS set(simple_javascript_engine_SRCS
simplejavascriptapplet.cpp simplejavascriptapplet.cpp
simplebindings/animationgroup.cpp
simplebindings/appletinterface.cpp simplebindings/appletinterface.cpp
simplebindings/anchorlayout.cpp simplebindings/anchorlayout.cpp
simplebindings/color.cpp simplebindings/color.cpp

View File

@ -0,0 +1,85 @@
#include "animationgroup.h"
ParallelAnimationGroup::ParallelAnimationGroup(QObject *parent)
: QParallelAnimationGroup(parent)
{
}
void ParallelAnimationGroup::addAnimation(QAbstractAnimation *animation)
{
QParallelAnimationGroup::addAnimation(animation);
}
QAbstractAnimation *ParallelAnimationGroup::animationAt(int index) const
{
return QParallelAnimationGroup::animationAt(index);
}
int ParallelAnimationGroup::animationCount() const
{
return QParallelAnimationGroup::animationCount();
}
void ParallelAnimationGroup::clearAnimations()
{
QParallelAnimationGroup::clearAnimations();
}
int ParallelAnimationGroup::indexOfAnimation(QAbstractAnimation *animation) const
{
return QParallelAnimationGroup::indexOfAnimation(animation);
}
void ParallelAnimationGroup::insertAnimationAt(int index, QAbstractAnimation *animation)
{
QParallelAnimationGroup::insertAnimationAt(index, animation);
}
void ParallelAnimationGroup::removeAnimation(QAbstractAnimation *animation)
{
QParallelAnimationGroup::removeAnimation(animation);
}
SequentialAnimationGroup::SequentialAnimationGroup(QObject *parent)
: QSequentialAnimationGroup(parent)
{
}
void SequentialAnimationGroup::addAnimation(QAbstractAnimation *animation)
{
QSequentialAnimationGroup::addAnimation(animation);
}
QAbstractAnimation *SequentialAnimationGroup::animationAt(int index) const
{
return QSequentialAnimationGroup::animationAt(index);
}
int SequentialAnimationGroup::animationCount() const
{
return QSequentialAnimationGroup::animationCount();
}
void SequentialAnimationGroup::clearAnimations()
{
QSequentialAnimationGroup::clearAnimations();
}
int SequentialAnimationGroup::indexOfAnimation(QAbstractAnimation *animation) const
{
return QSequentialAnimationGroup::indexOfAnimation(animation);
}
void SequentialAnimationGroup::insertAnimationAt(int index, QAbstractAnimation *animation)
{
QSequentialAnimationGroup::insertAnimationAt(index, animation);
}
void SequentialAnimationGroup::removeAnimation(QAbstractAnimation *animation)
{
QSequentialAnimationGroup::removeAnimation(animation);
}
#include "animationgroup.moc"

View File

@ -0,0 +1,42 @@
#ifndef ANIMATIONGROUP_H
#define ANIMATIONGROUP_H
#include <QParallelAnimationGroup>
#include <QSequentialAnimationGroup>
class ParallelAnimationGroup : public QParallelAnimationGroup
{
Q_OBJECT
public:
ParallelAnimationGroup(QObject *parent);
public Q_SLOTS:
void addAnimation(QAbstractAnimation * animation);
QAbstractAnimation *animationAt(int index) const;
int animationCount() const;
void clearAnimations();
int indexOfAnimation(QAbstractAnimation *animation) const;
void insertAnimationAt(int index, QAbstractAnimation * animation);
void removeAnimation(QAbstractAnimation * animation);
};
class SequentialAnimationGroup : public QSequentialAnimationGroup
{
Q_OBJECT
public:
SequentialAnimationGroup(QObject *parent);
public Q_SLOTS:
void addAnimation(QAbstractAnimation * animation);
QAbstractAnimation *animationAt(int index) const;
int animationCount() const;
void clearAnimations();
int indexOfAnimation(QAbstractAnimation *animation) const;
void insertAnimationAt(int index, QAbstractAnimation * animation);
void removeAnimation(QAbstractAnimation * animation);
};
#endif

View File

@ -45,6 +45,7 @@
#include <Plasma/Package> #include <Plasma/Package>
#include <Plasma/VideoWidget> #include <Plasma/VideoWidget>
#include "simplebindings/animationgroup.h"
#include "simplebindings/appletinterface.h" #include "simplebindings/appletinterface.h"
#include "simplebindings/filedialogproxy.h" #include "simplebindings/filedialogproxy.h"
@ -740,14 +741,14 @@ QScriptValue SimpleJavaScriptApplet::animation(QScriptContext *context, QScriptE
QScriptValue SimpleJavaScriptApplet::animationGroup(QScriptContext *context, QScriptEngine *engine) QScriptValue SimpleJavaScriptApplet::animationGroup(QScriptContext *context, QScriptEngine *engine)
{ {
QGraphicsWidget *parent = extractParent(context, engine); QGraphicsWidget *parent = extractParent(context, engine);
QSequentialAnimationGroup *group = new QSequentialAnimationGroup(parent); SequentialAnimationGroup *group = new SequentialAnimationGroup(parent);
return engine->newQObject(group); return engine->newQObject(group);
} }
QScriptValue SimpleJavaScriptApplet::parallelAnimationGroup(QScriptContext *context, QScriptEngine *engine) QScriptValue SimpleJavaScriptApplet::parallelAnimationGroup(QScriptContext *context, QScriptEngine *engine)
{ {
QGraphicsWidget *parent = extractParent(context, engine); QGraphicsWidget *parent = extractParent(context, engine);
QParallelAnimationGroup *group = new QParallelAnimationGroup(parent); ParallelAnimationGroup *group = new ParallelAnimationGroup(parent);
return engine->newQObject(group); return engine->newQObject(group);
} }