20 #include "javascriptanimation_p.h"
24 #include "animationscriptengine_p.h"
30 #define ADD_ENUM_VALUE(__c__, __ns__, __v__) \
31 __c__.setProperty(#__v__, QScriptValue(__c__.engine(), __ns__::__v__))
36 JavascriptAnimation::JavascriptAnimation(
const QString &name,
QObject *parent)
37 : EasingAnimation(parent),
38 #ifdef PLASMA_JSANIM_FPS
46 JavascriptAnimation::~JavascriptAnimation()
50 void JavascriptAnimation::prepInstance()
53 m_instance.setProperty(
"__plasma_javascriptanimation", engine->newQObject(
this),
54 QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration);
69 ADD_ENUM_VALUE(m_instance, JavascriptAnimation, PropertyAnimation);
72 void JavascriptAnimation::updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState)
75 if (oldState == Stopped && newState == Running) {
76 if (!m_method.isFunction()) {
79 kDebug() <<
"trying for" << m_name << m_instance.isFunction();
82 m_method = m_instance.property(QString(
"updateCurrentTime"));
83 if (!m_method.isFunction()) {
84 qDebug() <<
"**************** ERROR! Name: " << m_name <<
" ************";
85 m_instance = m_method = QScriptValue();
91 qreal x = targetWidget()->geometry().height()/2;
92 qreal y = targetWidget()->geometry().width()/2;
93 targetWidget()->setTransformOriginPoint(x, y);
97 if (m_method.isFunction()) {
98 m_instance.setProperty(
"duration", duration(), QScriptValue::ReadOnly);
99 m_instance.setProperty(
"target", m_instance.engine()->newQObject(targetWidget()), QScriptValue::ReadOnly);
101 #ifdef PLASMA_JSANIM_FPS
103 }
else if (oldState == Running && newState == Stopped) {
104 kDebug() <<
".........." << m_name <<
" fps: " << m_fps * 1000/duration();
109 void JavascriptAnimation::updateEffectiveTime(
int currentTime)
111 if (m_method.isFunction()) {
112 #ifdef PLASMA_JSANIM_FPS
115 QScriptValueList args;
118 m_method.call(m_instance, args);
124 #include "javascriptanimation_p.moc"
A system for applying effects to Plasma elements.
QScriptEngine * globalEngine()
QScriptValue animation(const QString &anim)
#define ADD_ENUM_VALUE(__c__, __ns__, __v__)