From e11acef04077ce812b2398619039452d008e29b4 Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Thu, 29 Apr 2010 23:58:01 +0000 Subject: [PATCH] support javascript animations svn path=/trunk/KDE/kdebase/runtime/; revision=1120789 --- .../javascript/simplejavascriptapplet.cpp | 33 ++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/scriptengines/javascript/simplejavascriptapplet.cpp b/scriptengines/javascript/simplejavascriptapplet.cpp index cc0eeeebb..39cf45f99 100644 --- a/scriptengines/javascript/simplejavascriptapplet.cpp +++ b/scriptengines/javascript/simplejavascriptapplet.cpp @@ -666,29 +666,32 @@ QScriptValue SimpleJavaScriptApplet::animation(QScriptContext *context, QScriptE QString animName = context->argument(0).toString().toLower(); const bool isPause = animName == "pause"; const bool isProperty = animName == "property"; - if (!isPause && !isProperty && !s_animationDefs.contains(animName)) { - return context->throwError(i18n("%1 is not a known animation type", animName)); - } bool parentIsApplet = false; QGraphicsWidget *parent = extractParent(context, engine, 0, &parentIsApplet); + QAbstractAnimation *anim = 0; + Plasma::Animation *plasmaAnim = 0; if (isPause) { - QPauseAnimation *pause = new QPauseAnimation(parent); - return engine->newQObject(pause); + anim = new QPauseAnimation(parent); } else if (isProperty) { - QPropertyAnimation *propertyAnim = new QPropertyAnimation(parent); - return engine->newQObject(propertyAnim); + anim = new QPropertyAnimation(parent); + } else if (s_animationDefs.contains(animName)) { + plasmaAnim = Plasma::Animator::create(s_animationDefs.value(animName), parent); } else { - Plasma::Animation *anim = Plasma::Animator::create(s_animationDefs.value(animName), parent); - if (anim) { - if (!parentIsApplet) { - anim->setTargetWidget(parent); - } + plasmaAnim = Plasma::Animator::create(animName, parent); + } - QScriptValue value = engine->newQObject(anim); - ScriptEnv::registerEnums(value, *anim->metaObject()); - return value; + if (plasmaAnim) { + if (!parentIsApplet) { + plasmaAnim->setTargetWidget(parent); } + anim = plasmaAnim; + } + + if (anim) { + QScriptValue value = engine->newQObject(anim); + ScriptEnv::registerEnums(value, *anim->metaObject()); + return value; } return context->throwError(i18n("%1 is not a known animation type", animName));