summaryrefslogtreecommitdiffstats
path: root/src/gui/painting
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@digia.com>2012-01-12 21:06:12 (GMT)
committerQt by Nokia <qt-info@nokia.com>2012-01-13 08:36:55 (GMT)
commit5f35882f91ff5634b1694d1f6d62c057d278b1a6 (patch)
tree2947a9c34743a02937d58e264ba9dc9da41b1185 /src/gui/painting
parent18b7ef9506609490a3958a97d5806ce0985a5575 (diff)
downloadQt-5f35882f91ff5634b1694d1f6d62c057d278b1a6.zip
Qt-5f35882f91ff5634b1694d1f6d62c057d278b1a6.tar.gz
Qt-5f35882f91ff5634b1694d1f6d62c057d278b1a6.tar.bz2
Fix using custom paper sizes on Mac
This solves the bug with using custom paper sizes on Mac, if a QSize was specified then with a Unit it would not respect this on Mac as it would not convert it correctly. Also paperSize() would return the wrong value. There is already a test for this in tst_QPrinter::testCustomPageSizes() Task-number: QTBUG-18723 Change-Id: I47c0cf2dd48ea3e0daa3b748f337ec38714aaf34 Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com> Reviewed-by: Jiang Jiang <jiang.jiang@nokia.com>
Diffstat (limited to 'src/gui/painting')
-rw-r--r--src/gui/painting/qprintengine_mac.mm8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/gui/painting/qprintengine_mac.mm b/src/gui/painting/qprintengine_mac.mm
index b103417..729c87b 100644
--- a/src/gui/painting/qprintengine_mac.mm
+++ b/src/gui/painting/qprintengine_mac.mm
@@ -179,6 +179,8 @@ void QMacPrintEnginePrivate::setPaperSize(QPrinter::PaperSize ps)
QPrinter::PaperSize QMacPrintEnginePrivate::paperSize() const
{
+ if (hasCustomPaperSize)
+ return QPrinter::Custom;
PMRect paper;
PMGetUnadjustedPaperRect(format, &paper);
int wMM = int((paper.right - paper.left) / 72 * 25.4 + 0.5);
@@ -854,11 +856,11 @@ QVariant QMacPrintEngine::property(PrintEnginePropertyKey key) const
case PPK_PaperRect: {
QRect r;
PMRect macrect;
+ qreal hRatio = d->resolution.hRes / 72;
+ qreal vRatio = d->resolution.vRes / 72;
if (d->hasCustomPaperSize) {
- r = QRect(0, 0, qRound(d->customSize.width()), qRound(d->customSize.height()));
+ r = QRect(0, 0, qRound(d->customSize.width() * hRatio), qRound(d->customSize.height() * vRatio));
} else if (PMGetAdjustedPaperRect(d->format, &macrect) == noErr) {
- qreal hRatio = d->resolution.hRes / 72;
- qreal vRatio = d->resolution.vRes / 72;
r.setCoords(int(macrect.left * hRatio), int(macrect.top * vRatio),
int(macrect.right * hRatio), int(macrect.bottom * vRatio));
r.translate(-r.x(), -r.y());