Date: Tuesday, June 15, 2021 @ 13:51:13 Author: arodseth Revision: 963766
upgpkg: posterazor 1.9.7.pre-1 Added: posterazor/trunk/qt.patch posterazor/trunk/update.patch Modified: posterazor/trunk/PKGBUILD posterazor/trunk/posterazor.desktop --------------------+ PKGBUILD | 37 posterazor.desktop | 2 qt.patch | 21 update.patch | 2104 +++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 2150 insertions(+), 14 deletions(-) Modified: PKGBUILD =================================================================== --- PKGBUILD 2021-06-15 13:46:15 UTC (rev 963765) +++ PKGBUILD 2021-06-15 13:51:13 UTC (rev 963766) @@ -2,21 +2,34 @@ # Contributor: Alois Nespor <al...@artixlinux.org> pkgname=posterazor -pkgver=1.9.7 +# 1.9.7 is not yet released, but 1.9.6 does not compile. +# After applying patches, the "about" dialog shows "1.9.7". +pkgver=1.9.7.pre pkgrel=1 pkgdesc='Cut an image or PDF into pieces which can be printed and assembled to a poster' -arch=('x86_64') +arch=(x86_64) url='https://github.com/aportale/posterazor' -license=('GPL') -depends=('poppler-qt5') -makedepends=('git') -source=("git+$url#commit=e20bb7dd2af75aad2a72f9f8fcffef045abdd8cc" - 'posterazor.desktop' - 'posterazor.xpm') -sha256sums=('SKIP' - 'd393b99b5cc9122c3050fdf195e128d654557dbfa24ca911dc138178a18e528d' - 'dd23560b60950add8aec451d127e33f6c5a81824db4ed729bd7fc0f21f9f373d') +license=(GPL) +depends=(poppler-qt5) +makedepends=(git) +# branch PosteRazor_1_9_6 +source=("git+$url#commit=5ffc88db94451872da50fa3f2b526ca6c41dab1c" + posterazor.desktop + posterazor.xpm + qt.patch::https://github.com/aportale/posterazor/commit/004cf52db5ff79fe1a083277c743fea4ac2e8321.patch + update.patch) +b2sums=('SKIP' + '1f7e5c55fcf7864141927308e2d2c4081b31c894d73a97937ab7fb8b5da567e1c43882fb40f27dd1d078231afd704a5a5a261bbc1751f87300c3f46cdf5a4966' + 'b18ce8c67b02b8818596117ce9ae99852d2164e084d4a446d096501ff6bb7c0cc19aa0a0037b015a2c3897e9117ee0fd8d49f6f208cfb3e4af838f69e2b6f211' + '0f938dc23b3aae118b8a95a6e4fe63da005811d0484acd4a6e180335c29e74b0ed302379aef77875957be9e8d353cc19bf9ed700833fc60e23f79e4d3e213aae' + '12b14e86b3ad3c0e213c67995d647e83b8655663ac73a9aa52bad61268d843da67b28e0c0c247cdf1cd9b8203a5ece6b8571f83fff2f0e0a1758bc0c58101a82') +prepare() { + cd posterazor + patch -p1 -i ../update.patch + patch -p1 -i ../qt.patch +} + build() { cd posterazor/src qmake-qt5 \ @@ -34,5 +47,3 @@ install -Dm644 "$srcdir/posterazor.xpm" \ "$pkgdir/usr/share/icons/posterazor.xpm" } - -# vim: ts=2 sw=2 et: Modified: posterazor.desktop =================================================================== --- posterazor.desktop 2021-06-15 13:46:15 UTC (rev 963765) +++ posterazor.desktop 2021-06-15 13:51:13 UTC (rev 963766) @@ -1,7 +1,7 @@ [Desktop Entry] Name=PosteRazor Comment=Make your own poster! -Exec=posterazor +Exec=/usr/bin/posterazor Icon=/usr/share/icons/posterazor.xpm Terminal=false Type=Application Added: qt.patch =================================================================== --- qt.patch (rev 0) +++ qt.patch 2021-06-15 13:51:13 UTC (rev 963766) @@ -0,0 +1,21 @@ +From 004cf52db5ff79fe1a083277c743fea4ac2e8321 Mon Sep 17 00:00:00 2001 +From: Yevgeniy Filatov <itspec...@gmail.com> +Date: Sun, 28 Jun 2020 14:44:37 +0400 +Subject: [PATCH] Fixed compilation on Qt 5.15 + +--- + src/paintcanvas.cpp | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/paintcanvas.cpp b/src/paintcanvas.cpp +index 7d3abe25..b2d9d76a 100644 +--- a/src/paintcanvas.cpp ++++ b/src/paintcanvas.cpp +@@ -25,6 +25,7 @@ + #include <QImage> + #include <QPainter> + #include <QVariant> ++#include <QPainterPath> + + PaintCanvas::PaintCanvas(QWidget *parent) + : QWidget(parent) Added: update.patch =================================================================== --- update.patch (rev 0) +++ update.patch 2021-06-15 13:51:13 UTC (rev 963766) @@ -0,0 +1,2104 @@ +diff --git a/src/controller.cpp b/src/controller.cpp +index b332d9a..f0307fb 100644 +--- a/src/controller.cpp ++++ b/src/controller.cpp +@@ -1,6 +1,6 @@ + /* + PosteRazor - Make your own poster! +- Copyright (C) 2005-2009 by Alessandro Portale ++ Copyright (C) 2005-2018 by Alessandro Portale + http://posterazor.sourceforge.net/ + + This file is part of PosteRazor +@@ -23,15 +23,22 @@ + #include "controller.h" + #include "posterazorcore.h" + #include "wizardcontroller.h" ++ + #include <QAction> + #include <QCoreApplication> +-#include <QLocale> +-#include <QSettings> ++#include <QDesktopServices> + #include <QFileDialog> ++#include <QLocale> + #include <QMessageBox> +-#include <QUrl> +-#include <QDesktopServices> ++#include <QSettings> + #include <QTranslator> ++#include <QUrl> ++ ++#ifdef Q_OS_WASM ++#include <emscripten.h> ++#include <emscripten/html5.h> ++#include <QBuffer> ++#endif // Q_OS_WASM + + const QLatin1String settingsKey_LaunchPDFApplication("LaunchPDFApplication"); + const QLatin1String settingsKey_TranslationName("TranslationName"); +@@ -42,7 +49,6 @@ Controller::Controller(PosteRazorCore *posteRazorCore, QWidget *view, QObject *p + : QObject(parent) + , m_posteRazorCore(posteRazorCore) + , m_view(view) +- , m_launchPDFApplication(true) + { + connect(m_view, SIGNAL(paperFormatChanged(const QString&)), SLOT(setPaperFormat(const QString&))); + connect(m_view, SIGNAL(paperOrientationChanged(QPrinter::Orientation)), SLOT(setPaperOrientation(QPrinter::Orientation))); +@@ -110,21 +116,19 @@ Controller::Controller(PosteRazorCore *posteRazorCore, QWidget *view, QObject *p + {SIGNAL(setPosterSizeModeAvailableSignal(Types::PosterSizeModes, bool)), + SLOT(setPosterSizeModeAvailable(Types::PosterSizeModes, bool))} + }; +- static const int signalsToViewSlotsConnectionsCount = +- int(sizeof signalsToViewSlotsConnections / sizeof signalsToViewSlotsConnections[0]); +- for (int i = 0; i < signalsToViewSlotsConnectionsCount; ++i) { ++ for (auto &connection : signalsToViewSlotsConnections) { + const QByteArray slot( +- QMetaObject::normalizedSignature(signalsToViewSlotsConnections[i].slot + 1)); ++ QMetaObject::normalizedSignature(connection.slot + 1)); + // + 1: Remove slot flag '1' + if (m_view->metaObject()->indexOfSlot(slot) != -1) +- connect(this, signalsToViewSlotsConnections[i].signal, m_view, signalsToViewSlotsConnections[i].slot); ++ connect(this, connection.signal, m_view, connection.slot); + } + + m_wizardController = new WizardController(m_view, this); + + if (!m_posteRazorCore->imageIOLibraryAboutText().isEmpty()) { +- QAction *aboutAction = new QAction(m_view); +- aboutAction->setText(QLatin1String("A&bout ") + m_posteRazorCore->imageIOLibraryName()); ++ auto aboutAction = new QAction(m_view); ++ aboutAction->setText(QStringLiteral("A&bout ") + m_posteRazorCore->imageIOLibraryName()); + connect (aboutAction, SIGNAL(triggered()), SLOT(showExtraAboutDialog())); + emit addAboutDialogActionSignal(aboutAction); + } +@@ -413,7 +417,7 @@ void Controller::loadInputImage() + for (int i = 0; i < formats.count(); i++) { + QStringList formatWildcards; + foreach (const QString &extension, formats.at(i).first) +- formatWildcards << QLatin1String("*.") + extension; ++ formatWildcards << QStringLiteral("*.") + extension; + allWildcards << formatWildcards; + QString formatName = formats.at(i).second; + // Some Open File dialogs (at least OSX) ar irritated if there are brackes in the file type name +@@ -425,27 +429,34 @@ void Controller::loadInputImage() + + QSettings loadPathSettings; + +- QString loadFileName = QFileDialog::getOpenFileName ( +- m_view, +- QCoreApplication::translate("Main window", "Load an input image"), +- loadPathSettings.value(settingsKey_ImageLoadPath, +-#if QT_VERSION >= 0x050000 +- QStandardPaths::standardLocations(QStandardPaths::PicturesLocation).first() +-#elif QT_VERSION >= 0x040400 +- QDesktopServices::storageLocation(QDesktopServices::PicturesLocation) ++ const QString loadPathDefault = ++ QStandardPaths::standardLocations(QStandardPaths::PicturesLocation).constFirst(); ++#ifdef Q_OS_WASM ++ QFileDialog::getOpenFileContent(allFilters.join(QLatin1String(";;")), ++ [this](const QString &fileName, const QByteArray &fileContent) { ++ const QString previousFileName = m_posteRazorCore->fileName(); ++ const QString copyFileName = QLatin1String("/home/web_user/") + QFileInfo(fileName).fileName(); ++ ++ QFile imageFile(copyFileName); ++ if (imageFile.open(QIODevice::WriteOnly)) { ++ imageFile.write(fileContent); ++ imageFile.close(); ++ } ++ ++ if (handleInputImageSelected(copyFileName)) ++ QFile::remove(previousFileName); ++ else ++ QFile::remove(copyFileName); ++ }); + #else +- QLatin1String(".") +-#endif +- ).toString(), +- allFilters.join(QLatin1String(";;")) +- ); ++ const QString loadFileName = ++ QFileDialog::getOpenFileName(m_view, ++ QCoreApplication::translate("Main window", "Load an input image"), ++ loadPathSettings.value(settingsKey_ImageLoadPath, loadPathDefault).toString(), ++ allFilters.join(QLatin1String(";;"))); + +- if (!loadFileName.isEmpty()) { +- const bool successful = loadInputImage(loadFileName); +- if (successful) +- loadPathSettings.setValue(settingsKey_ImageLoadPath, +- QDir::toNativeSeparators(QFileInfo(loadFileName).absolutePath())); +- } ++ handleInputImageSelected(loadFileName); ++#endif // QT_OS_WASM + } + + bool Controller::loadInputImage(const QString &fileName) +@@ -471,29 +482,64 @@ bool Controller::loadInputImage(const QString &imageFileName, QString &errorMess + + int Controller::savePoster(const QString &fileName) const + { +- const int result = m_posteRazorCore->savePoster(fileName); ++#ifdef Q_OS_WASM ++ QByteArray posterData; ++ QBuffer outIODevice(&posterData); ++ outIODevice.open(QIODevice::WriteOnly); ++#else ++ QFile outIODevice(fileName); ++ if (!outIODevice.open((QIODevice::WriteOnly))) ++ return -1; ++#endif // Q_OS_WASM ++ ++ const int result = m_posteRazorCore->savePoster(&outIODevice); ++ ++#ifdef Q_OS_WASM ++ outIODevice.close(); ++ // Snippet borrowed from my dear colleague Morten: ++ // https://codereview.qt-project.org/c/qt/qtbase/+/228599 ++ EM_ASM_({ ++ // Make the file contents and file name hint accessible to Javascript: convert ++ // the char * to a JavaScript string and create a subarray view into the C heap. ++ const contentPointer = $0; ++ const contentLength = $1; ++ const fileNameHint = UTF8ToString($2); ++ const fileContent = Module.HEAPU8.subarray(contentPointer, contentPointer + contentLength); ++ ++ // Create a hidden download link and click it programatically ++ const fileblob = new Blob([fileContent], { type : "application/octet-stream" } ); ++ var link = document.createElement("a"); ++ document.body.appendChild(link); ++ link.download = fileNameHint; ++ link.href = window.URL.createObjectURL(fileblob); ++ link.style = "display:none"; ++ link.click(); ++ document.body.removeChild(link); ++ }, posterData.constData(), posterData.length(), fileName.toUtf8().constData()); ++#else + if (result == 0 && m_launchPDFApplication) + QDesktopServices::openUrl(QUrl::fromLocalFile(fileName)); ++#endif // Q_OS_WASM ++ + return result; + } + + void Controller::savePoster() const + { ++#ifdef Q_OS_WASM ++ savePoster(QFileInfo(m_posteRazorCore->fileName()).baseName() + QLatin1String(".pdf")); ++ return; ++#endif // Q_OS_WASM ++ + QSettings savePathSettings; + + QString saveFileName = savePathSettings.value(settingsKey_PosterSavePath, +-#if QT_VERSION >= 0x050000 +- QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation) +-#elif QT_VERSION >= 0x040400 +- QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation) +-#else +- "." +-#endif +- ).toString() + QDir::separator() +- + QFileInfo(m_posteRazorCore->fileName()).baseName() +- + QLatin1String("-") +- + QCoreApplication::translate("Main window", "poster") +- + QLatin1String(".pdf"); ++ QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation)).toString() ++ + QDir::separator() ++ + QFileInfo(m_posteRazorCore->fileName()).baseName() ++ + QLatin1String("-") ++ + QCoreApplication::translate("Main window", "poster") ++ + QLatin1String(".pdf"); + bool fileExistsAskUserForOverwrite = false; + + do { +@@ -502,7 +548,7 @@ void Controller::savePoster() const + QCoreApplication::translate("Main window", "Save the poster"), + saveFileName, + QLatin1String("Portable Document format (*.pdf)"), +- NULL, ++ nullptr, + QFileDialog::DontConfirmOverwrite + ); + +@@ -511,7 +557,7 @@ void Controller::savePoster() const + if (saveFileInfo.suffix().toLower() != QLatin1String("pdf")) + saveFileName.append(QLatin1String(".pdf")); + +- fileExistsAskUserForOverwrite = QFileInfo(saveFileName).exists(); ++ fileExistsAskUserForOverwrite = QFileInfo::exists(saveFileName); + + if (!fileExistsAskUserForOverwrite + || QMessageBox::Yes == (QMessageBox::question(m_view, QString(), QCoreApplication::translate("Main window", "The file '%1' already exists.\nDo you want to overwrite it?").arg(saveFileInfo.fileName()), QMessageBox::Yes, QMessageBox::No)) +@@ -564,10 +610,8 @@ void Controller::showExtraAboutDialog() + { + const QString title = QLatin1String("About ") + m_posteRazorCore->imageIOLibraryName(); + QMessageBox::about( +- m_view, title, +- QString::fromLatin1("<h3>%1</h3>%2") // QMessageBox::aboutQt() also uses <h3> +- .arg(title) +- .arg(Types::newlineToParagraph(m_posteRazorCore->imageIOLibraryAboutText())) ++ m_view, title, QStringLiteral("<h3>%1</h3>%2") ++ .arg(title, Types::newlineToParagraph(m_posteRazorCore->imageIOLibraryAboutText())) + ); + } + +@@ -582,3 +626,19 @@ void Controller::imageSuffixSupported(const QString &suffix, bool &outIsSupporte + } + } + } ++ ++bool Controller::handleInputImageSelected(const QString &fileName) ++{ ++ bool successful = false; ++ ++ if (!fileName.isEmpty()) { ++ successful = loadInputImage(fileName); ++ if (successful) { ++ QSettings loadPathSettings; ++ loadPathSettings.setValue(settingsKey_ImageLoadPath, ++ QDir::toNativeSeparators(QFileInfo(fileName).absolutePath())); ++ } ++ } ++ ++ return successful; ++} +diff --git a/src/controller.h b/src/controller.h +index 73c6059..3c436be 100644 +--- a/src/controller.h ++++ b/src/controller.h +@@ -1,6 +1,6 @@ + /* + PosteRazor - Make your own poster! +- Copyright (C) 2005-2009 by Alessandro Portale ++ Copyright (C) 2005-2018 by Alessandro Portale + http://posterazor.sourceforge.net/ + + This file is part of PosteRazor +@@ -20,8 +20,7 @@ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef CONTROLLER_H +-#define CONTROLLER_H ++#pragma once + + #include "types.h" + #include <QObject> +@@ -40,7 +39,7 @@ class Controller: public QObject + Q_OBJECT + + public: +- Controller(PosteRazorCore *posteRazorCore, QWidget *view, QObject *parent = 0); ++ Controller(PosteRazorCore *posteRazorCore, QWidget *view, QObject *parent = nullptr); + + void updateDialog(); + void updatePreview(); +@@ -123,11 +122,11 @@ private slots: + void imageSuffixSupported(const QString &suffix, bool &outIsSupported) const; + + protected: +- PosteRazorCore *m_posteRazorCore; +- QWidget *m_view; +- bool m_launchPDFApplication; +- WizardController *m_wizardController; +- QTranslator *m_translator; ++ PosteRazorCore *m_posteRazorCore = nullptr; ++ QWidget *m_view = nullptr; ++ bool m_launchPDFApplication = true; ++ WizardController *m_wizardController = nullptr; ++ QTranslator *m_translator = nullptr; + QString m_translationName; + + void setDialogSaveOptions(); +@@ -140,6 +139,5 @@ protected: + void setDialogImageInfoFields(); + void setDialogOverlappingDimensions(); + void setDialogOverlappingOptions(); ++ bool handleInputImageSelected(const QString &fileName); + }; +- +-#endif // CONTROLLER_H +diff --git a/src/imageloaderfreeimage.cpp b/src/imageloaderfreeimage.cpp +index 44d6699..157fb6d 100644 +--- a/src/imageloaderfreeimage.cpp ++++ b/src/imageloaderfreeimage.cpp +@@ -1,6 +1,6 @@ + /* + PosteRazor - Make your own poster! +- Copyright (C) 2005-2009 by Alessandro Portale ++ Copyright (C) 2005-2018 by Alessandro Portale + http://posterazor.sourceforge.net/ + + This file is part of PosteRazor +@@ -22,10 +22,12 @@ + + #include "FreeImage.h" + #include "imageloaderfreeimage.h" +-#include <qendian.h> +-#include <QStringList> ++ + #include <QColor> +-#include <math.h> ++#include <QStringList> ++#include <qendian.h> ++ ++#include <cmath> + + static QString FreeImageErrorMessage; + +@@ -52,11 +54,6 @@ public: + + ImageLoaderFreeImage::ImageLoaderFreeImage(QObject *parent) + : QObject(parent) +- , m_bitmap(NULL) +- , m_widthPixels(0) +- , m_heightPixels(0) +- , m_horizontalDotsPerMeter(0) +- , m_verticalDotsPerMeter(0) + { + const static FreeImageInitializer initializer; + } +@@ -70,7 +67,7 @@ void ImageLoaderFreeImage::disposeImage() + { + if (m_bitmap) { + FreeImage_Unload(m_bitmap); +- m_bitmap = NULL; ++ m_bitmap = nullptr; + } + } + +@@ -92,7 +89,7 @@ bool ImageLoaderFreeImage::loadInputImage(const QString &imageFileName, QString + && type != FIT_RGB16 // 16bpp Greyscale, 48bpp Rgb + ) { + FreeImage_Unload(newImage); +- newImage = NULL; ++ newImage = nullptr; + } + } + +@@ -131,7 +128,7 @@ bool ImageLoaderFreeImage::loadInputImage(const QString &imageFileName, QString + + bool ImageLoaderFreeImage::isImageLoaded() const + { +- return (m_bitmap != NULL); ++ return (m_bitmap != nullptr); + } + + bool ImageLoaderFreeImage::isJpeg() const +@@ -177,8 +174,8 @@ const QImage ImageLoaderFreeImage::imageAsRGB(const QSize &size) const + const QSize sizePixels = this->sizePixels(); + + FIBITMAP* originalImage = m_bitmap; +- FIBITMAP* temp24BPPImage = NULL; +- FIBITMAP* scaledImage = NULL; ++ FIBITMAP* temp24BPPImage = nullptr; ++ FIBITMAP* scaledImage = nullptr; + + if (!(isRGB24 || isARGB32)) { + if (colorDataType() == Types::ColorTypeCMYK) { +@@ -272,7 +269,7 @@ const QByteArray ImageLoaderFreeImage::bits() const + char *destination = result.data(); + FreeImage_ConvertToRawBits((BYTE*)destination, m_bitmap, bytesPerLine, bitsPerPixel(), FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK, hasFreeImageVersionCorrectTopDownInConvertBits()); + +- const unsigned long numberOfPixels = m_widthPixels * m_heightPixels; ++ const unsigned int numberOfPixels = m_widthPixels * m_heightPixels; + #if FREEIMAGE_COLORORDER == FREEIMAGE_COLORORDER_BGR + if (colorDataType() == Types::ColorTypeRGB && bitsPerPixel() == 24) { + for (unsigned int pixelIndex = 0; pixelIndex < numberOfPixels; pixelIndex++) { +@@ -283,7 +280,7 @@ const QByteArray ImageLoaderFreeImage::bits() const + pixelPtr+=3; + } + } else if (colorDataType() == Types::ColorTypeRGBA && bitsPerPixel() == 32) { +- unsigned int* argbDestination = (unsigned int*)destination; ++ auto argbDestination = (unsigned int*)destination; + for (unsigned int pixelIndex = 0; pixelIndex < numberOfPixels; pixelIndex++) { + *argbDestination = qToBigEndian(*argbDestination); + argbDestination++; +@@ -293,7 +290,7 @@ const QByteArray ImageLoaderFreeImage::bits() const + if (colorDataType() == Types::ColorTypeRGB && bitsPerPixel() == 48) { + // Apparently, the 48 bit data has to be reordered on Windows and ppc/i386 OSX + // TODO: So maybe this swap belongs into the PDFwriter. Investigate. +- unsigned short* rgb48Destination = (unsigned short*)destination; ++ auto rgb48Destination = (unsigned short*)destination; + const unsigned long numberOfSwaps = numberOfPixels * 3; // Words are swapped + for (unsigned int pixelIndex = 0; pixelIndex < numberOfSwaps; pixelIndex++) { + *rgb48Destination = qToBigEndian(*rgb48Destination); +diff --git a/src/imageloaderfreeimage.h b/src/imageloaderfreeimage.h +index bf705c7..647f79b 100644 +--- a/src/imageloaderfreeimage.h ++++ b/src/imageloaderfreeimage.h +@@ -1,6 +1,6 @@ + /* + PosteRazor - Make your own poster! +- Copyright (C) 2005-2009 by Alessandro Portale ++ Copyright (C) 2005-2018 by Alessandro Portale + http://posterazor.sourceforge.net/ + + This file is part of PosteRazor +@@ -20,8 +20,7 @@ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef IMAGELOADERFREEIMAGE_H +-#define IMAGELOADERFREEIMAGE_H ++#pragma once + + #include "imageloaderinterface.h" + +@@ -30,36 +29,34 @@ struct FIBITMAP; + class ImageLoaderFreeImage: public QObject, public ImageLoaderInterface + { + public: +- ImageLoaderFreeImage(QObject *parent = 0); +- ~ImageLoaderFreeImage(); +- +- bool loadInputImage(const QString &imageFileName, QString &errorMessage); +- bool isImageLoaded() const; +- bool isJpeg() const; +- QString fileName() const; +- QSize sizePixels() const; +- qreal horizontalDotsPerUnitOfLength(Types::UnitsOfLength unit) const; +- qreal verticalDotsPerUnitOfLength(Types::UnitsOfLength unit) const; +- QSizeF size(Types::UnitsOfLength unit) const; +- const QImage imageAsRGB(const QSize &size) const; +- int bitsPerPixel() const; +- Types::ColorTypes colorDataType() const; +- const QByteArray bits() const; +- const QVector<QRgb> colorTable() const; +- const QVector<QPair<QStringList, QString> > &imageFormats() const; +- QString libraryName() const; +- QString libraryAboutText() const; ++ ImageLoaderFreeImage(QObject *parent = nullptr); ++ ~ImageLoaderFreeImage() override; ++ ++ bool loadInputImage(const QString &imageFileName, QString &errorMessage) override; ++ bool isImageLoaded() const override; ++ bool isJpeg() const override; ++ QString fileName() const override; ++ QSize sizePixels() const override; ++ qreal horizontalDotsPerUnitOfLength(Types::UnitsOfLength unit) const override; ++ qreal verticalDotsPerUnitOfLength(Types::UnitsOfLength unit) const override; ++ QSizeF size(Types::UnitsOfLength unit) const override; ++ const QImage imageAsRGB(const QSize &size) const override; ++ int bitsPerPixel() const override; ++ Types::ColorTypes colorDataType() const override; ++ const QByteArray bits() const override; ++ const QVector<QRgb> colorTable() const override; ++ const QVector<QPair<QStringList, QString> > &imageFormats() const override; ++ QString libraryName() const override; ++ QString libraryAboutText() const override; + + private: +- FIBITMAP* m_bitmap; +- int m_widthPixels; +- int m_heightPixels; +- unsigned int m_horizontalDotsPerMeter; +- unsigned int m_verticalDotsPerMeter; +- QString m_imageFileName; ++ FIBITMAP* m_bitmap = nullptr; ++ int m_widthPixels = 0; ++ int m_heightPixels = 0; ++ unsigned int m_horizontalDotsPerMeter = 0; ++ unsigned int m_verticalDotsPerMeter = 0; ++ QString m_imageFileName; + + void disposeImage(); + static bool hasFreeImageVersionCorrectTopDownInConvertBits(); + }; +- +-#endif // IMAGELOADERFREEIMAGE_H +diff --git a/src/imageloaderinterface.h b/src/imageloaderinterface.h +index 18e7848..419aafb 100644 +--- a/src/imageloaderinterface.h ++++ b/src/imageloaderinterface.h +@@ -1,6 +1,6 @@ + /* + PosteRazor - Make your own poster! +- Copyright (C) 2005-2009 by Alessandro Portale ++ Copyright (C) 2005-2018 by Alessandro Portale + http://posterazor.sourceforge.net/ + + This file is part of PosteRazor +@@ -20,8 +20,7 @@ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef IMAGELOADERINTERFACE_H +-#define IMAGELOADERINTERFACE_H ++#pragma once + + #include "types.h" + #include <QImage> +@@ -33,7 +32,7 @@ QT_END_NAMESPACE + class ImageLoaderInterface + { + public: +- virtual ~ImageLoaderInterface() {} ++ virtual ~ImageLoaderInterface() = default; + + virtual bool loadInputImage(const QString &imageFileName, QString &errorMessage) = 0; + virtual bool isImageLoaded() const = 0; +@@ -52,5 +51,3 @@ public: + virtual QString libraryName() const = 0; + virtual QString libraryAboutText() const = 0; + }; +- +-#endif // IMAGELOADERINTERFACE_H +diff --git a/src/imageloaderqt.cpp b/src/imageloaderqt.cpp +index ec53caa..0f4c53f 100644 +--- a/src/imageloaderqt.cpp ++++ b/src/imageloaderqt.cpp +@@ -1,6 +1,6 @@ + /* + PosteRazor - Make your own poster! +- Copyright (C) 2005-2009 by Alessandro Portale ++ Copyright (C) 2005-2018 by Alessandro Portale + http://posterazor.sourceforge.net/ + + This file is part of PosteRazor +@@ -21,11 +21,12 @@ + */ + + #include "imageloaderqt.h" ++ + #include <QImageReader> + #ifdef POPPLER_QT5_LIB + #include <poppler-qt5.h> + #endif +-#include <math.h> ++#include <cmath> + + ImageLoaderQt::ImageLoaderQt(QObject *parent) + : QObject(parent) +@@ -51,7 +52,7 @@ bool ImageLoaderQt::loadPdf(const QString &imageFileName, QString &errorMessage) + + // FIXME: Allow user to select page (currrently hard-wired to first page). + Poppler::Page* pdfPage = document->page(0); // Document starts at page 0 +- if (pdfPage == 0) ++ if (pdfPage == nullptr) + return false; + + // FIXME: Don't hard-wire the resolution, and display correct resolution! +@@ -114,7 +115,10 @@ qreal ImageLoaderQt::verticalDotsPerUnitOfLength(Types::UnitsOfLength unit) cons + QSizeF ImageLoaderQt::size(Types::UnitsOfLength unit) const + { + const QSize sizePixels = this->sizePixels(); +- return QSizeF(sizePixels.width() / horizontalDotsPerUnitOfLength(unit), sizePixels.height() / verticalDotsPerUnitOfLength(unit)); ++ return { ++ sizePixels.width() / horizontalDotsPerUnitOfLength(unit), ++ sizePixels.height() / verticalDotsPerUnitOfLength(unit) ++ }; + } + + const QImage ImageLoaderQt::imageAsRGB(const QSize &size) const +@@ -212,17 +216,16 @@ const QVector<QPair<QStringList, QString> > &ImageLoaderQt::imageFormats() const + {QLatin1String("xbm"), QLatin1String("X11 Bitmap")}, + {QLatin1String("xpm"), QLatin1String("X11 Pixmap")} + }; +- const int extensionListCount = int(sizeof extensionList / sizeof extensionList[0]); + const QList<QByteArray> supportedFormats = QImageReader::supportedImageFormats(); +- for (int i = 0; i < extensionListCount; i++) { +- QStringList extensions = extensionList[i].extensions.split(QLatin1Char(' ')); ++ for (auto &format : extensionList) { ++ QStringList extensions = format.extensions.split(QLatin1Char(' ')); + foreach (const QString &extension, extensions) + if (supportedFormats.contains(extension.toLatin1()) + #ifdef POPPLER_QT5_LIB + || (extension.toLatin1() == "pdf") + #endif + ) { +- formats.append(QPair<QStringList, QString> (extensions, extensionList[i].description)); ++ formats.append({extensions, format.description}); + break; + } + } +diff --git a/src/imageloaderqt.h b/src/imageloaderqt.h +index 2dbedab..c7a11a7 100644 +--- a/src/imageloaderqt.h ++++ b/src/imageloaderqt.h +@@ -1,6 +1,6 @@ + /* + PosteRazor - Make your own poster! +- Copyright (C) 2005-2009 by Alessandro Portale ++ Copyright (C) 2005-2018 by Alessandro Portale + http://posterazor.sourceforge.net/ + + This file is part of PosteRazor +@@ -20,8 +20,7 @@ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef IMAGELOADERQT_H +-#define IMAGELOADERQT_H ++#pragma once + + #include "imageloaderinterface.h" + #include <QObject> +@@ -29,25 +28,25 @@ + class ImageLoaderQt: public QObject, public ImageLoaderInterface + { + public: +- ImageLoaderQt(QObject *parent = 0); +- +- bool loadInputImage(const QString &imageFileName, QString &errorMessage); +- bool isImageLoaded() const; +- bool isJpeg() const; +- QString fileName() const; +- QSize sizePixels() const; +- qreal horizontalDotsPerUnitOfLength(Types::UnitsOfLength unit) const; +- qreal verticalDotsPerUnitOfLength(Types::UnitsOfLength unit) const; +- QSizeF size(Types::UnitsOfLength unit) const; +- const QImage imageAsRGB(const QSize &size) const; +- int bitsPerPixel() const; +- Types::ColorTypes colorDataType() const; ++ ImageLoaderQt(QObject *parent = nullptr); ++ ++ bool loadInputImage(const QString &imageFileName, QString &errorMessage) override; ++ bool isImageLoaded() const override; ++ bool isJpeg() const override; ++ QString fileName() const override; ++ QSize sizePixels() const override; ++ qreal horizontalDotsPerUnitOfLength(Types::UnitsOfLength unit) const override; ++ qreal verticalDotsPerUnitOfLength(Types::UnitsOfLength unit) const override; ++ QSizeF size(Types::UnitsOfLength unit) const override; ++ const QImage imageAsRGB(const QSize &size) const override; ++ int bitsPerPixel() const override; ++ Types::ColorTypes colorDataType() const override; + int savePoster(const QString &fileName, const PainterInterface *painter, int pagesCount, const QSizeF &sizeCm) const; +- const QByteArray bits() const; +- const QVector<QRgb> colorTable() const; +- const QVector<QPair<QStringList, QString> > &imageFormats() const; +- QString libraryName() const; +- QString libraryAboutText() const; ++ const QByteArray bits() const override; ++ const QVector<QRgb> colorTable() const override; ++ const QVector<QPair<QStringList, QString> > &imageFormats() const override; ++ QString libraryName() const override; ++ QString libraryAboutText() const override; + + void setQImage(const QImage &image); + +@@ -59,5 +58,3 @@ private: + QImage m_image; + QString m_imageFileName; + }; +- +-#endif // IMAGELOADERQT_H +diff --git a/src/main.cpp b/src/main.cpp +index f509461..fdafc5a 100644 +--- a/src/main.cpp ++++ b/src/main.cpp +@@ -1,6 +1,6 @@ + /* + PosteRazor - Make your own poster! +- Copyright (C) 2005-2009 by Alessandro Portale ++ Copyright (C) 2005-2018 by Alessandro Portale + http://posterazor.sourceforge.net/ + + This file is part of PosteRazor +@@ -20,8 +20,8 @@ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#include "mainwindow.h" + #include "controller.h" ++#include "mainwindow.h" + #include "posterazorcore.h" + #if defined (FREEIMAGE_LIB) + # include "imageloaderfreeimage.h" +@@ -31,12 +31,6 @@ + + #include <QtGui> + +-#if !defined(QT_SHARED) && !defined(QT_DLL) && !defined(FREEIMAGE_LIB) +-Q_IMPORT_PLUGIN(qgif) +-Q_IMPORT_PLUGIN(qjpeg) +-Q_IMPORT_PLUGIN(qtiff) +-#endif +- + int main (int argc, char **argv) + { + QApplication a(argc, argv); +@@ -73,9 +67,7 @@ int main (int argc, char **argv) + #else + + QCoreApplication::setApplicationName(QLatin1String("PosteRazor")); +-#if QT_VERSION >= 0x040400 +- QCoreApplication::setApplicationVersion(QLatin1String("1.9.5")); +-#endif ++ QCoreApplication::setApplicationVersion(QLatin1String("1.9.7")); + QCoreApplication::setOrganizationName(QLatin1String("CasaPortale")); + QCoreApplication::setOrganizationDomain(QLatin1String("de.casaportale")); + +@@ -106,6 +98,8 @@ int main (int argc, char **argv) + dialog.writeSettings(&settings); + controller.writeSettings(&settings); + ++ qDebug() << "supportedImageFormats" << QImageWriter::supportedImageFormats(); ++ + return appReturn; + #endif + } +diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp +index 818cdd0..66c60b2 100644 +--- a/src/mainwindow.cpp ++++ b/src/mainwindow.cpp +@@ -1,6 +1,6 @@ + /* + PosteRazor - Make your own poster! +- Copyright (C) 2005-2009 by Alessandro Portale ++ Copyright (C) 2005-2018 by Alessandro Portale + http://posterazor.sourceforge.net/ + + This file is part of PosteRazor +@@ -21,19 +21,20 @@ + */ + + #include "mainwindow.h" +-#include <QSignalMapper> +-#include <QFileDialog> +-#include <QTranslator> +-#include <QtDebug> +-#include <QVBoxLayout> ++ + #include <QDialogButtonBox> +-#include <QTextBrowser> +-#include <QMessageBox> +-#include <QSettings> +-#include <QMetaMethod> + #include <QDragEnterEvent> + #include <QDropEvent> ++#include <QFileDialog> ++#include <QMessageBox> ++#include <QMetaMethod> + #include <QMimeData> ++#include <QSettings> ++#include <QSignalMapper> ++#include <QTextBrowser> ++#include <QTranslator> ++#include <QVBoxLayout> ++#include <QtDebug> + + const QLatin1String settingsKey_MainWindowGeometry("MainWindowGeometry"); + +@@ -41,10 +42,7 @@ static QString applicationNameWithVersion() + { + return + QCoreApplication::applicationName() +-#if QT_VERSION >= 0x040400 +- + QLatin1Char(' ') + QCoreApplication::applicationVersion() +-#endif +- ; ++ + QLatin1Char(' ') + QCoreApplication::applicationVersion() ; + } + + MainWindow::MainWindow(QWidget *parent) +@@ -84,7 +82,7 @@ void MainWindow::dragEnterEvent(QDragEnterEvent *event) + { + const QMimeData *mimeData = event->mimeData(); + if (mimeData->hasUrls()) { +- const QUrl url = mimeData->urls().first(); ++ const QUrl url = mimeData->urls().constFirst(); + const QString localFile = url.toLocalFile(); + const QString fileSuffix = QFileInfo(localFile).suffix(); + bool suffixIsSupported = false; +@@ -225,8 +223,7 @@ void MainWindow::updateImageInfoFields(const QSize &inputImageSizeInPixels, cons + + void MainWindow::setCurrentTranslation(const QString &translation) + { +- QAction *translationAction = NULL; +- translationAction = m_translationActions.value(translation); ++ QAction *translationAction = m_translationActions.value(translation); + if (!translationAction) { + // On a Swiss system 'translation' may be "de_CH". So let's fall back to "de" + const QString translationLanguage = translation.split(QLatin1Char('_')).first(); +@@ -314,7 +311,7 @@ void MainWindow::showManual(const QString &title, const QString &text) + dialog->setWindowFlags(dialog->windowFlags() ^ Qt::WindowContextHelpButtonHint); + dialog->resize(500, 400); + dialog->setLayout(new QVBoxLayout); +- QTextBrowser *browser = new QTextBrowser; ++ auto browser = new QTextBrowser; + browser->setOpenExternalLinks(true); + browser->document()->setDefaultStyleSheet(QLatin1String( + "dt {font-weight: bold;}" +@@ -324,7 +321,7 @@ void MainWindow::showManual(const QString &title, const QString &text) + "h2 {margin-top: 18px; margin-bottom: 6px;}")); + browser->setHtml(text); + dialog->layout()->addWidget(browser); +- QDialogButtonBox *buttonBox = new QDialogButtonBox; ++ auto buttonBox = new QDialogButtonBox; + buttonBox->setStandardButtons(QDialogButtonBox::Ok); + connect(buttonBox, SIGNAL(accepted ()), dialog, SLOT(accept())); + dialog->layout()->addWidget(buttonBox); +@@ -380,9 +377,8 @@ void MainWindow::createConnections() + SIGNAL(needsPaint(PaintCanvasInterface*, const QVariant&)), + SIGNAL(imageLoaded()), + }; +- static const int relayedSignalsCount = int(sizeof relayedSignals / sizeof relayedSignals[0]); +- for (int i = 0; i < relayedSignalsCount; ++i) +- connect(m_wizard, relayedSignals[i], relayedSignals[i]); ++ for (auto signal : relayedSignals) ++ connect(m_wizard, signal, signal); + } + + void MainWindow::populateUI() +@@ -399,7 +395,7 @@ void MainWindow::populateUI() + + m_menuSettings->addSeparator(); + +- QActionGroup *translationActions = new QActionGroup(m_menuSettings); ++ auto translationActions = new QActionGroup(m_menuSettings); + connect (translationActions, SIGNAL(triggered(QAction*)), SLOT(handleTranslationAction(QAction*))); + translationActions->setExclusive(true); + const QDir translationDir(QLatin1String(":/Translations/")); +@@ -463,7 +459,7 @@ void MainWindow::showAboutPosteRazorDialog() + QLatin1String("<h2>License</h2>" + "<p>PosteRazor - Make your own poster!<br/>" + "posterazor.sourceforge.net<br/>" +- "Copyright (C) 2005-2009 by Alessandro Portale</p>" ++ "Copyright (C) 2005-2018 by Alessandro Portale</p>" + "<p>This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.</p>" + "<p>This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.</p>" + "<p>You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.</p>"); +diff --git a/src/mainwindow.h b/src/mainwindow.h +index e7bcf97..607ca0f 100644 +--- a/src/mainwindow.h ++++ b/src/mainwindow.h +@@ -1,6 +1,6 @@ + /* + PosteRazor - Make your own poster! +- Copyright (C) 2005-2009 by Alessandro Portale ++ Copyright (C) 2005-2018 by Alessandro Portale + http://posterazor.sourceforge.net/ + + This file is part of PosteRazor +@@ -20,8 +20,7 @@ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef MAINWINDOW_H +-#define MAINWINDOW_H ++#pragma once + + #include "ui_mainwindow.h" + +@@ -36,13 +35,13 @@ class MainWindow : public QMainWindow, private Ui::MainWindow + Q_OBJECT + + public: +- MainWindow(QWidget *parent = 0); ++ MainWindow(QWidget *parent = nullptr); + + void retranslateUi(); + void retranslateUiWithDimensionUnit(); +- void changeEvent(QEvent *event); +- void dragEnterEvent(QDragEnterEvent *event); +- void dropEvent(QDropEvent *event); ++ void changeEvent(QEvent *event) override; ++ void dragEnterEvent(QDragEnterEvent *event) override; ++ void dropEvent(QDropEvent *event) override; + + public slots: + void setPaperFormat(const QString &format); +@@ -83,9 +82,9 @@ public slots: + void showManual(const QString &title, const QString &text); + + private: +- PosteRazorCore *m_posteRazor; ++ PosteRazorCore *m_posteRazor = nullptr; + QString m_currentUnitOfLength; +- QActionGroup *m_unitOfLengthActions; ++ QActionGroup *m_unitOfLengthActions = nullptr; + QHash<QString, QAction*> m_translationActions; + + void createConnections(); +@@ -132,5 +131,3 @@ private slots: + void showAboutQtDialog() const; + void showAboutPosteRazorDialog(); + }; +- +-#endif // MAINWINDOW_H +diff --git a/src/paintcanvas.cpp b/src/paintcanvas.cpp +index 8a4bc0b..7d3abe2 100644 +--- a/src/paintcanvas.cpp ++++ b/src/paintcanvas.cpp +@@ -1,6 +1,6 @@ + /* + PosteRazor - Make your own poster! +- Copyright (C) 2005-2009 by Alessandro Portale ++ Copyright (C) 2005-2018 by Alessandro Portale + http://posterazor.sourceforge.net/ + + This file is part of PosteRazor +@@ -21,13 +21,13 @@ + */ + + #include "paintcanvas.h" ++ + #include <QImage> + #include <QPainter> + #include <QVariant> + + PaintCanvas::PaintCanvas(QWidget *parent) + : QWidget(parent) +- , m_qPainter(NULL) + , m_state(QLatin1String("image")) + { + } +@@ -39,7 +39,7 @@ void PaintCanvas::paintEvent(QPaintEvent *event) + m_qPainter = &painter; + m_qPainter->setRenderHint(QPainter::Antialiasing); + emit needsPaint(this, m_state); +- m_qPainter = NULL; ++ m_qPainter = nullptr; + } + + void PaintCanvas::drawFilledRect(const QRectF &rect, const QBrush &brush) +diff --git a/src/paintcanvas.h b/src/paintcanvas.h +index a848c69..92ba3bc 100644 +--- a/src/paintcanvas.h ++++ b/src/paintcanvas.h +@@ -1,6 +1,6 @@ + /* + PosteRazor - Make your own poster! +- Copyright (C) 2005-2009 by Alessandro Portale ++ Copyright (C) 2005-2018 by Alessandro Portale + http://posterazor.sourceforge.net/ + + This file is part of PosteRazor +@@ -20,8 +20,7 @@ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef PAINTCANVAS_H +-#define PAINTCANVAS_H ++#pragma once + + #include <QWidget> + #include "paintcanvasinterface.h" +@@ -37,18 +36,18 @@ class PaintCanvas: public QWidget, public PaintCanvasInterface + + private: + QImage m_image; +- QPainter *m_qPainter; ++ QPainter *m_qPainter = nullptr; + QString m_state; + + public: + PaintCanvas(QWidget *parent); + +- void paintEvent(QPaintEvent *event); +- void drawFilledRect(const QRectF &rect, const QBrush &brush); +- QSizeF size() const; +- void drawImage(const QRectF &rect); ++ void paintEvent(QPaintEvent *event) override; ++ void drawFilledRect(const QRectF &rect, const QBrush &brush) override; ++ QSizeF size() const override; ++ void drawImage(const QRectF &rect) override; + void setState(const QString &state); +- void drawOverlayText(const QPointF &position, int flags, int size, const QString &text); ++ void drawOverlayText(const QPointF &position, int flags, int size, const QString &text) override; + + public slots: + void setImage(const QImage &image); +@@ -56,5 +55,3 @@ public slots: + signals: + void needsPaint(PaintCanvasInterface *paintDevice, const QVariant &options) const; + }; +- +-#endif // PAINTCANVAS_H +diff --git a/src/paintcanvasinterface.h b/src/paintcanvasinterface.h +index c0c88c1..d625ecd 100644 +--- a/src/paintcanvasinterface.h ++++ b/src/paintcanvasinterface.h +@@ -1,6 +1,6 @@ + /* + PosteRazor - Make your own poster! +- Copyright (C) 2005-2009 by Alessandro Portale ++ Copyright (C) 2005-2018 by Alessandro Portale + http://posterazor.sourceforge.net/ + + This file is part of PosteRazor +@@ -20,8 +20,7 @@ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef PAINTCANVASINTERFACE_H +-#define PAINTCANVASINTERFACE_H ++#pragma once + + #include <QBrush> + #include <QSizeF> +@@ -30,12 +29,10 @@ + class PaintCanvasInterface + { + public: +- virtual ~PaintCanvasInterface() {} ++ virtual ~PaintCanvasInterface() = default; + + virtual void drawFilledRect(const QRectF &rect, const QBrush &brush) = 0; + virtual QSizeF size() const = 0; + virtual void drawImage(const QRectF &rect) = 0; + virtual void drawOverlayText(const QPointF &position, int flags, int size, const QString &text) = 0; + }; +- +-#endif // PAINTCANVASINTERFACE_H +diff --git a/src/pdfwriter.cpp b/src/pdfwriter.cpp +index 863517f..057e89e 100644 +--- a/src/pdfwriter.cpp ++++ b/src/pdfwriter.cpp +@@ -1,6 +1,6 @@ + /* + PosteRazor - Make your own poster! +- Copyright (C) 2005-2009 by Alessandro Portale ++ Copyright (C) 2005-2018 by Alessandro Portale + http://posterazor.sourceforge.net/ + + This file is part of PosteRazor +@@ -22,11 +22,13 @@ + + #include "paintcanvasinterface.h" + #include "pdfwriter.h" +-#include <QRectF> ++ + #include <QBrush> ++#include <QDateTime> + #include <QFile> + #include <QFileInfo> +-#include <QDateTime> ++#include <QRectF> ++ + #define LINEFEED "\x0A" + + const int valuePrecision = 4; +@@ -40,14 +42,6 @@ static qreal cm2Pt(qreal cm) + + PDFWriter::PDFWriter(QObject *parent) + : QObject(parent) +- , m_outputFile(NULL) +- , m_pdfObjectCount(0) +- , m_objectPagesID(0) +- , m_firstPageID(5) // will be ++ed if the image has a SMask +- , m_objectResourcesID(0) +- , m_objectImageID(0) +- , m_mediaboxWidth(5000.0) +- , m_mediaboxHeight(5000.0) + { + } + +@@ -349,22 +343,17 @@ int PDFWriter::finishPage() + return err; + } + +-int PDFWriter::startSaving(const QString &fileName, int pages, qreal widthCm, qreal heightCm) ++int PDFWriter::startSaving(QIODevice *outputDevice, int pages, qreal widthCm, qreal heightCm) + { + int err = 0; + + m_mediaboxWidth = cm2Pt(widthCm); + m_mediaboxHeight = cm2Pt(heightCm); + +- if (m_outputFile) { +- m_outputFile->close(); +- delete m_outputFile; +- } +- m_outputFile = new QFile(fileName, this); +- if (!m_outputFile->open(QIODevice::WriteOnly)) +- return 1; ++ if (m_outStream.device()) ++ m_outStream.device()->close(); + +- m_outStream.setDevice(m_outputFile); ++ m_outStream.setDevice(outputDevice); + m_contentPagesCount = pages; + m_xref.clear(); + m_outStream << "%PDF-1.3" LINEFEED +@@ -451,7 +440,7 @@ void PDFWriter::drawFilledRect(const QRectF& rect, const QBrush &brush) + + QSizeF PDFWriter::size() const + { +- return QSizeF(); ++ return {}; + } + + void PDFWriter::drawImage(const QRectF &rect) +diff --git a/src/pdfwriter.h b/src/pdfwriter.h +index c0d6d8b..a6f379c 100644 +--- a/src/pdfwriter.h ++++ b/src/pdfwriter.h +@@ -1,6 +1,6 @@ + /* + PosteRazor - Make your own poster! +- Copyright (C) 2005-2009 by Alessandro Portale ++ Copyright (C) 2005-2018 by Alessandro Portale + http://posterazor.sourceforge.net/ + + This file is part of PosteRazor +@@ -20,22 +20,17 @@ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef PDFWRITER_H +-#define PDFWRITER_H ++#pragma once + + #include "types.h" + #include "paintcanvasinterface.h" + #include <QRgb> + #include <QTextStream> + +-QT_BEGIN_NAMESPACE +-class QFile; +-QT_END_NAMESPACE +- + class PDFWriter: public QObject, public PaintCanvasInterface + { + public: +- PDFWriter(QObject *parent = 0); ++ PDFWriter(QObject *parent = nullptr); + + void addOffsetToXref(); + int addImageResourcesAndXObject(); +@@ -43,26 +38,23 @@ public: + int saveImage(const QByteArray &imageData, const QSize &sizePixels, int bitPerPixel, Types::ColorTypes colorType, const QVector<QRgb> &colorTable); + int startPage(); + int finishPage(); +- int startSaving(const QString &fileName, int pages, qreal widthCm, qreal heightCm); ++ int startSaving(QIODevice *outputDevice, int pages, qreal widthCm, qreal heightCm); + int finishSaving(); +- void drawFilledRect(const QRectF&, const QBrush &brush); +- QSizeF size() const; +- void drawImage(const QRectF &rect); +- void drawOverlayText(const QPointF &position, int flags, int size, const QString &text); ++ void drawFilledRect(const QRectF&, const QBrush &brush) override; ++ QSizeF size() const override; ++ void drawImage(const QRectF &rect) override; ++ void drawOverlayText(const QPointF &position, int flags, int size, const QString &text) override; + + private: +- QFile *m_outputFile; + QString m_xref; +- int m_pdfObjectCount; +- int m_contentPagesCount; +- int m_objectPagesID; +- int m_firstPageID; +- int m_objectResourcesID; +- int m_objectImageID; +- qreal m_mediaboxWidth; +- qreal m_mediaboxHeight; ++ int m_pdfObjectCount = 0; ++ int m_contentPagesCount = 0; ++ int m_objectPagesID = 0; ++ int m_firstPageID = 5; // will be ++ed if the image has a SMask ++ int m_objectResourcesID = 0; ++ int m_objectImageID = 0; ++ qreal m_mediaboxWidth = 5000.0; ++ qreal m_mediaboxHeight = 5000.0; + QString m_pageContent; + QTextStream m_outStream; + }; +- +-#endif // PDFWRITER_H +diff --git a/src/posterazor.pro b/src/posterazor.pro +index f88d3c3..2bd1a69 100644 +--- a/src/posterazor.pro ++++ b/src/posterazor.pro +@@ -1,6 +1,6 @@ + TARGET = PosteRazor + +-isEqual(QT_MAJOR_VERSION, 5):QT += widgets printsupport ++QT += widgets printsupport + + DESTDIR = $$PWD + +@@ -65,14 +65,6 @@ contains (DEFINES, FREEIMAGE_LIB) { + + unix:LIBS += \ + -lfreeimage +-} else { +- contains(CONFIG, static) { +- QTPLUGIN += \ +- qgif \ +- qjpeg \ +- qsvg \ +- qtiff +- } + } + + include (posterazor.pri) +diff --git a/src/posterazorcore.cpp b/src/posterazorcore.cpp +index e2a4117..3542e44 100644 +--- a/src/posterazorcore.cpp ++++ b/src/posterazorcore.cpp +@@ -1,6 +1,6 @@ + /* + PosteRazor - Make your own poster! +- Copyright (C) 2005-2009 by Alessandro Portale ++ Copyright (C) 2005-2018 by Alessandro Portale + http://posterazor.sourceforge.net/ + + This file is part of PosteRazor +@@ -20,17 +20,20 @@ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#include "posterazorcore.h" + #include "pdfwriter.h" ++#include "posterazorcore.h" + #if defined (FREEIMAGE_LIB) + # include "imageloaderfreeimage.h" + #else + # include "imageloaderqt.h" + #endif ++ ++#include <QBrush> ++#include <QFile> + #include <QSettings> + #include <QStringList> +-#include <QBrush> +-#include <math.h> ++ ++#include <cmath> + + const QLatin1String defaultValue_PaperFormat( "DIN A4"); + +@@ -55,23 +58,7 @@ const QLatin1String settingsKey_UnitOfLength( "UnitOfLength"); + PosteRazorCore::PosteRazorCore(ImageLoaderInterface *imageLoader, QObject *parent) + : QObject(parent) + , m_imageLoader(imageLoader) +- , m_posterSizeMode(Types::PosterSizeModePages) +- , m_posterDimension(2.0) +- , m_posterDimensionIsWidth(true) +- , m_posterAlignment(Qt::AlignCenter) +- , m_usesCustomPaperSize(false) + , m_paperFormat(defaultValue_PaperFormat) +- , m_paperOrientation(QPrinter::Portrait) +- , m_paperBorderTop(1.5) +- , m_paperBorderRight(1.5) +- , m_paperBorderBottom(1.5) +- , m_paperBorderLeft(1.5) +- , m_customPaperWidth(20) +- , m_customPaperHeight(20) +- , m_overlappingWidth(1.0) +- , m_overlappingHeight(1.0) +- , m_overlappingPosition(Qt::AlignBottom | Qt::AlignRight) +- , m_unitOfLength(Types::UnitOfLengthCentimeter) + { + Q_ASSERT(m_imageLoader); + } +@@ -142,7 +129,7 @@ qreal PosteRazorCore::convertDistanceToCm(qreal distance) const + + QSizeF PosteRazorCore::convertSizeToCm(const QSizeF &size) const + { +- return QSizeF(convertDistanceToCm(size.width()), convertDistanceToCm(size.height())); ++ return {convertDistanceToCm(size.width()), convertDistanceToCm(size.height())}; + } + + qreal PosteRazorCore::convertCmToDistance(qreal cm) const +@@ -152,7 +139,7 @@ qreal PosteRazorCore::convertCmToDistance(qreal cm) const + + QSizeF PosteRazorCore::convertCmToSize(const QSizeF &sizeInCm) const + { +- return QSizeF(convertCmToDistance(sizeInCm.width()), convertCmToDistance(sizeInCm.height())); ++ return {convertCmToDistance(sizeInCm.width()), convertCmToDistance(sizeInCm.height())}; + } + + bool PosteRazorCore::loadInputImage(const QString &imageFileName, QString &errorMessage) +@@ -314,10 +301,10 @@ QSizeF PosteRazorCore::customPaperSize() const + const qreal minimalPaperHeight = minimalPaperWidth; + const qreal maximalPaperWidth = 500.0; // 5 meter = maximum of a PDF page. + const qreal maximalPaperHeight = maximalPaperWidth; +- return QSizeF( ++ return { + convertCmToDistance(qBound(minimalPaperWidth, m_customPaperWidth, maximalPaperWidth)), + convertCmToDistance(qBound(minimalPaperHeight, m_customPaperHeight, maximalPaperHeight)) +- ); ++ }; + } + + void PosteRazorCore::setUseCustomPaperSize(bool useIt) +@@ -338,10 +325,10 @@ QSizeF PosteRazorCore::paperSize() const + + QSizeF PosteRazorCore::printablePaperAreaSize() const + { +- return QSizeF( ++ return { + paperSize().width() - paperBorderLeft() - paperBorderRight(), + paperSize().height() - paperBorderTop() - paperBorderBottom() +- ); ++ }; + } + + qreal PosteRazorCore::convertBetweenAbsoluteAndPagesPosterDimension(qreal dimension, bool pagesToAbsolute, bool width) const +@@ -371,7 +358,7 @@ qreal PosteRazorCore::convertBetweenAbsoluteAndPagesPosterDimension(qreal dimens + if (posterDimension >= printablePaperAreaDimension) { + posterDimension -= printablePaperAreaDimension; + posterDimensionPages += 1.0; +- } else if (posterDimension < printablePaperAreaDimension) { ++ } else { + posterDimensionPages = posterDimension / printablePaperAreaDimension; + posterDimension = 0; + } +@@ -481,12 +468,7 @@ qreal PosteRazorCore::posterDimension(Types::PosterSizeModes mode, bool width) c + { + qreal posterDimension = (width == m_posterDimensionIsWidth) ? m_posterDimension : calculateOtherPosterDimension(); + +- posterDimension = qMax( +- (mode == Types::PosterSizeModeAbsolute) ? 0.001 +- : (mode == Types::PosterSizeModePages) ? 0.001 +- : 0.001 +- , posterDimension +- ); ++ posterDimension = qMax(0.001 , posterDimension); + + // anything to convert? + if (posterSizeMode() != mode){ +@@ -519,7 +501,7 @@ qreal PosteRazorCore::posterDimension(Types::PosterSizeModes mode, bool width) c + + QSizeF PosteRazorCore::posterSize(Types::PosterSizeModes mode) const + { +- return QSizeF(posterDimension(mode, true), posterDimension(mode, false)); ++ return {posterDimension(mode, true), posterDimension(mode, false)}; + } + + Types::PosterSizeModes PosteRazorCore::posterSizeMode() const +@@ -649,13 +631,13 @@ void PosteRazorCore::paintPosterOnCanvasOverlapped(PaintCanvasInterface *paintCa + QRectF( + QPointF( + ( +- alignment & Qt::AlignLeft ? borderLeft +- : alignment & Qt::AlignHCenter ? qBound(borderLeft, (boxSize.width() - imageSize.width()) / 2, borderLeft + posterPrintableAreaSize.width() - imageSize.width()) ++ (alignment & Qt::AlignLeft) ? borderLeft ++ : (alignment & Qt::AlignHCenter) ? qBound(borderLeft, (boxSize.width() - imageSize.width()) / 2, borderLeft + posterPrintableAreaSize.width() - imageSize.width()) + : (borderLeft + posterPrintableAreaSize.width() - imageSize.width()) + ) + offset.x(), + ( +- alignment & Qt::AlignTop ? borderTop +- : alignment & Qt::AlignVCenter ? qBound(borderTop, (boxSize.height() - imageSize.height()) / 2, borderTop + posterPrintableAreaSize.height() - imageSize.height()) ++ (alignment & Qt::AlignTop) ? borderTop ++ : (alignment & Qt::AlignVCenter) ? qBound(borderTop, (boxSize.height() - imageSize.height()) / 2, borderTop + posterPrintableAreaSize.height() - imageSize.height()) + : (borderTop + posterPrintableAreaSize.height() - imageSize.height()) + ) + offset.y() + ), +@@ -737,14 +719,14 @@ void PosteRazorCore::paintPosterPageOnCanvas(PaintCanvasInterface *paintCanvas, + ); + const Qt::Alignment alignment = posterAlignment(); + qreal imageOffsetFromLeftPosterBorderCm = ( +- alignment & Qt::AlignRight ? posterTotalSizeCm.width() - posterImageSizeCm.width() - borderLeftCm +- : alignment & Qt::AlignHCenter ? (posterTotalSizeCm.width() - posterImageSizeCm.width()) / 2 - borderLeftCm ++ (alignment & Qt::AlignRight) ? posterTotalSizeCm.width() - posterImageSizeCm.width() - borderLeftCm ++ : (alignment & Qt::AlignHCenter) ? (posterTotalSizeCm.width() - posterImageSizeCm.width()) / 2 - borderLeftCm + : -borderLeftCm + ); + imageOffsetFromLeftPosterBorderCm = qBound(.0, imageOffsetFromLeftPosterBorderCm, posterTotalSizeCm.width() - posterImageSizeCm.width() - borderLeftCm - borderRightCm); + qreal imageOffsetFromTopPosterBorderCm = ( +- alignment & Qt::AlignBottom ? posterTotalSizeCm.height() - posterImageSizeCm.height() - borderTopCm +- : alignment & Qt::AlignVCenter ? (posterTotalSizeCm.height() - posterImageSizeCm.height()) / 2 - borderTopCm ++ (alignment & Qt::AlignBottom) ? posterTotalSizeCm.height() - posterImageSizeCm.height() - borderTopCm ++ : (alignment & Qt::AlignVCenter) ? (posterTotalSizeCm.height() - posterImageSizeCm.height()) / 2 - borderTopCm + : -borderTopCm + ); + imageOffsetFromTopPosterBorderCm = qBound(.0, imageOffsetFromTopPosterBorderCm, posterTotalSizeCm.height() - posterImageSizeCm.height() - borderTopCm - borderBottomCm); +@@ -783,7 +765,7 @@ void PosteRazorCore::paintOnCanvas(PaintCanvasInterface *paintCanvas, const QVar + } + } + +-int PosteRazorCore::savePoster(const QString &fileName) const ++int PosteRazorCore::savePoster(QIODevice *outputDevice) const + { + int err = 0; + +@@ -794,7 +776,7 @@ int PosteRazorCore::savePoster(const QString &fileName) const + const QByteArray imageData = m_imageLoader->bits(); + + PDFWriter pdfWriter; +- err = pdfWriter.startSaving(fileName, pagesCount, sizeCm.width(), sizeCm.height()); ++ err = pdfWriter.startSaving(outputDevice, pagesCount, sizeCm.width(), sizeCm.height()); + if (!err) { + if (m_imageLoader->isJpeg()) + err = pdfWriter.saveJpegImage(m_imageLoader->fileName(), imageSize, m_imageLoader->colorDataType()); +diff --git a/src/posterazorcore.h b/src/posterazorcore.h +index 27c30f8..b7c5ee8 100644 +--- a/src/posterazorcore.h ++++ b/src/posterazorcore.h +@@ -1,6 +1,6 @@ + /* + PosteRazor - Make your own poster! +- Copyright (C) 2005-2009 by Alessandro Portale ++ Copyright (C) 2005-2018 by Alessandro Portale + http://posterazor.sourceforge.net/ + + This file is part of PosteRazor +@@ -20,8 +20,7 @@ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef POSTERAZORCORE_H +-#define POSTERAZORCORE_H ++#pragma once + + #include "types.h" + #include "paintcanvasinterface.h" +@@ -38,7 +37,7 @@ class PosteRazorCore: public QObject + Q_OBJECT + + public: +- PosteRazorCore(ImageLoaderInterface *imageLoader, QObject *parent = 0); ++ PosteRazorCore(ImageLoaderInterface *imageLoader, QObject *parent = nullptr); + + static unsigned int imageBitsPerLineCount(int widthPixels, int bitPerPixel); + static unsigned int imageBytesPerLineCount(int widthPixels, int bitPerPixel); +@@ -47,7 +46,7 @@ public: + void readSettings(const QSettings *settings); + void writeSettings(QSettings *settings) const; + bool loadInputImage(const QString &imageFileName, QString &errorMessage); +- int savePoster(const QString &fileName) const; ++ int savePoster(QIODevice *outputDevice) const; + + QSize inputImageSizePixels() const; + qreal inputImageHorizontalDpi() const; +@@ -127,24 +126,22 @@ signals: + void previewImageChanged(const QImage &image) const; + + private: +- ImageLoaderInterface* m_imageLoader; +- Types::PosterSizeModes m_posterSizeMode; +- qreal m_posterDimension; +- bool m_posterDimensionIsWidth; +- Qt::Alignment m_posterAlignment; +- bool m_usesCustomPaperSize; +- QString m_paperFormat; +- QPrinter::Orientation m_paperOrientation; +- qreal m_paperBorderTop; +- qreal m_paperBorderRight; +- qreal m_paperBorderBottom; +- qreal m_paperBorderLeft; +- qreal m_customPaperWidth; +- qreal m_customPaperHeight; +- qreal m_overlappingWidth; +- qreal m_overlappingHeight; +- Qt::Alignment m_overlappingPosition; +- Types::UnitsOfLength m_unitOfLength; ++ ImageLoaderInterface* m_imageLoader = nullptr; ++ Types::PosterSizeModes m_posterSizeMode = Types::PosterSizeModePages; ++ qreal m_posterDimension = 2.0; ++ bool m_posterDimensionIsWidth = true; ++ Qt::Alignment m_posterAlignment = Qt::AlignCenter; ++ bool m_usesCustomPaperSize = false; ++ QString m_paperFormat; ++ QPrinter::Orientation m_paperOrientation = QPrinter::Portrait; ++ qreal m_paperBorderTop = 1.5; ++ qreal m_paperBorderRight = 1.5; ++ qreal m_paperBorderBottom = 1.5; ++ qreal m_paperBorderLeft = 1.5; ++ qreal m_customPaperWidth = 20.0; ++ qreal m_customPaperHeight = 20.0; ++ qreal m_overlappingWidth = 1.0; ++ qreal m_overlappingHeight = 1.0; ++ Qt::Alignment m_overlappingPosition = Qt::AlignBottom | Qt::AlignRight; ++ Types::UnitsOfLength m_unitOfLength = Types::UnitOfLengthCentimeter; + }; +- +-#endif // POSTERAZORCORE_H +diff --git a/src/snapspinbox.cpp b/src/snapspinbox.cpp +index 838fa75..f454521 100644 +--- a/src/snapspinbox.cpp ++++ b/src/snapspinbox.cpp +@@ -1,6 +1,6 @@ + /* + PosteRazor - Make your own poster! +- Copyright (C) 2005-2009 by Alessandro Portale ++ Copyright (C) 2005-2018 by Alessandro Portale + http://posterazor.sourceforge.net/ + + This file is part of PosteRazor +@@ -24,7 +24,6 @@ + + SnapSpinBox::SnapSpinBox(QWidget *parent) + : QDoubleSpinBox(parent) +- , m_originalValue(.0) + { + connect((const QObject *)lineEdit(), SIGNAL(textEdited(const QString &)), SLOT(handleLineEditTextEdited(const QString &))); + } +diff --git a/src/snapspinbox.h b/src/snapspinbox.h +index ca499ec..608578b 100644 +--- a/src/snapspinbox.h ++++ b/src/snapspinbox.h +@@ -1,6 +1,6 @@ + /* + PosteRazor - Make your own poster! +- Copyright (C) 2005-2009 by Alessandro Portale ++ Copyright (C) 2005-2018 by Alessandro Portale + http://posterazor.sourceforge.net/ + + This file is part of PosteRazor +@@ -20,8 +20,7 @@ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef SNAPSPINBOX_H +-#define SNAPSPINBOX_H ++#pragma once + + #include <QDoubleSpinBox> + +@@ -39,15 +38,13 @@ public: + void setValue(qreal value); + + protected: +- qreal m_originalValue; // This is not rounded +- QAbstractSpinBox::StepEnabled stepEnabled() const; ++ qreal m_originalValue = 0.0; // This is not rounded ++ QAbstractSpinBox::StepEnabled stepEnabled() const override; + + private slots: + void handleLineEditTextEdited(const QString &text); +- void stepBy(int steps); ++ void stepBy(int steps) override; + + signals: + void valueEdited(qreal value) const; + }; +- +-#endif // SNAPSPINBOX_H +diff --git a/src/tst_posterazor.cpp b/src/tst_posterazor.cpp +index 8ee9398..c951533 100644 +--- a/src/tst_posterazor.cpp ++++ b/src/tst_posterazor.cpp +@@ -1,6 +1,6 @@ + /* + PosteRazor - Make your own poster! +- Copyright (C) 2005-2009 by Alessandro Portale ++ Copyright (C) 2005-2018 by Alessandro Portale + http://posterazor.sourceforge.net/ + + This file is part of PosteRazor +@@ -33,12 +33,6 @@ + #include <QtGui> + #include <QtWidgets> + +-#if !defined(QT_SHARED) && !defined(QT_DLL) && !defined(FREEIMAGE_LIB) +-Q_IMPORT_PLUGIN(qgif) +-Q_IMPORT_PLUGIN(qjpeg) +-Q_IMPORT_PLUGIN(qtiff) +-#endif +- + class PosteRazorTests: public QObject + { + Q_OBJECT +@@ -60,9 +54,7 @@ const QColor PosteRazorTests::m_screenShotBackground = Qt::white; + void PosteRazorTests::initTestCase() + { + QCoreApplication::setApplicationName("PosteRazor"); +-#if QT_VERSION >= 0x040400 +- QCoreApplication::setApplicationVersion("1.9.5"); +-#endif ++ QCoreApplication::setApplicationVersion("1.9.7"); + QCoreApplication::setOrganizationName("CasaPortale"); + QCoreApplication::setOrganizationDomain("de.casaportale"); + } +@@ -92,10 +84,10 @@ void PosteRazorTests::screenShotterize() + QTest::qWaitForWindowExposed(&window); + QTest::qWait(500); // Wait for fancy effects to finish + +- QPushButton *nextButton = window.findChild<QPushButton*>(QString::fromLatin1("m_stepNextButton")); +- QTabWidget *paperFormatCustomTabs = window.findChild<QTabWidget*>(QString::fromLatin1("m_paperFormatTypeTabs")); +- QWidget *paperFormatStandardTab = window.findChild<QWidget*>(QString::fromLatin1("m_paperFormatStandardTab")); +- QWidget *paperFormatCustomTab = window.findChild<QWidget*>(QString::fromLatin1("m_paperFormatCustomTab")); ++ auto nextButton = window.findChild<QPushButton*>(QString::fromLatin1("m_stepNextButton")); ++ auto paperFormatCustomTabs = window.findChild<QTabWidget*>(QString::fromLatin1("m_paperFormatTypeTabs")); ++ auto paperFormatStandardTab = window.findChild<QWidget*>(QString::fromLatin1("m_paperFormatStandardTab")); ++ auto paperFormatCustomTab = window.findChild<QWidget*>(QString::fromLatin1("m_paperFormatCustomTab")); + + const QString screenShotFileNameTemplate = + QString::fromLatin1("ScreenShot-%1-%2-%3.png") +@@ -128,7 +120,7 @@ void PosteRazorTests::screenShotterize() + + static inline bool imageRowHasUniqueColor(const QImage &image, int row, const QColor &color) + { +- const QRgb *rowData = reinterpret_cast<const QRgb*>(image.scanLine(row)); ++ auto rowData = reinterpret_cast<const QRgb*>(image.scanLine(row)); + const QRgb colorRgba = color.rgba(); + for (int i = 0; i < image.width(); ++i) + if (*(rowData++) != colorRgba) +diff --git a/src/tst_posterazor.pro b/src/tst_posterazor.pro +index 383d048..f9cd1a8 100644 +--- a/src/tst_posterazor.pro ++++ b/src/tst_posterazor.pro +@@ -24,16 +24,6 @@ contains (DEFINES, FREEIMAGE_LIB) { + + unix:LIBS += \ + -lfreeimage +-} else { +- contains(CONFIG, static) { +- QTPLUGIN += \ +- qgif \ +- qjpeg \ +- qsvg \ +- qtiff +- } + } + + include (posterazor.pri) +- +-!contains(CONFIG, build_pass) system(lrelease posterazor.pro) +diff --git a/src/types.cpp b/src/types.cpp +index 98edad1..c8302ca 100644 +--- a/src/types.cpp ++++ b/src/types.cpp +@@ -1,6 +1,6 @@ + /* + PosteRazor - Make your own poster! +- Copyright (C) 2005-2009 by Alessandro Portale ++ Copyright (C) 2005-2018 by Alessandro Portale + http://posterazor.sourceforge.net/ + + This file is part of PosteRazor +@@ -21,29 +21,20 @@ + */ + + #include "types.h" +-#include <QtDebug> ++ + #include <QRegExp> ++#include <QtDebug> + + const QHash<Types::UnitsOfLength, QPair<QString, qreal> > &Types::unitsOfLength() + { +- static QHash<UnitsOfLength, QPair<QString, qreal> > units; +- if (units.empty()) { +- static const struct { +- UnitsOfLength unit; +- QString name; +- qreal cm; +- } unitsOfLength[] = { +- {UnitOfLengthMeter, QLatin1String("m"), 100.00}, +- {UnitOfLengthMillimeter, QLatin1String("mm"), 0.10}, +- {UnitOfLengthCentimeter, QLatin1String("cm"), 1.00}, +- {UnitOfLengthInch, QLatin1String("in"), 2.54}, +- {UnitOfLengthFeet, QLatin1String("ft"), 2.54 * 12.00}, +- {UnitOfLengthPoints, QLatin1String("pt"), 2.54 / 72.00} +- }; +- static const int unitsOfLengthCount = int(sizeof unitsOfLength / sizeof unitsOfLength[0]); +- for (int i = 0; i < unitsOfLengthCount; i++) +- units.insert(unitsOfLength[i].unit, QPair<QString, qreal> (unitsOfLength[i].name, unitsOfLength[i].cm)); +- } ++ const static QHash<UnitsOfLength, QPair<QString, qreal> > units = { ++ {UnitOfLengthMeter, {QLatin1String("m"), 100.00}}, ++ {UnitOfLengthMillimeter, {QLatin1String("mm"), 0.10}}, ++ {UnitOfLengthCentimeter, {QLatin1String("cm"), 1.00}}, ++ {UnitOfLengthInch, {QLatin1String("in"), 2.54}}, ++ {UnitOfLengthFeet, {QLatin1String("ft"), 2.54 * 12.00}}, ++ {UnitOfLengthPoints, {QLatin1String("pt"), 2.54 / 72.00}} ++ }; + return units; + } + +@@ -61,10 +52,10 @@ qreal Types::convertBetweenUnitsOfLength(qreal distance, UnitsOfLength sourceUni + + QSizeF Types::convertBetweenUnitsOfLength(const QSizeF &size, UnitsOfLength sourceUnit, UnitsOfLength targetUnit) + { +- return QSizeF( ++ return { + convertBetweenUnitsOfLength(size.width(), sourceUnit, targetUnit), + convertBetweenUnitsOfLength(size.height(), sourceUnit, targetUnit) +- ); ++ }; + } + + Types::UnitsOfLength Types::unitOfLenthFromString(const QString &string) +@@ -80,23 +71,14 @@ Types::UnitsOfLength Types::unitOfLenthFromString(const QString &string) + + const QHash<QString, QSizeF> &Types::paperFormats() + { +- static QHash<QString, QSizeF> formats; +- if (formats.empty()) { +- static const struct { +- QString name; +- qreal width; +- qreal height; +- } paperFormats[] = { +- {QLatin1String("DIN A4"), 21.0, 29.7}, +- {QLatin1String("DIN A3"), 29.7, 42.0}, +- {QLatin1String("Legal"), 21.6, 35.6}, +- {QLatin1String("Letter"), 21.6, 27.9}, +- {QLatin1String("Tabloid"), 27.9, 43.2} +- }; +- static const int paperFormatsCount = int(sizeof paperFormats / sizeof paperFormats[0]); +- for (int i = 0; i < paperFormatsCount; i++) +- formats.insert(paperFormats[i].name, QSizeF(paperFormats[i].width, paperFormats[i].height)); +- } ++ const static QHash<QString, QSizeF> formats = ++ { ++ {QLatin1String("DIN A4"), {21.0, 29.7}}, ++ {QLatin1String("DIN A3"), {29.7, 42.0}}, ++ {QLatin1String("Legal"), {21.6, 35.6}}, ++ {QLatin1String("Letter"), {21.6, 27.9}}, ++ {QLatin1String("Tabloid"), {27.9, 43.2}} ++ }; + return formats; + } + +diff --git a/src/types.h b/src/types.h +index a7d87ef..b426201 100644 +--- a/src/types.h ++++ b/src/types.h +@@ -1,6 +1,6 @@ + /* + PosteRazor - Make your own poster! +- Copyright (C) 2005-2009 by Alessandro Portale ++ Copyright (C) 2005-2018 by Alessandro Portale + http://posterazor.sourceforge.net/ + + This file is part of PosteRazor +@@ -20,8 +20,7 @@ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef TYPES_H +-#define TYPES_H ++#pragma once + + #include <QPair> + #include <QPrinter> +@@ -65,5 +64,3 @@ public: + static QString cleanString(const QString &dirtyString); + static QString newlineToParagraph(const QString &nlText); + }; +- +-#endif // TYPES_H +diff --git a/src/wizard.cpp b/src/wizard.cpp +index e0aa8bf..e5159b6 100644 +--- a/src/wizard.cpp ++++ b/src/wizard.cpp +@@ -1,6 +1,6 @@ + /* + PosteRazor - Make your own poster! +- Copyright (C) 2005-2009 by Alessandro Portale ++ Copyright (C) 2005-2018 by Alessandro Portale + http://posterazor.sourceforge.net/ + + This file is part of PosteRazor +@@ -21,12 +21,13 @@ + */ + + #include "wizard.h" +-#include <QSignalMapper> +-#include <QFileInfo> +-#include <QtDebug> +-#include <QVBoxLayout> ++ + #include <QDialogButtonBox> ++#include <QFileInfo> + #include <QMessageBox> ++#include <QSignalMapper> ++#include <QVBoxLayout> ++#include <QtDebug> + + Wizard::Wizard(QWidget *parent) + : QWidget(parent) +@@ -38,42 +39,34 @@ Wizard::Wizard(QWidget *parent) + m_stepHelpButton->setMinimumSize(m_imageLoadButton->sizeHint()); + m_savePosterButton->setIcon(QApplication::style()->standardPixmap(QStyle::SP_DialogSaveButton)); + +- const struct { +- QAbstractButton *sender; +- Qt::Alignment alignment; +- } alignmentMap[] = { +- {m_posterAlignmentTopLeftButton, Qt::AlignTop | Qt::AlignLeft }, +- {m_posterAlignmentTopButton, Qt::AlignTop | Qt::AlignHCenter }, +- {m_posterAlignmentTopRightButton, Qt::AlignTop | Qt::AlignRight }, +- {m_posterAlignmentLeftButton, Qt::AlignVCenter | Qt::AlignLeft }, +- {m_posterAlignmentCenterButton, Qt::AlignCenter }, +- {m_posterAlignmentRightButton, Qt::AlignVCenter | Qt::AlignRight }, +- {m_posterAlignmentBottomLeftButton, Qt::AlignBottom | Qt::AlignLeft }, +- {m_posterAlignmentBottomButton, Qt::AlignBottom | Qt::AlignHCenter }, +- {m_posterAlignmentBottomRightButton, Qt::AlignBottom | Qt::AlignRight } ++ m_overlappingButtons = { ++ {Qt::AlignTop | Qt::AlignLeft, m_overlappingPositionTopLeftButton }, ++ {Qt::AlignTop | Qt::AlignRight, m_overlappingPositionTopRightButton }, ++ {Qt::AlignBottom | Qt::AlignLeft, m_overlappingPositionBottomLeftButton }, ++ {Qt::AlignBottom | Qt::AlignRight, m_overlappingPositionBottomRightButton } + }; +- static const int alignmentMapCount = int(sizeof alignmentMap / sizeof alignmentMap[0]); +- for (int i = 0; i < alignmentMapCount; i++) +- m_alignmentButtons.insert(alignmentMap[i].alignment, alignmentMap[i].sender); +- +- const struct { +- QAbstractButton *sender; +- Qt::Alignment alignment; +- } overlappingMap[] = { +- {m_overlappingPositionTopLeftButton, Qt::AlignTop | Qt::AlignLeft }, +- {m_overlappingPositionTopRightButton, Qt::AlignTop | Qt::AlignRight }, +- {m_overlappingPositionBottomLeftButton, Qt::AlignBottom | Qt::AlignLeft }, +- {m_overlappingPositionBottomRightButton, Qt::AlignBottom | Qt::AlignRight } ++ ++ m_alignmentButtons = { ++ {Qt::AlignTop | Qt::AlignLeft, m_posterAlignmentTopLeftButton }, ++ {Qt::AlignTop | Qt::AlignHCenter, m_posterAlignmentTopButton }, ++ {Qt::AlignTop | Qt::AlignRight, m_posterAlignmentTopRightButton }, ++ {Qt::AlignVCenter | Qt::AlignLeft, m_posterAlignmentLeftButton }, ++ {Qt::AlignCenter, m_posterAlignmentCenterButton }, ++ {Qt::AlignVCenter | Qt::AlignRight, m_posterAlignmentRightButton }, ++ {Qt::AlignBottom | Qt::AlignLeft, m_posterAlignmentBottomLeftButton }, ++ {Qt::AlignBottom | Qt::AlignHCenter, m_posterAlignmentBottomButton }, ++ {Qt::AlignBottom | Qt::AlignRight, m_posterAlignmentBottomRightButton } + }; +- static const int overlappingMapCount = int(sizeof overlappingMap / sizeof overlappingMap[0]); +- for (int i = 0; i < overlappingMapCount; i++) +- m_overlappingButtons.insert(overlappingMap[i].alignment, overlappingMap[i].sender); + + m_steps->setCurrentIndex(0); + createConnections(); + populateUI(); + updatePosterSizeGroupsState(); + retranslateUi(); ++ ++#ifdef Q_OS_WASM ++ m_launchPDFApplicationCheckBox->hide(); ++#endif // Q_OS_WASM + } + + void Wizard::changeEvent(QEvent *event) +@@ -407,11 +400,11 @@ void Wizard::createConnections() + connect(m_posterSizePercentualRadioButton, SIGNAL(clicked()), SLOT(updatePosterSizeGroupsState())); + connect(m_overlappingWidthInput, SIGNAL(valueEdited(qreal)), SIGNAL(overlappingWidthChanged(qreal))); + connect(m_overlappingHeightInput, SIGNAL(valueEdited(qreal)), SIGNAL(overlappingHeightChanged(qreal))); +- QSignalMapper *overlappingMapper = new QSignalMapper(this); +- foreach (const Qt::Alignment alignment, m_overlappingButtons.keys()) { +- QAbstractButton *sender = m_overlappingButtons.value(alignment); ++ auto overlappingMapper = new QSignalMapper(this); ++ for (auto it = m_overlappingButtons.cbegin(), end = m_overlappingButtons.cend(); it != end; ++it) { ++ QAbstractButton *sender = it.value(); + connect(sender, SIGNAL(clicked()), overlappingMapper, SLOT(map())); +- overlappingMapper->setMapping(sender, alignment); ++ overlappingMapper->setMapping(sender, it.key()); + } + connect(overlappingMapper, SIGNAL(mapped(int)), SLOT(emitOverlappingPositionChange(int))); + connect(m_posterAbsoluteWidthInput, SIGNAL(valueEdited(qreal)), SIGNAL(posterWidthAbsoluteChanged(qreal))); +@@ -419,11 +412,11 @@ void Wizard::createConnections() + connect(m_posterPagesWidthInput, SIGNAL(valueEdited(qreal)), SIGNAL(posterWidthPagesChanged(qreal))); + connect(m_posterPagesHeightInput, SIGNAL(valueEdited(qreal)), SIGNAL(posterHeightPagesChanged(qreal))); + connect(m_posterPercentualSizeInput, SIGNAL(valueEdited(qreal)), SIGNAL(posterSizePercentualChanged(qreal))); +- QSignalMapper *alignmentMapper = new QSignalMapper(this); +- foreach (const Qt::Alignment alignment, m_alignmentButtons.keys()) { +- QAbstractButton *sender = m_alignmentButtons.value(alignment); ++ auto alignmentMapper = new QSignalMapper(this); ++ for (auto it = m_alignmentButtons.cbegin(), end = m_alignmentButtons.cend(); it != end; ++it) { ++ QAbstractButton *sender = it.value(); + connect(sender, SIGNAL(clicked()), alignmentMapper, SLOT(map())); +- alignmentMapper->setMapping(sender, alignment); ++ alignmentMapper->setMapping(sender, it.key()); + } + connect(alignmentMapper, SIGNAL(mapped(int)), SLOT(emitPosterAlignmentChange(int))); + connect(m_savePosterButton, SIGNAL(clicked()), SIGNAL(savePosterSignal())); +diff --git a/src/wizard.h b/src/wizard.h +index b64927d..f6da58b 100644 +--- a/src/wizard.h ++++ b/src/wizard.h +@@ -1,6 +1,6 @@ + /* + PosteRazor - Make your own poster! +- Copyright (C) 2005-2009 by Alessandro Portale ++ Copyright (C) 2005-2018 by Alessandro Portale + http://posterazor.sourceforge.net/ + + This file is part of PosteRazor +@@ -20,8 +20,7 @@ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef WIZARD_H +-#define WIZARD_H ++#pragma once + + #include "ui_wizard.h" + #include "types.h" +@@ -31,9 +30,9 @@ class Wizard : public QWidget, private Ui::Wizard + Q_OBJECT + + public: +- Wizard(QWidget *parent = 0); ++ Wizard(QWidget *parent = nullptr); + +- void changeEvent(QEvent *event); ++ void changeEvent(QEvent *event) override; + + public slots: + void retranslateUi(); +@@ -117,5 +116,3 @@ private slots: + void emitPosterAlignmentChange(int alignmentInt) const; + void updatePosterSizeGroupsState(); + }; +- +-#endif // WIZARD_H +diff --git a/src/wizardcontroller.cpp b/src/wizardcontroller.cpp +index e429ff9..99aa0db 100644 +--- a/src/wizardcontroller.cpp ++++ b/src/wizardcontroller.cpp +@@ -1,6 +1,6 @@ + /* + PosteRazor - Make your own poster! +- Copyright (C) 2005-2009 by Alessandro Portale ++ Copyright (C) 2005-2018 by Alessandro Portale + http://posterazor.sourceforge.net/ + + This file is part of PosteRazor +@@ -20,11 +20,12 @@ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#include "wizardcontroller.h" + #include "types.h" ++#include "wizardcontroller.h" ++ + #include <QCoreApplication> +-#include <QMetaObject> + #include <QMetaEnum> ++#include <QMetaObject> + + static const QMetaEnum wizardStepsEnum() + { +@@ -39,8 +40,6 @@ static int wizardStepsCount() + + WizardController::WizardController(QObject *wizardDialog, QObject *parent) + : QObject(parent) +- , m_wizardStep(WizardStepInputImage) +- , m_imageWasLoaded(false) + { + connect(this, SIGNAL(wizardStepChanged(int)), wizardDialog, SLOT(setWizardStep(int))); + connect(this, SIGNAL(wizardStepDescriptionChanged(const QString&, const QString&)), wizardDialog, SLOT(setWizardStepDescription(const QString&, const QString&))); +@@ -75,7 +74,7 @@ void WizardController::setStepAvailable(WizardSteps step, bool available) + WizardController::WizardSteps WizardController::previousAvailableStep() + { + for (int i = m_wizardStep; i > WizardStepInputImage; i--){ +- const WizardSteps newStep = WizardSteps(i - 1); ++ const auto newStep = WizardSteps(i - 1); + if (!m_unavaliableSteps.contains(newStep)) + return newStep; + } +@@ -86,7 +85,7 @@ WizardController::WizardSteps WizardController::previousAvailableStep() + WizardController::WizardSteps WizardController::nextAvailableStep() + { + for (int i = m_wizardStep; i < WizardStepSavePoster; ++i){ +- const WizardSteps newStep = WizardSteps(i + 1); ++ const auto newStep = WizardSteps(i + 1); + if (!m_unavaliableSteps.contains(newStep)) + return newStep; + } +@@ -110,8 +109,8 @@ void WizardController::showManual() + "All entries and choices are remembered until the next usage of the PosteRazor.", + "Manual preface. Place holders: %1 = Number of wizard steps, %2 = 'Back', %3 = 'Next' (will be automatically inserted)") + .arg(wizardStepsCount() - m_unavaliableSteps.count()) +- .arg(QCoreApplication::translate("Main window", "Back")) +- .arg(QCoreApplication::translate("Main window", "Next")))); ++ .arg(QCoreApplication::translate("Main window", "Back"), ++ QCoreApplication::translate("Main window", "Next")))); + for (int i = 0; i < wizardStepsEnum().keyCount(); i++) { + const WizardSteps step = (WizardSteps)wizardStepsEnum().value(i); + if (!m_unavaliableSteps.contains(step)){ +@@ -148,8 +147,7 @@ void WizardController::updateDialogWizardStep() + m_wizardStep == WizardStepInputImage ? "image" + : m_wizardStep == WizardStepOverlapping ? "overlapping" + : m_wizardStep == WizardStepPaperSize ? "paper" +- : m_wizardStep == WizardStepPosterSize ? "poster" +- : "poster" ++ : "poster" // WizardStepPosterSize, WizardStepSavePoster + )); + emit prevButtonEnabled(m_wizardStep != previousAvailableStep()); + emit nextButtonEnabled( +@@ -204,9 +202,9 @@ QString WizardController::stepHelp(WizardSteps step) + "Alternatively, a custom paper sheet size can be defined in the <b>%2</b> tab.\n" + "Paper borders are defined in the <b>%3</b> fields. Even if your printer does need no (or small) paper borders, some border might be needed to have enough area for gluing the final poster tiles together.", + "Wizard step 2. Place holders: %1 = 'Format:', %2 = 'Custom', %3 = 'Borders' (will be automatically inserted)") +- .arg(Types::cleanString(QCoreApplication::translate("Main window", "Format:"))) +- .arg(Types::cleanString(QCoreApplication::translate("Main window", "Custom"))) +- .arg(Types::cleanString(QCoreApplication::translate("Main window", "Borders"))); ++ .arg(Types::cleanString(QCoreApplication::translate("Main window", "Format:")), ++ Types::cleanString(QCoreApplication::translate("Main window", "Custom")), ++ Types::cleanString(QCoreApplication::translate("Main window", "Borders"))); + break; + case WizardStepOverlapping: + result = QCoreApplication::translate("Help", +@@ -223,20 +221,20 @@ QString WizardController::stepHelp(WizardSteps step) + "Wizard step 4. Start of the description."); + result.append(QLatin1String("<dl>")); + result.append(definitionTemplate +- .arg(Types::cleanString(QCoreApplication::translate("Main window", "Absolute size:"))) +- .arg(QCoreApplication::translate("Help", +- "You want to have a specific size of your poster.", +- "Wizard step 4. Description for 'absolute size'"))); ++ .arg(Types::cleanString(QCoreApplication::translate("Main window", "Absolute size:")), ++ QCoreApplication::translate("Help", ++ "You want to have a specific size of your poster.", ++ "Wizard step 4. Description for 'absolute size'"))); + result.append(definitionTemplate +- .arg(Types::cleanString(QCoreApplication::translate("Main window", "Size in pages:"))) +- .arg(QCoreApplication::translate("Help", +- "You want to use whole paper sheets and specify how many of them you want to use.", +- "Wizard step 4. Description for 'size in pages'"))); ++ .arg(Types::cleanString(QCoreApplication::translate("Main window", "Size in pages:")), ++ QCoreApplication::translate("Help", ++ "You want to use whole paper sheets and specify how many of them you want to use.", ++ "Wizard step 4. Description for 'size in pages'"))); + result.append(definitionTemplate +- .arg(Types::cleanString(QCoreApplication::translate("Main window", "Size in percent:"))) +- .arg(QCoreApplication::translate("Help", +- "Your input image has a certain size which is defined by the number of pixels and dpi (dots per Inch) and your want to enlarge the image by a certain factor.", +- "Wizard step 4. Description for 'size in percent'"))); ++ .arg(Types::cleanString(QCoreApplication::translate("Main window", "Size in percent:")), ++ QCoreApplication::translate("Help", ++ "Your input image has a certain size which is defined by the number of pixels and dpi (dots per Inch) and your want to enlarge the image by a certain factor.", ++ "Wizard step 4. Description for 'size in percent'"))); + result.append(QLatin1String("</dl>")); + result.append(QCoreApplication::translate("Help", + "The aspect ratio of width and height is always 1:1 and is automatically recalculated. In the preview area, you can see the overlapping areas which are surrounded by light red rectangles.\n" +diff --git a/src/wizardcontroller.h b/src/wizardcontroller.h +index 8cf61c0..31c6ef7 100644 +--- a/src/wizardcontroller.h ++++ b/src/wizardcontroller.h +@@ -1,6 +1,6 @@ + /* + PosteRazor - Make your own poster! +- Copyright (C) 2005-2009 by Alessandro Portale ++ Copyright (C) 2005-2018 by Alessandro Portale + http://posterazor.sourceforge.net/ + + This file is part of PosteRazor +@@ -20,8 +20,7 @@ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef WIZARDCONTROLLER_H +-#define WIZARDCONTROLLER_H ++#pragma once + + #include <QObject> + +@@ -39,7 +38,7 @@ public: + WizardStepSavePoster + }; + +- WizardController(QObject *wizardDialog, QObject *parent = 0); ++ WizardController(QObject *wizardDialog, QObject *parent = nullptr); + + void setStepAvailable(WizardSteps step, bool available); + WizardSteps previousAvailableStep(); +@@ -66,13 +65,11 @@ signals: + void showWizardStepHelpSignal(const QString &title, const QString &manual) const; + + private: +- WizardSteps m_wizardStep; +- bool m_imageWasLoaded; ++ WizardSteps m_wizardStep = WizardStepInputImage; ++ bool m_imageWasLoaded = false; + QList<WizardSteps> m_unavaliableSteps; + + QString stepXofYString(WizardSteps step) const; + static QString stepTitle(WizardSteps step); + static QString stepHelp(WizardSteps step); + }; +- +-#endif // WIZARDCONTROLLER_H