Skip to content

Commit

Permalink
Use Qt6
Browse files Browse the repository at this point in the history
  • Loading branch information
MasterMind2k committed Jan 1, 2022
1 parent 7d46650 commit 3410daf
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 15 deletions.
4 changes: 2 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 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
2 changes: 1 addition & 1 deletion 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 Down

0 comments on commit 3410daf

Please sign in to comment.