on xenial help sign in
Make Direction.isHorizontal and isVerticall callable from QML
856e0c3Daniel d'Andrada
plugins/Ubuntu/Gestures/Direction.h+2−2
@@ -36,8 +36,8 @@ public:
36 Upwards // Along the negative direction of the Y axis
36 Upwards // Along the negative direction of the Y axis
37 };
37 };
38
38
39− static bool isHorizontal(Direction::Type type);
39+ Q_INVOKABLE static bool isHorizontal(Direction::Type type);
40− static bool isVertical(Direction::Type type);
40+ Q_INVOKABLE static bool isVertical(Direction::Type type);
41};
41};
42
42
43#endif // DIRECTION_H
43#endif // DIRECTION_H
plugins/Ubuntu/Gestures/plugin.cpp+7−1
@@ -21,9 +21,15 @@
21
21
22#include <qqml.h>
22#include <qqml.h>
23
23
24+static QObject* directionSingleton(QQmlEngine* engine, QJSEngine* scriptEngine) {
25+ Q_UNUSED(engine);
26+ Q_UNUSED(scriptEngine);
27+ return new Direction;
28+}
29+
24void UbuntuGestureQmlPlugin::registerTypes(const char *uri)
30void UbuntuGestureQmlPlugin::registerTypes(const char *uri)
25{
31{
26− qmlRegisterType<Direction>(uri, 0, 1, "Direction");
32+ qmlRegisterSingletonType<Direction>(uri, 0, 1, "Direction", directionSingleton);
27 qmlRegisterType<DirectionalDragArea>(uri, 0, 1, "DirectionalDragArea");
33 qmlRegisterType<DirectionalDragArea>(uri, 0, 1, "DirectionalDragArea");
28 qmlRegisterType<AxisVelocityCalculator>(uri, 0, 1, "AxisVelocityCalculator");
34 qmlRegisterType<AxisVelocityCalculator>(uri, 0, 1, "AxisVelocityCalculator");
29}
35}