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 <QEasingCurve>
|
||||||
|
#include <QMetaEnum>
|
||||||
#include <QScriptValue>
|
#include <QScriptValue>
|
||||||
#include <QScriptEngine>
|
#include <QScriptEngine>
|
||||||
#include <QScriptContext>
|
#include <QScriptContext>
|
||||||
@ -55,11 +56,18 @@ static QScriptValue type(QScriptContext *ctx, QScriptEngine *eng)
|
|||||||
|
|
||||||
if (ctx->argumentCount()) {
|
if (ctx->argumentCount()) {
|
||||||
QScriptValue arg = ctx->argument(0);
|
QScriptValue arg = ctx->argument(0);
|
||||||
|
|
||||||
|
qint32 type = -1;
|
||||||
if (arg.isNumber()) {
|
if (arg.isNumber()) {
|
||||||
qint32 type = arg.toInt32();
|
type = arg.toInt32();
|
||||||
if (type > -1 && type < QEasingCurve::Custom) {
|
} else if (arg.isString()) {
|
||||||
self->setType(static_cast<QEasingCurve::Type>(type));
|
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