Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial move to Qt 6 #9

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -24,6 +24,8 @@ make
make install
```

To install to other path, use `qmake INSTALL_PREFIX=<path>`, everything stays the same.

## Example

See example app sources in [example directory](example/).
Expand Down
2 changes: 1 addition & 1 deletion example/example.pro
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 4 additions & 2 deletions src/PDFView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ ListView {
__currentSearchResultIndex = -1
__currentSearchResults = []
}
onError: pagesView.error(errorMessage)
onError: (errorMessage) => pagesView.error(errorMessage)
}

// Current page
Expand All @@ -119,7 +119,9 @@ ListView {

Connections {
target: pagesView
onContentYChanged: __updateCurrentPage()
function onContentYChanged() {
__updateCurrentPage()
}
}

function __goTo (destination) {
Expand Down
2 changes: 1 addition & 1 deletion src/pageImageProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ QImage PageImageProvider::requestImage(const QString& id, QSize* size, const QSi

DEBUG << "Page" << numPage << "requested";

QScopedPointer <Poppler::Page> page(document->page(numPage - 1));
auto page = document->page(numPage - 1);

QSizeF pageSize = page->pageSizeF();
DEBUG << "Requested size:" << requestedSize << "Page size:" << pageSize;
Expand Down
2 changes: 1 addition & 1 deletion src/pageImageProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#define PAGEIMAGEPROVIDER_H

#include <QQuickImageProvider>
#include <poppler/qt5/poppler-qt5.h>
#include <poppler/qt6/poppler-qt6.h>

class PageImageProvider : public QQuickImageProvider
{
Expand Down
8 changes: 3 additions & 5 deletions src/pdfModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include "pageImageProvider.h"

// Poppler
#include <poppler/qt5/poppler-qt5.h>
#include <poppler/qt6/poppler-qt6.h>

// Qt
#include <QDebug>
Expand Down Expand Up @@ -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;
}
Expand All @@ -97,7 +96,7 @@ void PdfModel::setPath(QString& pathName)
{
if (link->linkType() == Poppler::Link::Goto)
{
auto gotoLink = static_cast<Poppler::LinkGoto*>(link);
auto gotoLink = static_cast<Poppler::LinkGoto*>(link.get());
if (!gotoLink->isExternal())
{
pageLinks.append(QVariantMap{{ "rect", link->linkArea().normalized() }, { "destination", convertDestination(gotoLink->destination()) }});
Expand Down Expand Up @@ -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 + ")");
}
Expand All @@ -177,7 +176,6 @@ void PdfModel::clear()
providerName.clear();
}

delete document;
document = nullptr;
emit loadedChanged();
pages.clear();
Expand Down
4 changes: 2 additions & 2 deletions src/pdfModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#define PDFMODEL_H

#include <QObject>
#include <poppler/qt5/poppler-qt5.h>
#include <poppler/qt6/poppler-qt6.h>

#define DEBUG if (qgetenv("POPPLERPLUGIN_DEBUG") == "1") qDebug() << "Poppler plugin:"

Expand Down Expand Up @@ -54,7 +54,7 @@ class PdfModel : public QObject
void loadProvider();
void clear();

Poppler::Document* document = nullptr;
std::unique_ptr<Poppler::Document> document = nullptr;
QString providerName;
QString path;
QVariantList pages;
Expand Down
7 changes: 5 additions & 2 deletions src/src.pro
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ QT += qml quick
CONFIG += qt plugin
TEMPLATE = lib

LIBS += -lpoppler-qt5
LIBS += -lpoppler-qt6

# Input
SOURCES += \
Expand All @@ -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