-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
47 lines (40 loc) · 1.63 KB
/
Copy pathmain.cpp
File metadata and controls
47 lines (40 loc) · 1.63 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
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQmlEngine>
#include "EarthView.h"
#include "OrbitFeed.h"
// Copyright (c) 2026 Andy Armitage
// This source is distributed under the Mozilla Public License 2.0; see LICENSE.txt.
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
qmlRegisterType<EarthView>("EarthView", 1, 0, "EarthView");
QQmlApplicationEngine engine;
engine.addImportPath(QStringLiteral("qrc:/"));
QObject::connect(
&engine,
&QQmlApplicationEngine::objectCreationFailed,
&app,
[]() { QCoreApplication::exit(-1); },
Qt::QueuedConnection);
engine.loadFromModule("EarthViewDemo", "Main");
// Wire NATS orbit feed to EarthView in the sample app (EarthView itself stays NATS-agnostic).
if (!engine.rootObjects().isEmpty()) {
QObject *root = engine.rootObjects().first();
if (auto *earth = root->findChild<EarthView *>(QStringLiteral("earthView"))) {
auto *feed = new OrbitFeed(&app);
QObject::connect(feed, &OrbitFeed::satellitesUpdated, earth, [earth](const QVariantList &sats) {
earth->setSatellites(sats);
});
QObject::connect(feed, &OrbitFeed::groundStationsUpdated, earth, [earth](const QVariantList &stations) {
earth->setGroundStations(stations);
});
QObject::connect(feed, &OrbitFeed::statusMessage, [](const QString &msg) {
qInfo().noquote() << msg;
});
feed->setSubject(QStringLiteral("m.orbit.*"));
feed->start();
}
}
return app.exec();
}