Warning, file /maui/mauikit-filebrowsing/src/code/filebrowsing_plugin.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // SPDX-FileCopyrightText: 2020 Carl Schwan <carl@carlschwan.eu>
0002 //
0003 // SPDX-License-Identifier: LGPL-2.1-or-later
0004 
0005 #include "filebrowsing_plugin.h"
0006 
0007 #include <QQmlEngine>
0008 #include <QResource>
0009 
0010 #include "thumbnailer.h"
0011 
0012 #include "fmstatic.h"
0013 
0014 #include "tagslist.h"
0015 #include "tagging.h"
0016 
0017 #include "placeslist.h"
0018 #include "fmlist.h"
0019 #include "openwithmodel.h"
0020 
0021 QUrl FileBrowsingPlugin::componentUrl(const QString &fileName) const
0022 {
0023     return QUrl(resolveFileUrl(fileName));
0024 }
0025 
0026 void FileBrowsingPlugin::registerTypes(const char *uri)
0027 {
0028 #if defined(Q_OS_ANDROID)
0029     QResource::registerResource(QStringLiteral("assets:/android_rcc_bundle.rcc"));
0030 #endif
0031 
0032     Q_ASSERT(QLatin1String(uri) == QLatin1String("org.mauikit.filebrowsing"));
0033     
0034     //File Browsing components
0035     qmlRegisterType<FMList>(uri, 1, 0, "FMList");
0036     qmlRegisterType<PlacesList>(uri, 1, 0, "PlacesList");
0037     qmlRegisterUncreatableType<PathStatus>(uri, 1, 0, "PathStatus", QStringLiteral("cannot be created :: PathStatus"));
0038 
0039     qmlRegisterType(componentUrl(QStringLiteral("FileBrowser.qml")), uri, 1, 0, "FileBrowser");
0040     qmlRegisterType(componentUrl(QStringLiteral("PlacesListBrowser.qml")), uri, 1, 0, "PlacesListBrowser");
0041     qmlRegisterType(componentUrl(QStringLiteral("FileDialog.qml")), uri, 1, 0, "FileDialog");
0042 
0043     qmlRegisterType<OpenWithModel>(uri, 1, 3, "OpenWithModel");
0044     qmlRegisterType(componentUrl(QStringLiteral("OpenWithDialog.qml")), uri, 1, 0, "OpenWithDialog");
0045     
0046     qmlRegisterSingletonType<FMStatic>(uri, 1, 0, "FM", [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject * {
0047         Q_UNUSED(engine)
0048         Q_UNUSED(scriptEngine)
0049         return new FMStatic;
0050     });
0051     
0052     //File Tagging components
0053     qmlRegisterSingletonType<Tagging>(uri, 1, 3, "Tagging", [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject * {
0054         Q_UNUSED(engine)
0055         Q_UNUSED(scriptEngine)
0056         return Tagging::getInstance();
0057     }); //the singleton instance results in having tagging instance created in different threads which is not supported byt the slq driver
0058     
0059     qmlRegisterType<TagsList>(uri, 1, 0, "TagsListModel");
0060     qmlRegisterType(componentUrl(QStringLiteral("private/TagList.qml")), uri, 1, 0, "TagList");
0061     qmlRegisterType(componentUrl(QStringLiteral("TagsBar.qml")), uri, 1, 0, "TagsBar");
0062     qmlRegisterType(componentUrl(QStringLiteral("TagsDialog.qml")), uri, 1, 0, "TagsDialog");
0063     qmlRegisterType(componentUrl(QStringLiteral("NewTagDialog.qml")), uri, 1, 3, "NewTagDialog");
0064     
0065     //File Syncing components
0066 }
0067 
0068 void FileBrowsingPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
0069 {
0070     Q_UNUSED(uri);
0071 
0072     /** IMAGE PROVIDERS **/
0073     engine->addImageProvider(QStringLiteral("thumbnailer"), new Thumbnailer());
0074 }