diff options
author | Kai Pastor <dg0yt@darc.de> | 2015-09-11 01:22:14 +0200 |
---|---|---|
committer | Kai Pastor <dg0yt@darc.de> | 2016-02-25 18:42:47 +0000 |
commit | 44357dbe423d430246504d977f4422ed0e2e7a5a (patch) | |
tree | 2ac646155768ec7fbb5b7bdd448e0503189bc33b /src/plugins/platforms/cocoa/qprintengine_mac.mm | |
parent | debc44cf1106fb20065aab7848759eace3211c65 (diff) |
QMacPrintEngine: Really set the printer resolution
As already reported in 2009 (Qt 4.6) QPrinter never actually set the
printer resolution. This change adds the necessary call to
PMPrinterSetOutputResolution (available since OS X 10.5).
[ChangeLog][QtPrintSupport][OS X] QMacPrintEngine now really sets the
printer resolution.
Task-number: QTBUG-7000
Change-Id: I3e851b62e1a7ed78564a8a6fd576b0a18d7eff63
Reviewed-by: Andy Shaw <andy.shaw@theqtcompany.com>
Diffstat (limited to 'src/plugins/platforms/cocoa/qprintengine_mac.mm')
-rw-r--r-- | src/plugins/platforms/cocoa/qprintengine_mac.mm | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/plugins/platforms/cocoa/qprintengine_mac.mm b/src/plugins/platforms/cocoa/qprintengine_mac.mm index edd1d656f0..000a9c46c8 100644 --- a/src/plugins/platforms/cocoa/qprintengine_mac.mm +++ b/src/plugins/platforms/cocoa/qprintengine_mac.mm @@ -470,7 +470,6 @@ void QMacPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &va d->embedFonts = value.toBool(); break; case PPK_Resolution: { - // TODO It appears the old code didn't actually set the resolution??? Can we delete all this??? int bestResolution = 0; int dpi = value.toInt(); int bestDistance = INT_MAX; @@ -486,7 +485,17 @@ void QMacPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &va } } } - PMSessionValidatePageFormat(d->session(), d->format(), kPMDontWantBoolean); + PMResolution resolution; + resolution.hRes = resolution.vRes = bestResolution; + if (PMPrinterSetOutputResolution(d->m_printDevice->macPrinter(), d->settings(), &resolution) == noErr) { + // Setting the resolution succeeded. + // Now try to read the actual resolution selected by the OS. + if (PMPrinterGetOutputResolution(d->m_printDevice->macPrinter(), d->settings(), &d->resolution) != noErr) { + // Reading the resolution somehow failed; d->resolution is in undefined state. + // So use the value which was acceptable to PMPrinterSetOutputResolution. + d->resolution = resolution; + } + } break; } case PPK_CollateCopies: |