From a0d81b281f2069af54e1e8ad538e78690895b486 Mon Sep 17 00:00:00 2001 From: ZGaetano Date: Wed, 6 May 2026 20:34:39 -0400 Subject: [PATCH] Upload main.cpp --- app/main.cpp | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 app/main.cpp diff --git a/app/main.cpp b/app/main.cpp new file mode 100644 index 0000000..b3732ba --- /dev/null +++ b/app/main.cpp @@ -0,0 +1,53 @@ +// app/main.cpp +// +// DragonMoonlight application entry point. +// +// Initializes Qt, creates the QML engine, registers the DragonRelayBackend +// context property, and loads the main QML view (typically from moonlight-qt's +// main.qml or a fork thereof). + +#include +#include +#include + +#include "vpn/dragonrelaybackend.h" + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + + // ── Create QML Engine ───────────────────────────────────────────────────── + QQmlApplicationEngine engine; + + // ── Wire DragonRelayBackend context property ────────────────────────────── + // + // Create a DragonRelayBackend instance on the stack. This object must exist + // for as long as the QML engine is running (i.e., through the app event loop). + // + // The QML context property allows QML code to access C++ methods and properties: + // + // // in QML: + // dragonRelay.connectRelay(url, user, pass) + // dragonRelay.streamHost(hostIP, "Desktop") + // var hosts = dragonRelay.hosts + // var status = dragonRelay.status + // + DragonRelayBackend relayBackend; + engine.rootContext()->setContextProperty(QStringLiteral("dragonRelay"), &relayBackend); + + // ── Load main QML view ──────────────────────────────────────────────────── + // + // This assumes the moonlight-qt fork provides a main.qml that includes + // or references DragonRelayView.qml. Adjust the path as needed for your + // build configuration (e.g., if QML files are in a subdirectory or + // compiled as QRC resources). + // + const QUrl url(QStringLiteral("qrc:/app/gui/main.qml")); + engine.load(url); + + // ── Error handling ──────────────────────────────────────────────────────── + if (engine.rootObjects().isEmpty()) + return -1; + + return app.exec(); +}