diff --git a/README.md b/README.md index b8681ab..2ef4c7a 100644 --- a/README.md +++ b/README.md @@ -12,8 +12,8 @@ Based on discontinued [poppler-qml-plugin](https://launchpad.net/poppler-qml-plu ![Example application screenshot](example/screenshot.png?raw=true) ## Requirements -* Qt 5.11+ -* Poppler-Qt5 0.31+ +* Qt 6.2+ +* Poppler-Qt6 0.31+ * Qt Quick Controls 2 (only for an example app) ## Build and install @@ -24,6 +24,8 @@ make make install ``` +To install to other path, use `qmake INSTALL_PREFIX=`, everything stays the same. + ## Example See example app sources in [example directory](example/). diff --git a/example/example.pro b/example/example.pro index 56c4bcf..b1f1ebc 100644 --- a/example/example.pro +++ b/example/example.pro @@ -1,6 +1,6 @@ QT += quick widgets -CONFIG += c++11 +CONFIG += c++17 # The following define makes your compiler emit warnings if you use # any Qt feature that has been marked deprecated (the exact warnings diff --git a/src/PDFView.qml b/src/PDFView.qml index f5a0454..8987e26 100644 --- a/src/PDFView.qml +++ b/src/PDFView.qml @@ -106,7 +106,7 @@ ListView { __currentSearchResultIndex = -1 __currentSearchResults = [] } - onError: pagesView.error(errorMessage) + onError: (errorMessage) => pagesView.error(errorMessage) } // Current page @@ -119,7 +119,9 @@ ListView { Connections { target: pagesView - onContentYChanged: __updateCurrentPage() + function onContentYChanged() { + __updateCurrentPage() + } } function __goTo (destination) { diff --git a/src/pageImageProvider.cpp b/src/pageImageProvider.cpp index fd54552..d77d80d 100644 --- a/src/pageImageProvider.cpp +++ b/src/pageImageProvider.cpp @@ -45,7 +45,7 @@ QImage PageImageProvider::requestImage(const QString& id, QSize* size, const QSi DEBUG << "Page" << numPage << "requested"; - QScopedPointer page(document->page(numPage - 1)); + auto page = document->page(numPage - 1); QSizeF pageSize = page->pageSizeF(); DEBUG << "Requested size:" << requestedSize << "Page size:" << pageSize; diff --git a/src/pageImageProvider.h b/src/pageImageProvider.h index f04ad64..202e973 100644 --- a/src/pageImageProvider.h +++ b/src/pageImageProvider.h @@ -20,7 +20,7 @@ #define PAGEIMAGEPROVIDER_H #include -#include +#include class PageImageProvider : public QQuickImageProvider { diff --git a/src/pdfModel.cpp b/src/pdfModel.cpp index e93c966..629030d 100644 --- a/src/pdfModel.cpp +++ b/src/pdfModel.cpp @@ -21,7 +21,7 @@ #include "pageImageProvider.h" // Poppler -#include +#include // Qt #include @@ -71,7 +71,6 @@ void PdfModel::setPath(QString& pathName) { DEBUG << "ERROR : Can't open the document located at " + pathName; emit error("Can't open the document located at " + pathName); - delete document; document = nullptr; return; } @@ -97,7 +96,7 @@ void PdfModel::setPath(QString& pathName) { if (link->linkType() == Poppler::Link::Goto) { - auto gotoLink = static_cast(link); + auto gotoLink = static_cast(link.get()); if (!gotoLink->isExternal()) { pageLinks.append(QVariantMap{{ "rect", link->linkArea().normalized() }, { "destination", convertDestination(gotoLink->destination()) }}); @@ -161,7 +160,7 @@ void PdfModel::loadProvider() const QString& prefix = QString::number(quintptr(this)); providerName = "poppler" + prefix; - engine->addImageProvider(providerName, new PageImageProvider(document)); + engine->addImageProvider(providerName, new PageImageProvider(document.get())); DEBUG << "Image provider loaded successfully !" << qPrintable("(" + providerName + ")"); } @@ -177,7 +176,6 @@ void PdfModel::clear() providerName.clear(); } - delete document; document = nullptr; emit loadedChanged(); pages.clear(); diff --git a/src/pdfModel.h b/src/pdfModel.h index da1db59..01a16fe 100644 --- a/src/pdfModel.h +++ b/src/pdfModel.h @@ -20,7 +20,7 @@ #define PDFMODEL_H #include -#include +#include #define DEBUG if (qgetenv("POPPLERPLUGIN_DEBUG") == "1") qDebug() << "Poppler plugin:" @@ -54,7 +54,7 @@ class PdfModel : public QObject void loadProvider(); void clear(); - Poppler::Document* document = nullptr; + std::unique_ptr document = nullptr; QString providerName; QString path; QVariantList pages; diff --git a/src/src.pro b/src/src.pro index d679525..c3ac432 100644 --- a/src/src.pro +++ b/src/src.pro @@ -4,7 +4,7 @@ QT += qml quick CONFIG += qt plugin TEMPLATE = lib -LIBS += -lpoppler-qt5 +LIBS += -lpoppler-qt6 # Input SOURCES += \ @@ -31,7 +31,10 @@ qmltypes.commands = $$[QT_INSTALL_BINS]/qmlplugindump org.docviewer.poppler 1.0 qmltypes.depends = $$QMAKE_RESOLVED_TARGET QMAKE_EXTRA_TARGETS += qmltypes -installPath = $$[QT_INSTALL_QML]/org/docviewer/poppler/ +isEmpty(INSTALL_PREFIX) { + INSTALL_PREFIX = $$[QT_INSTALL_QML] +} +installPath = $${INSTALL_PREFIX}/org/docviewer/poppler/ qmlFiles.path = $$installPath target.path = $$installPath INSTALLS += target qmlFiles