/*
 *  SPDX-FileCopyrightText: 2009 Alan Alpert <alan.alpert@nokia.com>
 *  SPDX-FileCopyrightText: 2010 Ménard Alexis <menard@kde.org>
 *  SPDX-FileCopyrightText: 2010 Marco Martin <mart@kde.org>
 *
 *  SPDX-License-Identifier: LGPL-2.0-or-later
 */

#include "kirigamiformsplugin.h"

// This is required for declarative registration to work on Windows.
// This is normally generated by Qt but since we need a manually written plugin
// file, we need to include this ourselves.
extern void qml_register_types_org_kde_kirigami_forms();
Q_GHS_KEEP_REFERENCE(qml_register_types_org_kde_kirigami_forms)

KirigamiFormsPlugin::KirigamiFormsPlugin(QObject *parent)
    : QQmlExtensionPlugin(parent)
{
    // See above.
    volatile auto registration = &qml_register_types_org_kde_kirigami_forms;
    Q_UNUSED(registration)
}

void KirigamiFormsPlugin::registerTypes(const char *uri)
{
    Q_ASSERT(QLatin1String(uri) == QLatin1String("org.kde.kirigami.forms"));

    QString formsChoice = QString::fromLocal8Bit(qgetenv("KDE_KIRIGAMI_FORMS_STYLE"));
    if (formsChoice.isEmpty() || formsChoice != QStringLiteral("flat")) {
        formsChoice = QStringLiteral("cards");
    }

    qmlRegisterModuleImport(uri,
                            QQmlModuleImportModuleAny,
                            (QLatin1String("org.kde.kirigami.forms.private.") % formsChoice).toUtf8().constData(),
                            QQmlModuleImportLatest,
                            QQmlModuleImportAuto);
}

#include "moc_kirigamiformsplugin.cpp"
