allow clearing the animations, checking for whether an animation is registered and make it first-come, first-serve to avoid anims overriding each other
svn path=/trunk/KDE/kdelibs/; revision=1120236
This commit is contained in:
parent
b9d926ac63
commit
03bc2d587e
@ -38,15 +38,30 @@ QScriptValue animation(const QString &anim)
|
|||||||
return s_animFuncs.value(anim);
|
return s_animFuncs.value(anim);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isAnimationRegistered(const QString &anim)
|
||||||
|
{
|
||||||
|
return s_animFuncs.contains(anim);
|
||||||
|
}
|
||||||
|
|
||||||
|
void clearAnimations()
|
||||||
|
{
|
||||||
|
s_animFuncs.clear();
|
||||||
|
delete inst;
|
||||||
|
inst = 0;
|
||||||
|
}
|
||||||
|
|
||||||
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 = context->argument(0).toString();
|
||||||
|
|
||||||
|
if (!s_animFuncs.contains(name)) {
|
||||||
const QScriptValue func = context->argument(1);
|
const QScriptValue func = context->argument(1);
|
||||||
if (func.isFunction()) {
|
if (func.isFunction()) {
|
||||||
s_animFuncs.insert(name, func);
|
s_animFuncs.insert(name, func);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return engine->undefinedValue();
|
return engine->undefinedValue();
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,8 @@ namespace Plasma
|
|||||||
namespace AnimationScriptEngine
|
namespace AnimationScriptEngine
|
||||||
{
|
{
|
||||||
|
|
||||||
|
void clearAnimations();
|
||||||
|
bool isAnimationRegistered(const QString &anim);
|
||||||
QScriptEngine* globalEngine();
|
QScriptEngine* globalEngine();
|
||||||
QScriptValue animation(const QString &anim);
|
QScriptValue animation(const QString &anim);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user