forked from jonquark/grrok
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.cpp
71 lines (58 loc) · 2.1 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
#include <QApplication>
#include <QDir>
#include <QDeclarativeEngine>
#include <QDeclarativeComponent>
#include <QDeclarativeContext>
#include <QDeclarativeView>
#include <QDeclarativeItem>
#include <QDesktopWidget>
#include <QDebug>
#ifdef HAS_BOOSTER
#include <MDeclarativeCache>
#endif
#ifdef DESKTOP
#include <QGLWidget>
#endif
Q_DECL_EXPORT int main(int argc, char *argv[])
{
#ifdef HAS_BOOSTER
QScopedPointer<QApplication> app(MDeclarativeCache::qApplication(argc, argv));
QScopedPointer<QDeclarativeView> view(MDeclarativeCache::qDeclarativeView());
#else
QScopedPointer<QApplication> app(new QApplication(argc, argv));
QScopedPointer<QDeclarativeView> view(new QDeclarativeView);
#endif
#ifdef DESKTOP
bool isDesktop = true;
view->setViewport(new QGLWidget);
#else
bool isDesktop = app->arguments().contains("-desktop");
#endif
QString path("/opt/grrok/"); //default install
qDebug() << app->applicationDirPath() + QDir::separator() + "qml/grrok/main.qml";
if (isDesktop || QFile::exists(app->applicationDirPath() + QDir::separator() + "qml/grrok/main.qml")) {
path = app->applicationDirPath() + QDir::separator();
}
view->setSource(path + QLatin1String("qml/grrok/main.qml"));
if (view->status() == QDeclarativeView::Error) {
qWarning() << "Unable to read main qml file";
return 1;
}
if (isDesktop) {
view->setFixedSize(480, 854);
view->rootObject()->setProperty("_desktop", true);
view->setResizeMode(QDeclarativeView::SizeRootObjectToView);
if (app->arguments().contains("-openInSecondScreen")) {
QRect secondScreenRect = QApplication::desktop()->screenGeometry(1/*screenNumber*/);
view->move(secondScreenRect.topLeft() + QPoint(100, 100));
}
view->show();
} else {
view->setAttribute(Qt::WA_OpaquePaintEvent);
view->setAttribute(Qt::WA_NoSystemBackground);
view->viewport()->setAttribute(Qt::WA_OpaquePaintEvent);
view->viewport()->setAttribute(Qt::WA_NoSystemBackground);
view->showFullScreen();
}
return app->exec();
}