From ebdfa9e4ee3d6fab5d6ca0d8ecae593f396e0c5c Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Sat, 31 Jul 2021 12:52:33 +0200 Subject: [PATCH] Change paper sizes to QSizeF --- src/convertworker.cpp | 12 ++++++------ src/ippprinter.cpp | 4 ++-- src/papersizes.h | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/convertworker.cpp b/src/convertworker.cpp index d3b597c..ab682d7 100644 --- a/src/convertworker.cpp +++ b/src/convertworker.cpp @@ -193,9 +193,9 @@ try { qDebug() << "Unsupported paper size" << PaperSize; throw ConvertFailedException(tr("Unsupported paper size")); } - QPair wh = PaperSizes[PaperSize]; - quint32 Width = qRound(wh.first/25.4*HwResX); - quint32 Height = qRound(wh.second/25.4*HwResY); + QSizeF size = PaperSizes[PaperSize]; + quint32 Width = qRound(size.width()/25.4*HwResX); + quint32 Height = qRound(size.height()/25.4*HwResY); qDebug() << "Size is" << Width << "x" << Height; @@ -228,7 +228,7 @@ try { tmpPdfFile.open(); QPdfWriter pdfWriter(tmpPdfFile.fileName()); pdfWriter.setCreator("SeaPrint " SEAPRINT_VERSION); - QPageSize pageSize(QSizeF {wh.first, wh.second}, QPageSize::Millimeter); + QPageSize pageSize(size, QPageSize::Millimeter); pdfWriter.setPageSize(pageSize); pdfWriter.setResolution(HwResX); QPainter painter(&pdfWriter); @@ -452,7 +452,7 @@ try { qDebug() << "Unsupported paper size" << PaperSize; throw ConvertFailedException(tr("Unsupported paper size")); } - QPair wh = PaperSizes[PaperSize]; + QSizeF size = PaperSizes[PaperSize]; QFile inFile(filename); if(!inFile.open(QIODevice::ReadOnly)) @@ -467,7 +467,7 @@ try { QPdfWriter pdfWriter(tmpPdfFile.fileName()); pdfWriter.setCreator("SeaPrint " SEAPRINT_VERSION); - QPageSize pageSize(QSizeF {wh.first, wh.second}, QPageSize::Millimeter); + QPageSize pageSize(size, QPageSize::Millimeter); pdfWriter.setPageSize(pageSize); pdfWriter.setResolution(resolution); diff --git a/src/ippprinter.cpp b/src/ippprinter.cpp index c4d6d5a..94689a4 100644 --- a/src/ippprinter.cpp +++ b/src/ippprinter.cpp @@ -521,8 +521,8 @@ void IppPrinter::print(QJsonObject jobAttrs, QString filename) return; } - int x = PaperSizes[PaperSize].first*100; - int y = PaperSizes[PaperSize].second*100; + int x = PaperSizes[PaperSize].width()*100; + int y = PaperSizes[PaperSize].height()*100; QJsonObject Dimensions = {{"tag", IppMsg::BeginCollection}, diff --git a/src/papersizes.h b/src/papersizes.h index a13fbe7..a37f1a7 100644 --- a/src/papersizes.h +++ b/src/papersizes.h @@ -1,9 +1,9 @@ #ifndef PAPERSIZES_H #define PAPERSIZES_H #include -#include +#include -static QMap> PaperSizes = +static QMap PaperSizes = {{"asme_f_28x40in", {711.20, 1016.00}}, {"iso_2a0_1189x1682mm", {1189.00, 1682.00}}, {"iso_a0_841x1189mm", {841.00, 1189.00}},