Added support for passing QEasingCurve::Type enumerator literal string as valid argument on type() js binding
svn path=/trunk/KDE/kdebase/runtime/; revision=1097616
This commit is contained in:
parent
6722dbdd97
commit
1bd327f133
@ -17,6 +17,7 @@
|
||||
*/
|
||||
|
||||
#include <QEasingCurve>
|
||||
#include <QMetaEnum>
|
||||
#include <QScriptValue>
|
||||
#include <QScriptEngine>
|
||||
#include <QScriptContext>
|
||||
@ -55,11 +56,18 @@ static QScriptValue type(QScriptContext *ctx, QScriptEngine *eng)
|
||||
|
||||
if (ctx->argumentCount()) {
|
||||
QScriptValue arg = ctx->argument(0);
|
||||
|
||||
qint32 type = -1;
|
||||
if (arg.isNumber()) {
|
||||
qint32 type = arg.toInt32();
|
||||
if (type > -1 && type < QEasingCurve::Custom) {
|
||||
self->setType(static_cast<QEasingCurve::Type>(type));
|
||||
}
|
||||
type = arg.toInt32();
|
||||
} else if (arg.isString()) {
|
||||
QMetaObject meta = QEasingCurve::staticMetaObject;
|
||||
QMetaEnum easingCurveEnum = meta.enumerator(meta.indexOfEnumerator("Type"));
|
||||
|
||||
type = easingCurveEnum.keyToValue(arg.toString().toAscii().data());
|
||||
}
|
||||
if (type > -1 && type < QEasingCurve::Custom) {
|
||||
self->setType(static_cast<QEasingCurve::Type>(type));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user