This repository has been archived by the owner on Dec 1, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
84 lines (65 loc) · 2.21 KB
/
main.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
80
81
82
83
84
#include <QApplication>
#include <QDebug>
#include <QTranslator>
#include "UserData.h"
#include "Settings.h"
#include "Utility.h"
#include "HttpRequest.h"
#ifdef Q_OS_IOS
#include "UIButton.h"
#endif
#if QT_VERSION < 0x050000
#include <QtDeclarative>
#include "qmlapplicationviewer.h"
#include "MyImage.h"
#else
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include <QQuickView>
#endif
int main(int argc, char *argv[])
{
//qDebug() << getenv("PATH");
QApplication app(argc, argv);
QString locale = QLocale::system().name();
QTranslator translator;
if(!translator.load(QString("onetoall_") + locale,":/i18n")){
qDebug()<<"translator load erro";
}
app.installTranslator(&translator);
UserData userData;
Settings settings;
Utility utility;
HttpRequest httpRequest;
NetworkAccessManagerFactory factory;
#if QT_VERSION < 0x050000
QmlApplicationViewer viewer;
viewer.engine()->setNetworkAccessManagerFactory(&factory);
viewer.rootContext()->setContextProperty("userdata",&userData);
viewer.rootContext()->setContextProperty("settings", &settings);
viewer.rootContext()->setContextProperty("utility",&utility);
viewer.rootContext()->setContextProperty("httprequest",&httpRequest);
qmlRegisterType<MyImage>("com.stars.widgets", 1, 0, "MyImage");
#ifdef Q_OS_SYMBIAN
viewer.setSource(QUrl("qrc:/qml/Symbian3/main.qml"));
#elif defined(Q_OS_HARMATTAN) | defined(Q_WS_SIMULATOR)
viewer.setSource(QUrl("qrc:/qml/Meego/main.qml"));
#endif
viewer.showExpanded();
#else
QQmlApplicationEngine engine;
engine.rootContext()->setContextProperty("userdata",&userData);
engine.rootContext()->setContextProperty("settings", &settings);
engine.rootContext()->setContextProperty("utility",&utility);
engine.rootContext()->setContextProperty("httprequest",&httpRequest);
#ifdef Q_OS_ANDROID
engine.load(QUrl(QStringLiteral("qrc:/qml/Android/main.qml")));
#elif defined(Q_OS_IOS)
qmlRegisterType<QUIButton>("com.qshen.ios", 0, 1, "UIButton");
engine.load(QUrl(QStringLiteral("qrc:/qml/IOS/main.qml")));
#elif defined(Q_OS_WIN32)
engine.load(QUrl(QStringLiteral("qrc:/qml/Win32/main.qml")));
#endif
#endif
return app.exec();
}