// 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); QCoreApplication::setOrganizationName("WildDragon"); QCoreApplication::setApplicationName("DragonMoonlight"); // ── 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(); }