This repository has been archived by the owner on Apr 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 50
/
qaqmltypes.cpp
52 lines (38 loc) · 1.53 KB
/
qaqmltypes.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <QtQml>
#include "qaline.h"
#include "qaunits.h"
#include "qamousesensor.h"
#include "qatimer.h"
#include "priv/qasystemdispatcherproxy.h"
#include "qaimagewriter.h"
static QObject *systemDispatcherProvider(QQmlEngine *engine, QJSEngine *scriptEngine) {
Q_UNUSED(engine);
Q_UNUSED(scriptEngine);
QASystemDispatcherProxy* object = new QASystemDispatcherProxy();
return object;
}
static QJSValue timerProvider(QQmlEngine* engine , QJSEngine *scriptEngine) {
Q_UNUSED(engine);
QATimer* timer = new QATimer();
QJSValue value = scriptEngine->newQObject(timer);
return value;
}
template <typename T>
static QObject* provider(QQmlEngine *engine, QJSEngine *scriptEngine) {
Q_UNUSED(engine);
Q_UNUSED(scriptEngine);
T* object = new T();
return object;
}
static void regiserQmlTypes() {
// QADevice is a exception. Won't register by QAQmlTypes.
qmlRegisterSingletonType<QASystemDispatcherProxy>("QuickAndroid", 0, 1,
"SystemDispatcher", systemDispatcherProvider);
qmlRegisterSingletonType<QAUnits>("QuickAndroid", 0, 1,
"Units", provider<QAUnits>);
qmlRegisterType<QALine>("QuickAndroid.Private",0,1,"Line");
qmlRegisterType<QAMouseSensor>("QuickAndroid.Private",0,1,"MouseSensor");
qmlRegisterSingletonType("QuickAndroid.Private", 0, 1, "TimerUtils", timerProvider);
qmlRegisterType<QAImageWriter>("QuickAndroid.Private",0,1,"ImageWriter");
}
Q_COREAPP_STARTUP_FUNCTION(regiserQmlTypes)