proper file names, AnimationEngine -> AnimationScriptEngine, and it becomes a namespace
svn path=/trunk/KDE/kdelibs/; revision=1119242
This commit is contained in:
parent
d38dc61819
commit
a5c793691b
@ -24,15 +24,21 @@
|
|||||||
|
|
||||||
#include "engine.h"
|
#include "engine.h"
|
||||||
|
|
||||||
QScriptEngine* AnimationEngine::inst = 0;
|
namespace Plasma
|
||||||
QHash<QString, QScriptValue> AnimationEngine::s_animFuncs;
|
{
|
||||||
|
|
||||||
QScriptValue AnimationEngine::animation(const QString &anim)
|
namespace AnimationScriptEngine
|
||||||
|
{
|
||||||
|
|
||||||
|
QScriptEngine* inst = 0;
|
||||||
|
QHash<QString, QScriptValue> s_animFuncs;
|
||||||
|
|
||||||
|
QScriptValue animation(const QString &anim)
|
||||||
{
|
{
|
||||||
return s_animFuncs.value(anim);
|
return s_animFuncs.value(anim);
|
||||||
}
|
}
|
||||||
|
|
||||||
QScriptValue AnimationEngine::registerAnimation(QScriptContext *context, QScriptEngine *engine)
|
QScriptValue registerAnimation(QScriptContext *context, QScriptEngine *engine)
|
||||||
{
|
{
|
||||||
if (context->argumentCount() > 1) {
|
if (context->argumentCount() > 1) {
|
||||||
const QString name = context->argument(0).toString();
|
const QString name = context->argument(0).toString();
|
||||||
@ -45,15 +51,18 @@ QScriptValue AnimationEngine::registerAnimation(QScriptContext *context, QScript
|
|||||||
return engine->undefinedValue();
|
return engine->undefinedValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
QScriptEngine *AnimationEngine::globalEngine()
|
QScriptEngine *globalEngine()
|
||||||
{
|
{
|
||||||
if (!inst) {
|
if (!inst) {
|
||||||
inst = new QScriptEngine;
|
inst = new QScriptEngine;
|
||||||
QScriptValue global = inst->globalObject();
|
QScriptValue global = inst->globalObject();
|
||||||
global.setProperty("registerAnimation", inst->newFunction(AnimationEngine::registerAnimation));
|
global.setProperty("registerAnimation", inst->newFunction(AnimationScriptEngine::registerAnimation));
|
||||||
qDebug() << "........... first js animation, creating the engine!";
|
qDebug() << "........... first js animation, creating the engine!";
|
||||||
}
|
}
|
||||||
|
|
||||||
return inst;
|
return inst;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace AnimationEngine
|
||||||
|
} // namespace Plasma
|
||||||
|
|
@ -27,19 +27,17 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
/* Plasma-shell will have an engine */
|
/* Plasma-shell will have an engine */
|
||||||
class AnimationEngine
|
namespace Plasma
|
||||||
{
|
{
|
||||||
public:
|
|
||||||
static QScriptEngine* globalEngine();
|
|
||||||
static QScriptValue animation(const QString &anim);
|
|
||||||
|
|
||||||
protected:
|
namespace AnimationScriptEngine
|
||||||
AnimationEngine() { }
|
{
|
||||||
|
|
||||||
private:
|
static QScriptEngine* globalEngine();
|
||||||
static QScriptEngine *inst;
|
static QScriptValue animation(const QString &anim);
|
||||||
static QScriptValue registerAnimation(QScriptContext *context, QScriptEngine *engine);
|
|
||||||
static QHash<QString, QScriptValue> s_animFuncs;
|
}
|
||||||
};
|
|
||||||
|
} // namespace Plasma
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -17,10 +17,10 @@
|
|||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "jsanim_p.h"
|
#include "javascriptanimation_p.h"
|
||||||
#include "engine.h"
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
#include "animationscriptengine.h"
|
||||||
/* TODO:
|
/* TODO:
|
||||||
* - support passing more parameters to the js animation object
|
* - support passing more parameters to the js animation object
|
||||||
* - support more properties: angle, direction, etc
|
* - support more properties: angle, direction, etc
|
||||||
@ -47,7 +47,7 @@ void JavascriptAnimation::updateState(QAbstractAnimation::State newState, QAbstr
|
|||||||
qDebug() << ".................. state: " << newState;
|
qDebug() << ".................. state: " << newState;
|
||||||
if (oldState == Stopped && newState == Running) {
|
if (oldState == Stopped && newState == Running) {
|
||||||
if (!engine) {
|
if (!engine) {
|
||||||
engine = AnimationEngine::globalEngine();
|
engine = AnimationScriptEngine::globalEngine();
|
||||||
|
|
||||||
//Define the class and create an instance
|
//Define the class and create an instance
|
||||||
if (!m_instance) {
|
if (!m_instance) {
|
Loading…
x
Reference in New Issue
Block a user