File indexing completed on 2024-04-21 04:44:33

0001 // SPDX-FileCopyrightText: 2020 Carl Schwan <carl@carlschwan.eu>
0002 //
0003 // SPDX-License-Identifier: LGPL-2.1-or-later
0004 
0005 #include <QQmlEngine>
0006 #include <QResource>
0007 #include <QQmlContext>
0008 
0009 #include "accounts_plugin.h"
0010 
0011 #include "mauiaccounts.h"
0012 
0013 void AccountsPlugin::registerTypes(const char *uri)
0014 {
0015     #if defined(Q_OS_ANDROID)
0016     QResource::registerResource(QStringLiteral("assets:/android_rcc_bundle.rcc"));
0017     #endif
0018     
0019     Q_ASSERT(QLatin1String(uri) == QLatin1String("org.mauikit.accounts"));
0020 
0021     qmlRegisterSingletonType<MauiAccounts>(uri, 1, 0, "Accounts", [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject * {
0022         Q_UNUSED(scriptEngine)
0023         auto accounts = MauiAccounts::instance();
0024         engine->setObjectOwnership(accounts, QQmlEngine::CppOwnership);
0025         return accounts;
0026     });
0027     
0028     qmlRegisterType(componentUrl(QStringLiteral("AccountsMenuItem.qml")), uri, 1, 0, "AccountsMenuItem");
0029     qmlRegisterType(componentUrl(QStringLiteral("AccountsDialog.qml")), uri, 1, 0, "AccountsDialog");
0030     qmlRegisterType(componentUrl(QStringLiteral("CredentialsDialog.qml")), uri, 1, 0, "CredentialsDialog");
0031 }
0032 
0033 void AccountsPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
0034 {
0035     Q_UNUSED(uri);
0036     Q_UNUSED(engine);
0037     
0038 }
0039 
0040 QUrl AccountsPlugin::componentUrl(const QString &fileName) const
0041 {
0042     return QUrl(resolveFileUrl(fileName));
0043 }