-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
49 lines (40 loc) · 1.64 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
#include <QGuiApplication>
#include <QApplication>
#include <QQmlApplicationEngine>
#include <QtQml>
#include "heightreader.h"
#include <iostream>
#include <QPermission>
#include <QPixmap>
#include <QSplashScreen>
int main(int argc, char *argv[])
{
qmlRegisterType<HeightReader>("HeightReader", 1, 0, "HeightReader");
QApplication app(argc, argv);
app.setOrganizationName("FyrLysARCompany");
app.setOrganizationDomain("fyrlysarcompany.com");
app.setApplicationName("FyrLysAR");
QQmlApplicationEngine engine;
const QUrl url(u"qrc:/FyrLysAR/main.qml"_qs);
QPixmap pixmap(":/images/splash.png");
QSplashScreen splash(pixmap);
splash.show();
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
&app, [url](QObject *obj, const QUrl &objUrl) {
if (!obj && url == objUrl)
QCoreApplication::exit(-1);
}, Qt::QueuedConnection);
QCameraPermission cameraPermission;
QLocationPermission locationPermission;
qApp->requestPermission(cameraPermission, [&engine, &url, &splash, &locationPermission](const QPermission &grantedCameraPermission) {
if (grantedCameraPermission.status() != Qt::PermissionStatus::Granted)
qWarning("Camera permission is not granted!");
qApp->requestPermission(locationPermission, [&engine, &url, &splash](const QPermission &grantedLocationPermission) {
if (grantedLocationPermission.status() != Qt::PermissionStatus::Granted)
qWarning("Location permission is not granted!");
engine.load(url);
splash.hide();
});
});
return app.exec();
}