#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include "PluginLoader.hpp"

int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);

    // 创建插件加载器
    auto pluginLoader = new PluginLoader(&app);

    QQmlApplicationEngine engine;

    // 将插件加载器暴露给 QML
    engine.rootContext()->setContextProperty("pluginLoader", pluginLoader);

    QObject::connect(
        &engine,
        &QQmlApplicationEngine::objectCreationFailed,
        &app,
        []() { QCoreApplication::exit(-1); },
        Qt::QueuedConnection);

    // 使用这种方式加载
    const QUrl url(QStringLiteral("qrc:/AuseftDDSPlugTest/Main.qml"));
    engine.load(url);

    return app.exec();
}
