MauiKit File Browsing

filebrowsing_plugin.cpp
1// SPDX-FileCopyrightText: 2020 Carl Schwan <carl@carlschwan.eu>
2//
3// SPDX-License-Identifier: LGPL-2.1-or-later
4
5#include "filebrowsing_plugin.h"
6
7#include <QQmlEngine>
8#include <QResource>
9#include <QDebug>
10
11#include "thumbnailer.h"
12
13#include "fmstatic.h"
14
15#include "tagslist.h"
16#include "tagging.h"
17
18#include "placeslist.h"
19#include "fmlist.h"
20#include "openwithmodel.h"
21
22QUrl FileBrowsingPlugin::componentUrl(const QString &fileName) const
23{
24 return QUrl(resolveFileUrl(fileName));
25}
26
27void FileBrowsingPlugin::registerTypes(const char *uri)
28{
29 qDebug() << "REGISTER MAUIKITFILEBROWSING TYPES <<<<<<<<<<<<<<<<<<<<<<";
30
31#if defined(Q_OS_ANDROID)
32 QResource::registerResource(QStringLiteral("assets:/android_rcc_bundle.rcc"));
33#endif
34
35 Q_ASSERT(QLatin1String(uri) == QLatin1String("org.mauikit.filebrowsing"));
36
37 //File Browsing components
38 qmlRegisterType<FMList>(uri, 1, 0, "FMList");
39 qmlRegisterType<PlacesList>(uri, 1, 0, "PlacesList");
40 qmlRegisterUncreatableType<PathStatus>(uri, 1, 0, "PathStatus", QStringLiteral("cannot be created :: PathStatus"));
41
42 qmlRegisterType(componentUrl(QStringLiteral("FileBrowser.qml")), uri, 1, 0, "FileBrowser");
43 qmlRegisterType(componentUrl(QStringLiteral("PlacesListBrowser.qml")), uri, 1, 0, "PlacesListBrowser");
44 qmlRegisterType(componentUrl(QStringLiteral("FileDialog.qml")), uri, 1, 0, "FileDialog");
45
46 qmlRegisterType<OpenWithModel>(uri, 1, 3, "OpenWithModel");
47 qmlRegisterType(componentUrl(QStringLiteral("OpenWithDialog.qml")), uri, 1, 0, "OpenWithDialog");
48
49 qmlRegisterSingletonType<FMStatic>(uri, 1, 0, "FM", [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject * {
50 Q_UNUSED(engine)
51 Q_UNUSED(scriptEngine)
52 return new FMStatic;
53 });
54
55 //File Tagging components
56 qmlRegisterSingletonType<Tagging>(uri, 1, 3, "Tagging", &Tagging::qmlInstance); //the singleton instance results in having tagging instance created in different threads which is not supported byt the slq driver
57
58 qmlRegisterType<TagsList>(uri, 1, 0, "TagsListModel");
59 qmlRegisterType(componentUrl(QStringLiteral("private/TagList.qml")), uri, 1, 0, "TagList");
60 qmlRegisterType(componentUrl(QStringLiteral("TagsBar.qml")), uri, 1, 0, "TagsBar");
61 qmlRegisterType(componentUrl(QStringLiteral("TagsDialog.qml")), uri, 1, 0, "TagsDialog");
62 qmlRegisterType(componentUrl(QStringLiteral("NewTagDialog.qml")), uri, 1, 3, "NewTagDialog");
63
64 //File Syncing components
65}
66
67void FileBrowsingPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
68{
69 Q_UNUSED(uri);
70
71 /** IMAGE PROVIDERS **/
72 engine->addImageProvider(QStringLiteral("thumbnailer"), new Thumbnailer());
73}
The FMStatic class is a group of static file management methods, this class has a constructor only as...
Definition fmstatic.h:35
void addImageProvider(const QString &providerId, QQmlImageProviderBase *provider)
bool registerResource(const QString &rccFileName, const QString &mapRoot)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 17 2024 11:51:27 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.