make it possible to prefix anims
svn path=/trunk/KDE/kdelibs/; revision=1126034
This commit is contained in:
parent
ae9656bb59
commit
eb8e81e27c
@ -49,6 +49,7 @@ namespace AnimationScriptEngine
|
|||||||
|
|
||||||
QScriptEngine* inst = 0;
|
QScriptEngine* inst = 0;
|
||||||
QHash<QString, QScriptValue> s_animFuncs;
|
QHash<QString, QScriptValue> s_animFuncs;
|
||||||
|
QString s_prefix;
|
||||||
|
|
||||||
QScriptValue animation(const QString &anim)
|
QScriptValue animation(const QString &anim)
|
||||||
{
|
{
|
||||||
@ -70,7 +71,7 @@ void clearAnimations()
|
|||||||
QScriptValue 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 = s_prefix + context->argument(0).toString();
|
||||||
|
|
||||||
if (!s_animFuncs.contains(name)) {
|
if (!s_animFuncs.contains(name)) {
|
||||||
const QScriptValue func = context->argument(1);
|
const QScriptValue func = context->argument(1);
|
||||||
@ -171,7 +172,7 @@ QScriptEngine *globalEngine()
|
|||||||
return inst;
|
return inst;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool loadScript(const QString &path)
|
bool loadScript(const QString &path, const QString &prefix)
|
||||||
{
|
{
|
||||||
QFile file(path);
|
QFile file(path);
|
||||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
@ -183,7 +184,9 @@ bool loadScript(const QString &path)
|
|||||||
QString tmp(buffer.readAll());
|
QString tmp(buffer.readAll());
|
||||||
|
|
||||||
QScriptEngine *engine = AnimationScriptEngine::globalEngine();
|
QScriptEngine *engine = AnimationScriptEngine::globalEngine();
|
||||||
|
s_prefix = prefix;
|
||||||
QScriptValue def(engine->evaluate(tmp, path));
|
QScriptValue def(engine->evaluate(tmp, path));
|
||||||
|
s_prefix.clear();
|
||||||
if (engine->hasUncaughtException()) {
|
if (engine->hasUncaughtException()) {
|
||||||
const QScriptValue error = engine->uncaughtException();
|
const QScriptValue error = engine->uncaughtException();
|
||||||
QString file = error.property("fileName").toString();
|
QString file = error.property("fileName").toString();
|
||||||
|
@ -38,7 +38,7 @@ void clearAnimations();
|
|||||||
bool isAnimationRegistered(const QString &anim);
|
bool isAnimationRegistered(const QString &anim);
|
||||||
QScriptEngine* globalEngine();
|
QScriptEngine* globalEngine();
|
||||||
QScriptValue animation(const QString &anim);
|
QScriptValue animation(const QString &anim);
|
||||||
bool loadScript(const QString &path);
|
bool loadScript(const QString &path, const QString &prefix = QString());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user