[graphics/pvfviewer] /: Ported to KF6/Qt6
Steve Allewell
null at kde.org
Thu Oct 31 22:08:41 GMT 2024
Git commit c34a72c5c697758c636bf18a2777f2015d1a85fb by Steve Allewell.
Committed on 31/10/2024 at 22:02.
Pushed by sallewell into branch 'master'.
Ported to KF6/Qt6
M +2 -2 .gitlab-ci.yml
M +7 -7 .kde-ci.yml
M +21 -15 CMakeLists.txt
M +1 -1 build.sh
M +1 -1 doc/credits.docbook
M +2 -2 doc/index.docbook
M +1 -1 pvfViewerui.rc
M +2 -2 src/Main.cpp
M +1 -1 src/MainWindow.cpp
M +2 -3 src/Thumbnail.cpp
M +3 -3 src/Thumbnail.h
M +14 -31 src/ViewerTab.cpp
M +2 -2 src/ViewerTab.h
https://invent.kde.org/graphics/pvfviewer/-/commit/c34a72c5c697758c636bf18a2777f2015d1a85fb
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 8c89af5..4c99cc3 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -4,6 +4,6 @@
include:
- project: sysadmin/ci-utilities
file:
- - /gitlab-templates/linux.yml
- - /gitlab-templates/freebsd.yml
+ - /gitlab-templates/linux-qt6.yml
+ - /gitlab-templates/freebsd-qt6.yml
diff --git a/.kde-ci.yml b/.kde-ci.yml
index 78c2117..3703e91 100644
--- a/.kde-ci.yml
+++ b/.kde-ci.yml
@@ -2,14 +2,14 @@
# SPDX-License-Identifier: CC0-1.0
Dependencies:
-- 'on': ['@all']
+- 'on': ['Linux', 'FreeBSD', 'Windows']
'require':
- 'frameworks/extra-cmake-modules': '@stable'
- 'frameworks/kdoctools': '@stable'
- 'frameworks/ki18n': '@stable'
- 'frameworks/kio': '@stable'
- 'frameworks/kwidgetsaddons': '@stable'
- 'frameworks/kxmlgui': '@stable'
+ 'frameworks/extra-cmake-modules': '@latest-kf6'
+ 'frameworks/kdoctools': '@latest-kf6'
+ 'frameworks/ki18n': '@latest-kf6'
+ 'frameworks/kio': '@latest-kf6'
+ 'frameworks/kwidgetsaddons': '@latest-kf6'
+ 'frameworks/kxmlgui': '@latest-kf6'
Options:
require-passing-tests-on: ['Linux', 'FreeBSD', 'Windows']
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 673600c..761e334 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,7 +2,7 @@ cmake_minimum_required (VERSION 3.16)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
-project (pvfViewer)
+project (pvfViewer VERSION "1.0.0")
find_package (ECM REQUIRED NO_MODULE)
set (CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
@@ -10,20 +10,21 @@ set (CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
include (KDEInstallDirs)
include (KDECMakeSettings)
include (KDECompilerSettings NO_POLICY_SCOPE)
+include (ECMSetupVersion)
include (ECMInstallIcons)
include (FeatureSummary)
kde_enable_exceptions ()
-find_package (Qt5 CONFIG REQUIRED
+find_package (Qt6 CONFIG REQUIRED
Core
PrintSupport
Widgets
)
-find_package (KF5DocTools)
+find_package (KF6DocTools)
-find_package (KF5 REQUIRED COMPONENTS
+find_package (KF6 REQUIRED COMPONENTS
I18n
KIO
WidgetsAddons
@@ -31,10 +32,15 @@ find_package (KF5 REQUIRED COMPONENTS
)
find_package (SharedMimeInfo)
-find_package (Poppler REQUIRED COMPONENTS Qt5)
+find_package (Poppler REQUIRED COMPONENTS Qt6)
include_directories (BEFORE ${CMAKE_CURENT_BINARY_DIR})
+ecm_setup_version(${pvfViewer_VERSION}
+ VARIABLE_PREFIX PVFVIEWER
+ VERSION_HEADER Version.h
+)
+
set (pvfViewer_SRCS
src/Main.cpp
src/MainWindow.cpp
@@ -47,23 +53,23 @@ set (pvfViewer_SRCS
file (GLOB pvfViewer_UI ${CMAKE_CURRENT_SOURCE_DIR}/ui/*.ui)
ki18n_wrap_ui (pvfViewer_SRCS ${pvfViewer_UI})
-if (KF5DocTools_FOUND)
+if (KF6DocTools_FOUND)
add_subdirectory (doc)
-endif (KF5DocTools_FOUND)
+endif (KF6DocTools_FOUND)
ecm_install_icons (ICONS sc-apps-pvfViewer.svgz sc-mimetypes-application-x-pvf.svgz DESTINATION ${KDE_INSTALL_ICONDIR})
add_executable (pvfViewer ${pvfViewer_SRCS})
target_link_libraries (pvfViewer
- Qt5::Core
- Qt5::PrintSupport
- Qt5::Widgets
- KF5::I18n
- KF5::KIOFileWidgets
- KF5::WidgetsAddons
- KF5::XmlGui
- Poppler::Qt5
+ Qt6::Core
+ Qt6::PrintSupport
+ Qt6::Widgets
+ KF6::I18n
+ KF6::KIOFileWidgets
+ KF6::WidgetsAddons
+ KF6::XmlGui
+ Poppler::Qt6
)
if (SILENCE_DEPRECATED)
diff --git a/build.sh b/build.sh
index f647a60..23712fc 100755
--- a/build.sh
+++ b/build.sh
@@ -61,7 +61,7 @@ else
mkdir build
if [ -d "build" ]; then
cd build
- cmake -DCMAKE_INSTALL_PREFIX=`qtpaths --install-prefix` .. -DCMAKE_BUILD_TYPE=$BUILD_TYPE $WITH_PROFILE $SILENCE_DEPRECATED && make -j${THREADS} $VERBOSE && sudo make install
+ cmake -DCMAKE_INSTALL_PREFIX=`qtpaths6 --install-prefix` .. -DBUILD_WITH_QT6=ON -DCMAKE_BUILD_TYPE=$BUILD_TYPE $WITH_PROFILE $SILENCE_DEPRECATED && make -j${THREADS} $VERBOSE && sudo make install
else
echo "Unable to create build directory. Build aborted\n"
fi
diff --git a/doc/credits.docbook b/doc/credits.docbook
index ebdeba4..1a33e68 100644
--- a/doc/credits.docbook
+++ b/doc/credits.docbook
@@ -14,7 +14,7 @@
</para>
<para>
Inspiration and some code snippets from <ulink url="https://okular.kde.org/">Okular</ulink> which
- also uses the Poppler library and its Qt5 interface for displaying PDF documents.
+ also uses the Poppler library and its Qt interface for displaying PDF documents.
</para>
<para>
Tux image attribution: <email>lewing at isc.tamu.edu</email> Larry Ewing and The GIMP.
diff --git a/doc/index.docbook b/doc/index.docbook
index a74471a..6e6a77b 100644
--- a/doc/index.docbook
+++ b/doc/index.docbook
@@ -26,8 +26,8 @@
<holder>Stephen P. Allewell</holder>
</copyright>
<legalnotice>&FDLNotice;</legalnotice>
- <date>2020-03-10</date>
- <releaseinfo>pvfViewer 0.1.0</releaseinfo>
+ <date>2024-10-31</date>
+ <releaseinfo>pvfViewer 1.0.0</releaseinfo>
<abstract>
<para>
&pvfViewer; is an application to allow opening and printing of PC Stitch Pattern Viewer files.
diff --git a/pvfViewerui.rc b/pvfViewerui.rc
index fee0c8b..00675d5 100644
--- a/pvfViewerui.rc
+++ b/pvfViewerui.rc
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
-<kpartgui name="pvfViewer" version="0.1.0">
+<kpartgui name="pvfViewer" version="1.0.0">
<MenuBar>
<Menu name="file">
<Action name="fileExportPDF"/>
diff --git a/src/Main.cpp b/src/Main.cpp
index 8d52309..1ad9e39 100644
--- a/src/Main.cpp
+++ b/src/Main.cpp
@@ -18,7 +18,7 @@
#include <KLocalizedString>
#include "MainWindow.h"
-
+#include "Version.h"
int main(int argc, char *argv[])
{
@@ -28,7 +28,7 @@ int main(int argc, char *argv[])
KAboutData aboutData(QStringLiteral("pvfViewer"), // component name
QString(i18n("pvfViewer")), // display name
- QStringLiteral("0.1.0"), // version
+ QStringLiteral(PVFVIEWER_VERSION_STRING), // version
i18n("A PC Stitch pvf pattern viewer."), // short description
KAboutLicense::GPL_V2, // license
i18n("(c)2020 Steve Allewell"), // copyright
diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp
index 7a6f88e..3410449 100644
--- a/src/MainWindow.cpp
+++ b/src/MainWindow.cpp
@@ -21,7 +21,7 @@
#include <KLocalizedString>
#include <KRecentFilesAction>
-#include <poppler-qt5.h>
+#include <poppler-qt6.h>
#include "ViewerTab.h"
diff --git a/src/Thumbnail.cpp b/src/Thumbnail.cpp
index 2ed8187..b03dd84 100644
--- a/src/Thumbnail.cpp
+++ b/src/Thumbnail.cpp
@@ -14,16 +14,15 @@
#include <QPainter>
-Thumbnail::Thumbnail(Poppler::Page *pdfPage, QListWidget *parent)
+Thumbnail::Thumbnail(std::unique_ptr<Poppler::Page> pdfPage, QListWidget *parent)
: QListWidgetItem(parent, QListWidgetItem::UserType),
- m_pdfPage(pdfPage)
+ m_pdfPage(std::move(pdfPage))
{
}
Thumbnail::~Thumbnail()
{
- delete m_pdfPage;
}
diff --git a/src/Thumbnail.h b/src/Thumbnail.h
index f805eee..fb010e6 100644
--- a/src/Thumbnail.h
+++ b/src/Thumbnail.h
@@ -15,7 +15,7 @@
#include <QListWidgetItem>
-#include <poppler-qt5.h>
+#include <poppler-qt6.h>
class QImage;
@@ -24,7 +24,7 @@ class QImage;
class Thumbnail : public QListWidgetItem
{
public:
- Thumbnail(Poppler::Page *pdfPage, QListWidget *parent);
+ Thumbnail(std::unique_ptr<Poppler::Page> pdfPage, QListWidget *parent);
~Thumbnail();
QImage image() const;
@@ -38,7 +38,7 @@ public slots:
void setImage(const QImage &image);
private:
- Poppler::Page *m_pdfPage;
+ std::unique_ptr<Poppler::Page> m_pdfPage;
QImage m_image;
};
diff --git a/src/ViewerTab.cpp b/src/ViewerTab.cpp
index 5e75c4f..8f4f732 100644
--- a/src/ViewerTab.cpp
+++ b/src/ViewerTab.cpp
@@ -11,6 +11,7 @@
#include "ViewerTab.h"
+#include <QFile>
#include <QImage>
#include <QListWidget>
#include <QPainter>
@@ -77,7 +78,6 @@ void ViewerTab::valueChanged(int value)
ViewerTab::~ViewerTab()
{
- delete m_document;
}
@@ -129,8 +129,6 @@ int ViewerTab::load(const QUrl &url)
if (!m_document || m_document->isLocked()) {
KMessageBox::error(nullptr, i18n("Failed to create PDF from data."));
- delete m_document;
- m_document = nullptr;
return -1;
}
@@ -236,14 +234,8 @@ void ViewerTab::print()
{
QPrinter printer;
- QList<Poppler::Page *> pages;
-
int pageCount = m_document->numPages();
- for (int page = 0 ; page < pageCount ; ++page) {
- pages.append(m_document->page(page));
- }
-
printer.setFullPage(true);
printer.setPrintRange(QPrinter::AllPages);
printer.setFromTo(1, pageCount);
@@ -253,38 +245,27 @@ void ViewerTab::print()
if (printDialog->exec() == QDialog::Accepted) {
int fromPage = 1;
int toPage = pageCount;
+ int pageStep = 1;
if (printer.printRange() == QPrinter::PageRange) {
fromPage = printer.fromPage();
toPage = printer.toPage();
}
- while (toPage < pages.count()) pages.removeLast();
- while (--fromPage) pages.removeFirst();
+ pageCount = toPage - fromPage + 1;
- int pageCount = pages.count();
-
- QProgressDialog progress(this);
- progress.setWindowModality(Qt::WindowModal);
- progress.setRange(0, pageCount);
+ if (printer.pageOrder() == QPrinter::LastPageFirst) {
+ std::swap(fromPage, toPage);
+ pageStep = -1;
+ }
QPainter painter;
painter.begin(&printer);
- for (int page = 0 ; page < pageCount ; ++page) {
- if (progress.wasCanceled()) {
- printer.abort();
- return;
- }
-
- if (page > 0) {
- printer.newPage();
- }
-
- progress.setValue(page);
- progress.setLabelText(i18n("Printing page %1", page+1));
+ int page = fromPage;
- Poppler::Page *pdfPage = (printer.pageOrder() == QPrinter::FirstPageFirst)?pages.takeFirst():pages.takeLast();
+ for (int printPage = 0 ; printPage < pageCount ; page += pageStep) {
+ std::unique_ptr<Poppler::Page> pdfPage = m_document->page(page - 1);
if (pdfPage) {
QSizeF pageSize = pdfPage->pageSizeF(); // size in points 1/72 inch
@@ -301,11 +282,13 @@ void ViewerTab::print()
painter.drawImage(QRectF(QPointF(0, 0), scale * pdfPage->pageSizeF()), image);
}
+
+ if (++printPage < pageCount) {
+ printer.newPage();
+ }
}
painter.end();
-
- progress.setValue(pageCount);
}
delete printDialog;
diff --git a/src/ViewerTab.h b/src/ViewerTab.h
index e49606f..d8f55a2 100644
--- a/src/ViewerTab.h
+++ b/src/ViewerTab.h
@@ -18,7 +18,7 @@
#include <QTimer>
#include <QWidget>
-#include <poppler-qt5.h>
+#include <poppler-qt6.h>
#include "ui_ViewerTab.h"
@@ -57,7 +57,7 @@ protected:
private:
Ui::ViewerTab ui;
- Poppler::Document *m_document;
+ std::unique_ptr<Poppler::Document> m_document;
QByteArray m_pdfData;
QPixmap m_pixmap;
More information about the kde-doc-english
mailing list