Repository navigation
Expand file tree
/
Copy pathmain.cpp
More file actions
61 lines (53 loc) · 2.24 KB
/
Copy pathmain.cpp
File metadata and controls
61 lines (53 loc) · 2.24 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
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include <QtQml>
#include <QUrl>
#include "appbackend.h"
#include "climatecontroller.h"
#include "mediacontroller.h"
#include "quicksettingscontroller.h"
#include "vehiclecontroller.h"
int main(int argc, char *argv[])
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
AppBackend appBackend;
QuickSettingsController quickSettings;
MediaController mediaController;
VehicleController vehicleController;
ClimateController climateController;
// Resolve App.* QML modules (Components, Screens, Controllers) shipped in
// the resource tree, so QML can `import App.Components` instead of "../".
engine.addImportPath(QStringLiteral("qrc:/qml"));
// Register the design-system singletons. The .qml files declare `pragma
// Singleton`; these calls supply the module URI/name (so no qmldir entry is
// needed) — a single source of truth reachable from any QML file via
// `import App.Theme` / `import App.Icons`.
qmlRegisterSingletonType(
QUrl(QStringLiteral("qrc:/qml/App/Theme/Theme.qml")),
"App.Theme", 1, 0, "Theme");
qmlRegisterSingletonType(
QUrl(QStringLiteral("qrc:/qml/App/Icons/Icons.qml")),
"App.Icons", 1, 0, "Icons");
engine.rootContext()->setContextProperty(QStringLiteral("appBackend"), &appBackend);
engine.rootContext()->setContextProperty(QStringLiteral("quickControls"), &quickSettings);
engine.rootContext()->setContextProperty(QStringLiteral("mediaControls"), &mediaController);
engine.rootContext()->setContextProperty(QStringLiteral("vehicleControls"), &vehicleController);
engine.rootContext()->setContextProperty(QStringLiteral("climateControls"), &climateController);
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();
}