on xenial help sign in
Make Direction.isHorizontal and isVerticall callable from QML
commit856e0c3031767502a6d885460355a2118536bd4c authorDaniel d'Andrada <daniel.dandrada@canonical.com> dateMon 17 Jun 2013, 10:45 (13 years ago) parent41f64be
2 files changed+9−3
plugins/Ubuntu/Gestures/Direction.h+2−2 plugins/Ubuntu/Gestures/plugin.cpp+7−1
plugins/Ubuntu/Gestures/Direction.h+2−2
@@ -36,8 +36,8 @@ public:
3636 Upwards // Along the negative direction of the Y axis
3737 };
3838
39− static bool isHorizontal(Direction::Type type);
40− static bool isVertical(Direction::Type type);
39+ Q_INVOKABLE static bool isHorizontal(Direction::Type type);
40+ Q_INVOKABLE static bool isVertical(Direction::Type type);
4141};
4242
4343#endif // DIRECTION_H
plugins/Ubuntu/Gestures/plugin.cpp+7−1
@@ -21,9 +21,15 @@
2121
2222#include <qqml.h>
2323
24+static QObject* directionSingleton(QQmlEngine* engine, QJSEngine* scriptEngine) {
25+ Q_UNUSED(engine);
26+ Q_UNUSED(scriptEngine);
27+ return new Direction;
28+}
29+
2430void UbuntuGestureQmlPlugin::registerTypes(const char *uri)
2531{
26− qmlRegisterType<Direction>(uri, 0, 1, "Direction");
32+ qmlRegisterSingletonType<Direction>(uri, 0, 1, "Direction", directionSingleton);
2733 qmlRegisterType<DirectionalDragArea>(uri, 0, 1, "DirectionalDragArea");
2834 qmlRegisterType<AxisVelocityCalculator>(uri, 0, 1, "AxisVelocityCalculator");
2935}