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 37
/
quickios.cpp
79 lines (63 loc) · 2.2 KB
/
quickios.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include <QtQml>
#include <QtGui>
#include <QVariantMap>
#include <QPointer>
#include "quickios.h"
#include "qialertview.h"
#include "qisystemdispatcher.h"
#include "qidevice.h"
#include "qiactionsheet.h"
#include "qiimagepicker.h"
#include "qiactivityindicator.h"
static QJSValue systemProvider(QQmlEngine* engine , QJSEngine *scriptEngine) {
Q_UNUSED(engine);
QISystemDispatcher *system = QISystemDispatcher::instance();
QJSValue value = scriptEngine->newQObject(system);
return value;
}
static QJSValue deviceProvider(QQmlEngine* engine , QJSEngine *scriptEngine) {
Q_UNUSED(engine);
QIDevice* device = QIDevice::instance();
QScreen *src = QGuiApplication::screens().at(0); // @TODO: Dynamic update
device->setScreenWidth(src->availableGeometry().width());
device->setScreenHeight(src->availableGeometry().height());
QJSValue value = scriptEngine->newQObject(device);
return value;
}
void QuickIOS::registerTypes()
{
}
void QuickIOS::setupWindow(QQuickWindow *window)
{
#ifdef Q_OS_IOS
QIDevice* device = QIDevice::instance();
device->setScreenFillStatusBar(true);
window->showFullScreen();
#else
Q_UNUSED(window);
#endif
}
void QuickIOS::setStatusBarStyle(QuickIOS::StatusBarStyle style)
{
QISystemDispatcher *system = QISystemDispatcher::instance();
QVariantMap data;
data["style"] = style;
system->dispatch("applicationSetStatusBarStyle",data);
}
void QuickIOS::setStatusBarHidden(bool hidden, int animation)
{
QISystemDispatcher* dispatcher = QISystemDispatcher::instance();
QVariantMap message;
message["hidden"] = hidden;
message["animation"] = animation;
dispatcher->dispatch("applicationSetStatusBarHidden", message);
}
static void registerTypes() {
qmlRegisterSingletonType("QuickIOS", 0, 1, "SystemMessenger", systemProvider);
qmlRegisterSingletonType("QuickIOS", 0, 1, "QIDevice", deviceProvider);
qmlRegisterType<QIAlertView>("QuickIOS",0,1,"AlertView");
qmlRegisterType<QIActionSheet>("QuickIOS",0,1,"ActionSheet");
qmlRegisterType<QIImagePicker>("QuickIOS",0,1,"ImagePicker");
qmlRegisterType<QIActivityIndicator>("QuickIOS",0,1,"ActivityIndicator");
}
Q_COREAPP_STARTUP_FUNCTION(registerTypes)