support javascript animations
svn path=/trunk/KDE/kdebase/runtime/; revision=1120789
This commit is contained in:
parent
47406f1250
commit
e11acef040
@ -666,30 +666,33 @@ QScriptValue SimpleJavaScriptApplet::animation(QScriptContext *context, QScriptE
|
|||||||
QString animName = context->argument(0).toString().toLower();
|
QString animName = context->argument(0).toString().toLower();
|
||||||
const bool isPause = animName == "pause";
|
const bool isPause = animName == "pause";
|
||||||
const bool isProperty = animName == "property";
|
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;
|
bool parentIsApplet = false;
|
||||||
QGraphicsWidget *parent = extractParent(context, engine, 0, &parentIsApplet);
|
QGraphicsWidget *parent = extractParent(context, engine, 0, &parentIsApplet);
|
||||||
|
QAbstractAnimation *anim = 0;
|
||||||
|
Plasma::Animation *plasmaAnim = 0;
|
||||||
if (isPause) {
|
if (isPause) {
|
||||||
QPauseAnimation *pause = new QPauseAnimation(parent);
|
anim = new QPauseAnimation(parent);
|
||||||
return engine->newQObject(pause);
|
|
||||||
} else if (isProperty) {
|
} else if (isProperty) {
|
||||||
QPropertyAnimation *propertyAnim = new QPropertyAnimation(parent);
|
anim = new QPropertyAnimation(parent);
|
||||||
return engine->newQObject(propertyAnim);
|
} else if (s_animationDefs.contains(animName)) {
|
||||||
|
plasmaAnim = Plasma::Animator::create(s_animationDefs.value(animName), parent);
|
||||||
} else {
|
} else {
|
||||||
Plasma::Animation *anim = Plasma::Animator::create(s_animationDefs.value(animName), parent);
|
plasmaAnim = Plasma::Animator::create(animName, parent);
|
||||||
if (anim) {
|
|
||||||
if (!parentIsApplet) {
|
|
||||||
anim->setTargetWidget(parent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (plasmaAnim) {
|
||||||
|
if (!parentIsApplet) {
|
||||||
|
plasmaAnim->setTargetWidget(parent);
|
||||||
|
}
|
||||||
|
anim = plasmaAnim;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (anim) {
|
||||||
QScriptValue value = engine->newQObject(anim);
|
QScriptValue value = engine->newQObject(anim);
|
||||||
ScriptEnv::registerEnums(value, *anim->metaObject());
|
ScriptEnv::registerEnums(value, *anim->metaObject());
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return context->throwError(i18n("%1 is not a known animation type", animName));
|
return context->throwError(i18n("%1 is not a known animation type", animName));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user