Skip to content

Commit

Permalink
Add support for poppler-qt6
Browse files Browse the repository at this point in the history
Fixes #352
  • Loading branch information
selmf committed Nov 14, 2022
1 parent 133e378 commit 633113b
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Version counting is based on semantic versioning (Major.Feature.Patch)

### All apps
* Run logger in a dedicated thread to avoid segfaults at application shutdown
* Add support for poppler-qt6 pdf backend

## 9.10

Expand Down
3 changes: 1 addition & 2 deletions YACReaderLibrary/initial_comic_info_extractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void InitialComicInfoExtractor::extract()
#ifndef NO_PDF
if (fi.suffix().compare("pdf", Qt::CaseInsensitive) == 0) {
#if defined Q_OS_MAC && defined USE_PDFKIT
auto pdfComic = std::make_unique<MacOSXPDFComic>();
auto pdfComic = std::make_unique<MacOSXPDFComic>();
if (!pdfComic->openComic(_fileSource)) {
return;
}
Expand Down Expand Up @@ -64,7 +64,6 @@ void InitialComicInfoExtractor::extract()
saveCover(_target, p);
} else if (_target != "") {
QLOG_WARN() << "Extracting cover: requested cover index greater than numPages " << _fileSource;

}
}
return;
Expand Down
7 changes: 6 additions & 1 deletion common/comic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -808,8 +808,13 @@ void PDFComic::process()
return;
}
#else

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
pdfComic = Poppler::Document::load(_path);
#else
auto _pdfComic = Poppler::Document::load(_path);
pdfComic = std::unique_ptr<Poppler::Document>(_pdfComic);
#endif

if (!pdfComic) {
moveToThread(QCoreApplication::instance()->thread());
Expand Down Expand Up @@ -877,7 +882,7 @@ void PDFComic::renderPage(int page)
QImage img = pdfComic->getPage(page);
if (!img.isNull()) {
#else
std::unique_ptr<Poppler::Page> pdfpage (pdfComic->page(page));
std::unique_ptr<Poppler::Page> pdfpage(pdfComic->page(page));
if (pdfpage) {
QImage img = pdfpage->renderToImage(150, 150);
#endif
Expand Down
3 changes: 2 additions & 1 deletion common/comic.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "pdf_comic.h"
#endif // NO_PDF
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()
class Comic : public QObject
{
Expand Down Expand Up @@ -172,6 +172,7 @@ class PDFComic : public Comic
std::unique_ptr<Poppler::Document> pdfComic;
#endif
void renderPage(int page);

// void run();

public:
Expand Down
5 changes: 5 additions & 0 deletions common/pdf_comic.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <QImage>
#include <QFile>
#include <QMutex>
#include <QtGlobal>

#if defined Q_OS_MAC && defined USE_PDFKIT
class MacOSXPDFComic
Expand Down Expand Up @@ -45,6 +46,10 @@ class PdfiumComic
QFile pdfFile;
};
#else
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#include <poppler-qt6.h>
#else
#include "poppler-qt5.h"
#endif // QT_VERSION
#endif // Q_OS_MAC
#endif // PDF_COMIC_H
33 changes: 23 additions & 10 deletions dependencies/pdf_backend.pri
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,31 @@ CONFIG(poppler) {
LIBS += -L$$PWD/poppler/dependencies/bin
}
if(unix|mingw):!macx {
!contains(QT_CONFIG, no-pkg-config):packagesExist(poppler-qt5) {
message("Using system provided installation of poppler-qt5 found by pkg-config.")
CONFIG += link_pkgconfig
PKGCONFIG += poppler-qt5
} else:!macx:exists(/usr/include/poppler/qt5) {
message("Using system provided installation of poppler-qt5.")
INCLUDEPATH += /usr/include/poppler/qt5
LIBS += -lpoppler-qt5
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 {
error("Could not find poppler-qt5")
!contains(QT_CONFIG, no-pkg-config):packagesExist(poppler-qt5) {
message("Using system provided installation of poppler-qt5 found by pkg-config.")
CONFIG += link_pkgconfig
PKGCONFIG += poppler-qt5
} else:!macx:exists(/usr/include/poppler/qt5) {
message("Using system provided installation of poppler-qt5.")
INCLUDEPATH += /usr/include/poppler/qt5
LIBS += -lpoppler-qt5
} else {
error("Could not find poppler-qt5")
}
}

}
unix:macx {
error (Poppler backend is currently not supported on macOS)
Expand Down

0 comments on commit 633113b

Please sign in to comment.