diff options
author | Andy Shaw <andy.shaw@digia.com> | 2011-09-11 10:03:58 (GMT) |
---|---|---|
committer | Qt Commercial Integration <QtCommercial@digia.com> | 2012-01-31 10:25:10 (GMT) |
commit | 3d3576eadd1bc84d67890a288eb46111ce67433c (patch) | |
tree | 68e65a69d0912fab95e0a5203b1886d0c186672f | |
parent | 17332a87f61171ed1bfda16f4adf535956471520 (diff) | |
download | Qt-3d3576eadd1bc84d67890a288eb46111ce67433c.zip Qt-3d3576eadd1bc84d67890a288eb46111ce67433c.tar.gz Qt-3d3576eadd1bc84d67890a288eb46111ce67433c.tar.bz2 |
Fix set/paperSize(QPrinter::PaperSize) on Mac
This fixes the paper size setting on Mac as it would not return the
same paper size that was set with setPaperSize() when calling
paperSize().
Test is included.
Task-number: QTBUG-20882
-rw-r--r-- | src/gui/painting/qprintengine_mac.mm | 4 | ||||
-rw-r--r-- | tests/auto/qprinter/tst_qprinter.cpp | 25 |
2 files changed, 18 insertions, 11 deletions
diff --git a/src/gui/painting/qprintengine_mac.mm b/src/gui/painting/qprintengine_mac.mm index 22ed25a..939079a 100644 --- a/src/gui/painting/qprintengine_mac.mm +++ b/src/gui/painting/qprintengine_mac.mm @@ -149,7 +149,7 @@ QMacPrintEnginePrivate::~QMacPrintEnginePrivate() void QMacPrintEnginePrivate::setPaperSize(QPrinter::PaperSize ps) { Q_Q(QMacPrintEngine); - QSizeF newSize = qt_paperSizeToQSizeF(ps); + QSize newSize = qt_paperSizeToQSizeF(ps).toSize(); QCFType<CFArrayRef> formats; PMPrinter printer; @@ -185,7 +185,7 @@ QPrinter::PaperSize QMacPrintEnginePrivate::paperSize() const int wMM = int((paper.right - paper.left) / 72 * 25.4 + 0.5); int hMM = int((paper.bottom - paper.top) / 72 * 25.4 + 0.5); for (int i = QPrinter::A4; i < QPrinter::NPaperSize; ++i) { - QSizeF s = qt_paperSizeToQSizeF(QPrinter::PaperSize(i)); + QSize s = qt_paperSizeToQSizeF(QPrinter::PaperSize(i)).toSize(); if (s.width() == wMM && s.height() == hMM) return (QPrinter::PaperSize)i; } diff --git a/tests/auto/qprinter/tst_qprinter.cpp b/tests/auto/qprinter/tst_qprinter.cpp index 2cda5f0..67f2c4d 100644 --- a/tests/auto/qprinter/tst_qprinter.cpp +++ b/tests/auto/qprinter/tst_qprinter.cpp @@ -577,15 +577,22 @@ void tst_QPrinter::outputFormatFromSuffix() void tst_QPrinter::setGetPaperSize() { - QPrinter p; - p.setOutputFormat(QPrinter::PdfFormat); - QSizeF size(500, 10); - p.setPaperSize(size, QPrinter::Millimeter); - QCOMPARE(p.paperSize(QPrinter::Millimeter), size); - QSizeF ptSize = p.paperSize(QPrinter::Point); - //qDebug() << ptSize; - QVERIFY(qAbs(ptSize.width() - size.width() * (72/25.4)) < 1E-4); - QVERIFY(qAbs(ptSize.height() - size.height() * (72/25.4)) < 1E-4); + { + QPrinter p; + p.setOutputFormat(QPrinter::PdfFormat); + QSizeF size(500, 10); + p.setPaperSize(size, QPrinter::Millimeter); + QCOMPARE(p.paperSize(QPrinter::Millimeter), size); + QSizeF ptSize = p.paperSize(QPrinter::Point); + //qDebug() << ptSize; + QVERIFY(qAbs(ptSize.width() - size.width() * (72/25.4)) < 1E-4); + QVERIFY(qAbs(ptSize.height() - size.height() * (72/25.4)) < 1E-4); + } + { + QPrinter p; + p.setPaperSize(QPrinter::Legal); + QCOMPARE(p.paperSize(), QPrinter::Legal); + } } void tst_QPrinter::testPageMargins_data() |