/*
 * SPDX-FileCopyrightText: 2026 Maciej Sopyło <me@klh.io>
 * SPDX-FileCopyrightText: 2026 ChromiumOS-Guy <chromiumos-guy-opensource@proton.me>
 * SPDX-License-Identifier: GPL-3.0-or-later
 */

#include <QGuiApplication>
#include <QDBusConnection>
#include <QDBusMetaType>
#include <QDebug>

#include "dbus_types.h"
#include "DesktopPortal.h"

int main(int argc, char **argv)
{
    // FIXME: need to offload UI from main (prehaps to to lomiri shell directly, subject to debate)
    // QGuiApplication (not QCoreApplication): portals such as FileChooser show QML dialogs
    // (QQuickView), which require the GUI stack.
    QGuiApplication app(argc, argv);
    // The backend outlives any transient picker window - don't exit when a dialog closes.
    app.setQuitOnLastWindowClosed(false);

    if (!QDBusConnection::sessionBus().isConnected()) {
        qWarning() << "Cannot connect to the D-Bus session bus!";
        return 1;
    }

    new DesktopPortal(&app);
    return app.exec();
}
