-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
executable file
·91 lines (52 loc) · 2 KB
/
main.cpp
File metadata and controls
executable file
·91 lines (52 loc) · 2 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
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
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include <QIcon>
#include "hostsecurecollection.h"
#include "devicemodel.h"
namespace
{
void registerTypes();
}
int main( int argc, char *argv[] )
{
qputenv("QML_DISABLE_DISK_CACHE", "1");
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif
QCoreApplication::setApplicationName( "HostSecure" );
QCoreApplication::setApplicationVersion( "1.0" );
QCoreApplication::setOrganizationName( "HostSecure" );
QCoreApplication::setOrganizationDomain( "usn.no" );
QGuiApplication app(argc, argv);
QIcon::setThemeName( "HostSecureIcons" );
QQmlApplicationEngine engine;
auto hsc = new HostSecureCollection( &engine );
engine.rootContext()->setContextProperty( "HSC", hsc );
registerTypes();
engine.addImportPath( ":/" );
const QUrl url( QStringLiteral("qrc:/main.qml") );
QObject::connect( &engine, &QQmlApplicationEngine::objectCreated,
&app, [url]( QObject *obj, const QUrl &objUrl ) {
if ( !obj && url == objUrl )
QCoreApplication::exit( -1 );
}, Qt::QueuedConnection );
engine.load( url );
return app.exec();
}
namespace
{
//!
//! \brief registerTypes Register QtObject in Qt metadata to be able to access
//! the exposed properties and functions in QML.
//!
void registerTypes()
{
constexpr auto msg = "Cannot create from QML..";
constexpr auto uri = "HostSecure";
qmlRegisterUncreatableType< HostSecureCollection >( "HostSecure", 1, 0, "HostSecureCollection", msg );
qmlRegisterUncreatableType< MmiMqttClient >( uri, 1, 0, "MmiMqttClient", msg );
qmlRegisterUncreatableType< EdgeModel >( uri, 1, 0, "EdgeModel", msg );
qmlRegisterUncreatableType< DeviceModel >( uri, 1, 0, "DeviceModel", msg );
}
}