Add support for poppler-qt6

Fixes #352
This commit is contained in:
Felix Kauselmann 2022-11-13 17:05:29 +01:00
parent be85954b0c
commit 4a59dd6db6
6 changed files with 38 additions and 14 deletions

View File

@ -12,6 +12,7 @@ Version counting is based on semantic versioning (Major.Feature.Patch)
### All apps ### All apps
* Run logger in a dedicated thread to avoid segfaults at application shutdown * Run logger in a dedicated thread to avoid segfaults at application shutdown
* Add support for poppler-qt6 pdf backend
## 9.10 ## 9.10

View File

@ -64,7 +64,6 @@ void InitialComicInfoExtractor::extract()
saveCover(_target, p); saveCover(_target, p);
} else if (_target != "") { } else if (_target != "") {
QLOG_WARN() << "Extracting cover: requested cover index greater than numPages " << _fileSource; QLOG_WARN() << "Extracting cover: requested cover index greater than numPages " << _fileSource;
} }
} }
return; return;

View File

@ -808,8 +808,13 @@ void PDFComic::process()
return; return;
} }
#else #else
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
pdfComic = Poppler::Document::load(_path);
#else
auto _pdfComic = Poppler::Document::load(_path); auto _pdfComic = Poppler::Document::load(_path);
pdfComic = std::unique_ptr<Poppler::Document>(_pdfComic); pdfComic = std::unique_ptr<Poppler::Document>(_pdfComic);
#endif
if (!pdfComic) { if (!pdfComic) {
moveToThread(QCoreApplication::instance()->thread()); moveToThread(QCoreApplication::instance()->thread());

View File

@ -12,7 +12,7 @@
#include "pdf_comic.h" #include "pdf_comic.h"
#endif // NO_PDF #endif // NO_PDF
class ComicDB; class ComicDB;
//#define EXTENSIONS << "*.jpg" << "*.jpeg" << "*.png" << "*.gif" << "*.tiff" << "*.tif" << "*.bmp" Comic::getSupportedImageFormats()
//#define EXTENSIONS_LITERAL << ".jpg" << ".jpeg" << ".png" << ".gif" << ".tiff" << ".tif" << ".bmp" //Comic::getSupportedImageLiteralFormats() //#define EXTENSIONS_LITERAL << ".jpg" << ".jpeg" << ".png" << ".gif" << ".tiff" << ".tif" << ".bmp" //Comic::getSupportedImageLiteralFormats()
class Comic : public QObject class Comic : public QObject
{ {
@ -172,6 +172,7 @@ private:
std::unique_ptr<Poppler::Document> pdfComic; std::unique_ptr<Poppler::Document> pdfComic;
#endif #endif
void renderPage(int page); void renderPage(int page);
// void run(); // void run();
public: public:

View File

@ -5,6 +5,7 @@
#include <QImage> #include <QImage>
#include <QFile> #include <QFile>
#include <QMutex> #include <QMutex>
#include <QtGlobal>
#if defined Q_OS_MAC && defined USE_PDFKIT #if defined Q_OS_MAC && defined USE_PDFKIT
class MacOSXPDFComic class MacOSXPDFComic
@ -45,6 +46,10 @@ private:
QFile pdfFile; QFile pdfFile;
}; };
#else #else
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#include <poppler-qt6.h>
#else
#include "poppler-qt5.h" #include "poppler-qt5.h"
#endif // QT_VERSION
#endif // Q_OS_MAC #endif // Q_OS_MAC
#endif // PDF_COMIC_H #endif // PDF_COMIC_H

View File

@ -55,6 +55,19 @@ CONFIG(poppler) {
LIBS += -L$$PWD/poppler/dependencies/bin LIBS += -L$$PWD/poppler/dependencies/bin
} }
if(unix|mingw):!macx { if(unix|mingw):!macx {
greaterThan (QT_MAJOR_VERSION, 5) {
!contains(QT_CONFIG, no-pkg-config):packagesExist(poppler-qt6) {
message("Using system provided installation of poppler-qt6 found by pkg-config.")
CONFIG += link_pkgconfig
PKGCONFIG += poppler-qt6
} else:!macx:exists(/usr/include/poppler/qt6) {
message("Using system provided installation of poppler-qt6.")
INCLUDEPATH += /usr/include/poppler/qt6
LIBS += -lpoppler-qt6
} else {
error("Could not find poppler-qt6")
}
} else {
!contains(QT_CONFIG, no-pkg-config):packagesExist(poppler-qt5) { !contains(QT_CONFIG, no-pkg-config):packagesExist(poppler-qt5) {
message("Using system provided installation of poppler-qt5 found by pkg-config.") message("Using system provided installation of poppler-qt5 found by pkg-config.")
CONFIG += link_pkgconfig CONFIG += link_pkgconfig
@ -66,7 +79,7 @@ CONFIG(poppler) {
} else { } else {
error("Could not find poppler-qt5") error("Could not find poppler-qt5")
} }
}
} }
unix:macx { unix:macx {
error (Poppler backend is currently not supported on macOS) error (Poppler backend is currently not supported on macOS)