-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathmain.cpp
More file actions
54 lines (49 loc) · 1.43 KB
/
Copy pathmain.cpp
File metadata and controls
54 lines (49 loc) · 1.43 KB
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
#include <QQmlContext>
#include "stockModel.h"
#include "stock.h"
#include <QTranslator>
#if defined(Q_OS_ANDROID)
#include <QtGui/QGuiApplication>
#include "notifyAndroid.h"
#elif defined(Q_OS_IOS)
#else
#include <QApplication>
#include "trayIcon.h"
#endif
#include <QDebug>
#include "qDebug2Logcat.h"
#include <QQuickView>
int main(int argc, char *argv[])
{
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
QGuiApplication app(argc, argv);
#else
QApplication app(argc, argv);
#endif
installLogcatMessageHandler("stockMonitor");
QTranslator t;
t.load(":/stockMonitor_zh.qm");
app.installTranslator(&t);
StockModel *model = new StockModel;
QQuickView viewer;
viewer.setResizeMode(QQuickView::SizeRootObjectToView);
QQmlContext *ctx = viewer.rootContext();
ctx->setContextProperty("stockModel", model);
ctx->setContextProperty("currentStock", model->currentStock());
viewer.setSource(QUrl("qrc:/qml/main.qml"));
#if defined(Q_OS_ANDROID)
NotifyAndroid *notify = new NotifyAndroid;
model->connectToReminder(notify, SLOT(onRemind(QString)));
#elif defined(Q_OS_IOS)
#else
TrayIcon *tray = new TrayIcon();
tray->setWindow(&viewer);
model->connectToReminder(tray, SLOT(onRemind(QString)));
viewer.setIcon(tray->icon());
viewer.setTitle(QObject::tr("stock monitor"));
viewer.setMinimumHeight(480);
viewer.setMinimumWidth(800);
#endif
viewer.show();
return app.exec();
}