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>
This commit is contained in:
parent
debc44cf11
commit
44357dbe42
@ -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:
|
||||
|
@ -1628,7 +1628,24 @@ void tst_QPrinter::resolution()
|
||||
// Test set/get
|
||||
int expected = 333;
|
||||
#ifdef Q_OS_MAC
|
||||
// Set resolution does nothing on OSX, see QTBUG-7000
|
||||
// QMacPrintEngine chooses the closest supported resolution.
|
||||
const QList<int> all_supported = native.supportedResolutions();
|
||||
foreach (int supported, all_supported) {
|
||||
// Test setting a supported resolution
|
||||
int requested = supported;
|
||||
native.setResolution(requested);
|
||||
QCOMPARE(native.resolution(), requested);
|
||||
|
||||
// Test setting an unsupported resolution
|
||||
do {
|
||||
requested += 5;
|
||||
} while (all_supported.contains(requested));
|
||||
native.setResolution(requested);
|
||||
int result = native.resolution();
|
||||
QVERIFY(all_supported.contains(result));
|
||||
QVERIFY(qAbs(result - requested) <= qAbs(supported - requested));
|
||||
}
|
||||
|
||||
expected = native.resolution();
|
||||
#endif // Q_OS_MAC
|
||||
native.setResolution(expected);
|
||||
|
Loading…
Reference in New Issue
Block a user