-
Notifications
You must be signed in to change notification settings - Fork 56
/
main.cpp
97 lines (78 loc) · 3.55 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
85
86
87
88
89
90
91
92
93
94
95
96
97
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QtQml/qqml.h>
#include <QFontDatabase>
#include <QFileInfo>
#include <QDir>
#include <QQuickStyle>
#include <QQmlContext>
#include <QSysInfo>
#include <QtWebView>
#include <QTranslator>
#include <QLibraryInfo>
#include <qqml.h>
#ifdef Q_OS_ANDROID
#include <QtAndroidExtras/QtAndroid>
#endif
#include "wifisetup/bluetoothdiscovery.h"
#include "wifisetup/btwifisetup.h"
#include "wifisetup/wirelessaccesspoint.h"
#include "wifisetup/wirelessaccesspoints.h"
#include "wifisetup/wirelessaccesspointsproxy.h"
#include "clipboardhelper.h"
#include "permissionhelper.h"
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
app.setApplicationName("berrylan");
app.setOrganizationName("nymea");
QCommandLineParser parser;
QCommandLineOption demoOption("demo");
parser.addOption(demoOption);
parser.process(app);
QtWebView::initialize();
// QQuickStyle::setStyle(":/styles");
QQuickStyle::setStyle("Material");
foreach (const QFileInfo &di, QDir(":/fonts/").entryInfoList(QDir::Dirs)) {
qDebug() << "Adding font path:" << di.absoluteFilePath();
foreach (const QFileInfo &fi, QDir(di.absoluteFilePath()).entryInfoList()) {
qDebug() << "Adding font:" << fi.absoluteFilePath();
QFontDatabase::addApplicationFont(fi.absoluteFilePath());
}
}
QFont applicationFont;
applicationFont.setFamily("Montserrat");
applicationFont.setCapitalization(QFont::MixedCase);
applicationFont.setPixelSize(20);
applicationFont.setWeight(QFont::Light);
QGuiApplication::setFont(applicationFont);
QTranslator qtTranslator;
qtTranslator.load("qt_" + QLocale::system().name(),
QLibraryInfo::location(QLibraryInfo::TranslationsPath));
app.installTranslator(&qtTranslator);
QTranslator appTranslator;
qDebug() << "Loading translation file:" << ":/translations/berrylan-" + QLocale::system().name();
appTranslator.load(":/translations/berrylan-" + QLocale::system().name());
app.installTranslator(&appTranslator);
qmlRegisterType<BtWiFiSetup>("BerryLan", 1, 0, "BtWiFiSetup");
qmlRegisterType<BluetoothDiscovery>("BerryLan", 1, 0, "BluetoothDiscovery");
qmlRegisterUncreatableType<BluetoothDeviceInfos>("BerryLan", 1, 0, "BluetoothDeviceInfos", "Get it from BluetoothDiscovery");
qmlRegisterType<BluetoothDeviceInfosProxy>("BerryLan", 1, 0, "BluetoothDeviceInfosProxy");
qmlRegisterUncreatableType<BluetoothDeviceInfo>("BerryLan", 1, 0, "BluetoothDeviceInfo", "Get it from BluetoothDeviceInfos");
qmlRegisterUncreatableType<WirelessAccessPoints>("BerryLan", 1, 0, "WirelessAccessPoints", "Get it from NetworkManagerController");
qmlRegisterUncreatableType<WirelessAccessPoint>("BerryLan", 1, 0, "WirelessAccessPoint", "Get it from WirelessAccessPoints");
qmlRegisterType<WirelessAccessPointsProxy>("BerryLan", 1, 0, "WirelessAccessPointsProxy");
qmlRegisterSingletonType<PermissionHelper>("BerryLan", 1, 0, "PermissionHelper", PermissionHelper::permissionsHelperProvider);
QQmlApplicationEngine engine;
ClipboardHelper clipBoard;
engine.rootContext()->setContextProperty("systemProductType", QSysInfo::productType());
engine.rootContext()->setContextProperty("clipBoard", &clipBoard);
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
if (engine.rootObjects().isEmpty())
return -1;
#ifdef Q_OS_ANDROID
QtAndroid::hideSplashScreen(250);
#endif
return app.exec();
}