-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cpp
78 lines (63 loc) · 2.42 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
/*************************************************************************
**
** (C) Copyright 2013 Reach Technology Inc.
**
** This code is protected by international copyright laws. This file may
** only be used in accordance with a license and cannot be used on
** hardware other than supplied by Reach Technology Inc. We appreciate
** your understanding and fairness.
**
*************************************************************************/
#include <QApplication>
#include <QSettings>
#include <QFileInfo>
#include <QDeclarativeEngine>
#include "mainview.h"
#include "systemdefs.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QApplication::setOrganizationName("Reach Technology");
QApplication::setOrganizationDomain("reachtech.com");
QApplication::setApplicationName("Qml Viewer");
QApplication::setApplicationVersion(APP_VERSION);
QFileInfo settingsFile;
QStringList args = app.arguments();
foreach (QString item, args) {
if(item == "--version" || item == "-v") {
qDebug() << "QML Viewer " << APP_VERSION;
return 0;
}
}
QString sb(QApplication::applicationDirPath());
sb.append(QDir::separator());
sb.append("settings.conf");
// check to see if we have a settings file where we started from
// if not fall back to system hard coded path
QFileInfo file(sb.toLatin1());
if (file.exists()) {
qDebug() << "[QML] using local settings file";
settingsFile.setFile(file.filePath());
} else {
qDebug() << "[QML] using system defined settings file";
settingsFile.setFile(SYSTEM_SETTINGS_FILE);
}
QSettings settings(settingsFile.filePath(),QSettings::NativeFormat);
settings.beginGroup(SYSTEM_SETTINGS_SECTION);
MainView w;
w.setSource(QUrl::fromLocalFile(settings.value("main_view").toString()));
w.enableLookupAck(settings.value("enable_ack",false).toBool());
w.setResizeMode(QDeclarativeView::SizeRootObjectToView);
if (settings.value("full_screen",false).toBool()) {
w.showFullScreen();
}
if (settings.value("hide_curosr",false).toBool()) {
w.setCursor(QCursor( Qt::BlankCursor ));
}
QString offlinePath = settings.value("offline_storage_path").toString();
if (offlinePath.length() > 0)
w.engine()->setOfflineStoragePath(offlinePath);
settings.endGroup();
w.show();
return app.exec();
}