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