File indexing completed on 2025-02-02 04:36:38
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 <QFontDatabase> 0008 0009 #include "plugin.h" 0010 0011 //poppler stuff 0012 #include <poppler/code/pdfdocument.h> 0013 #include <poppler/code/thumbnailer.h> 0014 0015 //cb stuff 0016 #include <cbz/code/ArchiveBookModel.h> 0017 #include <cbz/code/BookListModel.h> 0018 #include <cbz/code/BookModel.h> 0019 #include <cbz/code/ComicCoverImageProvider.h> 0020 #include <cbz/code/FolderBookModel.h> 0021 #include <cbz/code/PreviewImageProvider.h> 0022 0023 #include <cbz/code/FilterProxy.h> 0024 #include <cbz/code/PropertyContainer.h> 0025 0026 #include <cbz/code/acbf/AcbfBinary.h> 0027 #include <cbz/code/acbf/AcbfReference.h> 0028 #include <cbz/code/acbf/AcbfStyle.h> 0029 #include <cbz/code/acbf/AcbfIdentifiedObjectModel.h> 0030 0031 void DocumentsPlugin::registerTypes(const char *uri) 0032 { 0033 #if defined(Q_OS_ANDROID) 0034 QResource::registerResource(QStringLiteral("assets:/android_rcc_bundle.rcc")); 0035 QResource::registerResource(QStringLiteral("fonts.qrc"), "fonts"); 0036 0037 if(QFile::exists(":/fonts/Courier/Courier.ttf")) 0038 { 0039 qDebug() << "Courier font exists"; 0040 } 0041 QFontDatabase::addApplicationFont(":/fonts/Courier/Courier.ttf"); 0042 QFontDatabase::addApplicationFont(":/fonts/Courier/Courier Bold Oblique.otf"); 0043 QFontDatabase::addApplicationFont(":/fonts/Helvetica-Font/Helvetica-Bold.ttf"); 0044 QFontDatabase::addApplicationFont(":/fonts/Helvetica-Font/Helvetica-BoldOblique.ttf"); 0045 QFontDatabase::addApplicationFont(":/fonts/Helvetica-Font/Helvetica-Oblique.ttf"); 0046 QFontDatabase::addApplicationFont(":/fonts/times/TIMESR.ttf"); 0047 QFontDatabase::addApplicationFont(":/fonts/Helvetica-Font/Helvetica.ttf"); 0048 #endif 0049 0050 Q_ASSERT(QLatin1String(uri) == QLatin1String("org.mauikit.documents")); 0051 //Poppler stuff 0052 qmlRegisterType<PdfDocument>(uri, 1, 0, "Document"); 0053 qmlRegisterType(componentUrl(QStringLiteral("poppler/PDFViewer.qml")), uri, 1, 0, "PDFViewer"); 0054 0055 //CB stuff 0056 qmlRegisterType<CategoryEntriesModel>(uri, 1, 0, "CategoryEntriesModel"); 0057 qmlRegisterType<BookListModel>(uri, 1, 0, "BookListModel"); 0058 qmlRegisterType<BookModel>(uri, 1, 0, "BookModel"); 0059 qmlRegisterType<ArchiveBookModel>(uri, 1, 0, "ArchiveBookModel"); 0060 qmlRegisterType<FolderBookModel>(uri, 1, 0, "FolderBookModel"); 0061 qmlRegisterType<PropertyContainer>(uri, 1, 0, "PropertyContainer"); 0062 qmlRegisterType<FilterProxy>(uri, 1, 0, "FilterProxy"); 0063 0064 qmlRegisterUncreatableType<AdvancedComicBookFormat::Reference>(uri, 1, 0, "Reference", "Don't attempt to create ACBF types directly, use the convenience functions on their container types for creating them"); 0065 qmlRegisterUncreatableType<AdvancedComicBookFormat::Binary>(uri, 1, 0, "Binary", "Don't attempt to create ACBF types directly, use the convenience functions on their container types for creating them"); 0066 qmlRegisterUncreatableType<AdvancedComicBookFormat::Style>(uri, 1, 0, "Style", "Don't attempt to create ACBF types directly, use the convenience functions on their container types for creating them"); 0067 qmlRegisterType<AdvancedComicBookFormat::IdentifiedObjectModel>(uri, 1, 0, "IdentifiedObjectModel"); 0068 0069 } 0070 0071 void DocumentsPlugin::initializeEngine(QQmlEngine *engine, const char *uri) 0072 { 0073 Q_UNUSED(uri); 0074 0075 /** IMAGE PROVIDERS **/ 0076 engine->addImageProvider("preview", new Thumbnailer()); 0077 0078 0079 // engine->addImageProvider("preview", new PreviewImageProvider()); 0080 engine->addImageProvider("comiccover", new ComicCoverImageProvider()); 0081 0082 } 0083 0084 QUrl DocumentsPlugin::componentUrl(const QString &fileName) const 0085 { 0086 return QUrl(resolveFileUrl(fileName)); 0087 }