summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2009-11-04 04:16:12 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2009-11-04 04:16:12 (GMT)
commit47889bd63d8a14b10984576998a69d8a4cd0a8d0 (patch)
treea20f8e7b3b0b19de5c68f1d1103a77caf2d17936 /src/declarative
parent2c6d4485b7a0c8c819a225e56ca9a43ab4fcccf4 (diff)
parent684fe7af0b6d8133973132fd5b6b01cc16957a10 (diff)
downloadQt-47889bd63d8a14b10984576998a69d8a4cd0a8d0.zip
Qt-47889bd63d8a14b10984576998a69d8a4cd0a8d0.tar.gz
Qt-47889bd63d8a14b10984576998a69d8a4cd0a8d0.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/qml/qmlengine.cpp20
-rw-r--r--src/declarative/qml/qmlengine_p.h1
2 files changed, 21 insertions, 0 deletions
diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp
index c562e02..2926791 100644
--- a/src/declarative/qml/qmlengine.cpp
+++ b/src/declarative/qml/qmlengine.cpp
@@ -147,6 +147,7 @@ QmlEnginePrivate::QmlEnginePrivate(QmlEngine *e)
qtObject.setProperty(QLatin1String("tint"), scriptEngine.newFunction(QmlEnginePrivate::tint, 2));
//misc methods
+ qtObject.setProperty(QLatin1String("closestAngle"), scriptEngine.newFunction(QmlEnginePrivate::closestAngle, 2));
qtObject.setProperty(QLatin1String("playSound"), scriptEngine.newFunction(QmlEnginePrivate::playSound, 1));
qtObject.setProperty(QLatin1String("openUrlExternally"),scriptEngine.newFunction(desktopOpenUrl, 1));
@@ -810,6 +811,25 @@ QScriptValue QmlEnginePrivate::desktopOpenUrl(QScriptContext *ctxt, QScriptEngin
return e->newVariant(QVariant(ret));
}
+QScriptValue QmlEnginePrivate::closestAngle(QScriptContext *ctxt, QScriptEngine *e)
+{
+ if(ctxt->argumentCount() < 2)
+ return e->newVariant(QVariant(0.0));
+ qreal a = ctxt->argument(0).toNumber();
+ qreal b = ctxt->argument(1).toNumber();
+ qreal ret = b;
+ qreal diff = b-a;
+ while(diff > 180.0){
+ ret -= 360.0;
+ diff -= 360.0;
+ }
+ while(diff < -180.0){
+ ret += 360.0;
+ diff += 360.0;
+ }
+ return e->newVariant(QVariant(ret));
+}
+
QScriptValue QmlEnginePrivate::tint(QScriptContext *ctxt, QScriptEngine *engine)
{
if(ctxt->argumentCount() != 2)
diff --git a/src/declarative/qml/qmlengine_p.h b/src/declarative/qml/qmlengine_p.h
index b050ef6..3c60b5c 100644
--- a/src/declarative/qml/qmlengine_p.h
+++ b/src/declarative/qml/qmlengine_p.h
@@ -269,6 +269,7 @@ public:
static QScriptValue darker(QScriptContext*, QScriptEngine*);
static QScriptValue tint(QScriptContext*, QScriptEngine*);
+ static QScriptValue closestAngle(QScriptContext*, QScriptEngine*);
static QScriptValue playSound(QScriptContext*, QScriptEngine*);
static QScriptValue desktopOpenUrl(QScriptContext*, QScriptEngine*);