QPrinter - Clean up Print Engine Key defaults and tests
The PrintEngine keys are not consistently treated across the platforms and are not properly tested. Start the process of making the print engines behave consistently by documenting and testing the current behavior. Ensure all unsupported features return a consistent default value. The auto test for valuePreservation() has been flaky depending on the platform and installed printers so remove it and replace it with more complete testing. If no native printers available then don't test the native engines. Fixes for the individual inconsistent keys will follow. Task-number: QTBUG-26430 Change-Id: Iab914d7e0a5ae4a2cdc24c8645751f0910cf440c Reviewed-by: Lars Knoll <lars.knoll@digia.com>
This commit is contained in:
parent
aae1eb3b03
commit
053bee8b80
@ -591,20 +591,52 @@ void QMacPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &va
|
||||
return;
|
||||
|
||||
switch (key) {
|
||||
case PPK_CollateCopies:
|
||||
|
||||
// The following keys are properties or derived values and so cannot be set
|
||||
case PPK_PageRect:
|
||||
break;
|
||||
case PPK_PaperRect:
|
||||
break;
|
||||
case PPK_PaperSources:
|
||||
break;
|
||||
case PPK_SupportsMultipleCopies:
|
||||
break;
|
||||
case PPK_SupportedResolutions:
|
||||
break;
|
||||
|
||||
// The following keys are settings that are unsupported by the Mac PrintEngine
|
||||
case PPK_ColorMode:
|
||||
break;
|
||||
case PPK_CollateCopies:
|
||||
// TODO Add support using PMSetCollate / PMGetCollate
|
||||
break;
|
||||
case PPK_Creator:
|
||||
// TODO Add value preservation support by using local variable
|
||||
break;
|
||||
case PPK_CustomBase:
|
||||
break;
|
||||
case PPK_DocumentName:
|
||||
// TODO Add support using PMPrintSettingsSetJobName / PMPrintSettingsGetJobName
|
||||
break;
|
||||
case PPK_Duplex:
|
||||
// TODO Add support using PMSetDuplex / PMGetDuplex
|
||||
break;
|
||||
case PPK_FontEmbedding:
|
||||
break;
|
||||
case PPK_PageOrder:
|
||||
// TODO Check if can be supported via Cups Options
|
||||
break;
|
||||
case PPK_PaperSource:
|
||||
// TODO Check if can be supported via Cups Options
|
||||
break;
|
||||
case PPK_PrinterProgram:
|
||||
break;
|
||||
case PPK_SelectionOption:
|
||||
break;
|
||||
case PPK_WindowsPageSize:
|
||||
break;
|
||||
|
||||
// The following keys are properties and settings that are supported by the Mac PrintEngine
|
||||
case PPK_Resolution: {
|
||||
PMPrinter printer;
|
||||
UInt32 count;
|
||||
@ -709,9 +741,7 @@ void QMacPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &va
|
||||
d->hasCustomPageMargins = true;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
// No default so that compiler will complain if new keys added and not handled in this engine
|
||||
}
|
||||
}
|
||||
|
||||
@ -724,16 +754,59 @@ QVariant QMacPrintEngine::property(PrintEnginePropertyKey key) const
|
||||
return *d->valueCache.find(key);
|
||||
|
||||
switch (key) {
|
||||
|
||||
// The following keys are settings that are unsupported by the Mac PrintEngine
|
||||
// Return sensible default values to ensure consistent behavior across platforms
|
||||
case PPK_CollateCopies:
|
||||
// TODO Add support using PMSetCollate / PMGetCollate
|
||||
ret = false;
|
||||
break;
|
||||
case PPK_ColorMode:
|
||||
ret = QPrinter::Color;
|
||||
break;
|
||||
case PPK_Creator:
|
||||
ret = QString();
|
||||
break;
|
||||
case PPK_CustomBase:
|
||||
// Special case, leave null
|
||||
break;
|
||||
case PPK_DocumentName:
|
||||
// TODO Add support using PMPrintSettingsSetJobName / PMPrintSettingsGetJobName
|
||||
ret = QString();
|
||||
break;
|
||||
case PPK_Duplex:
|
||||
// TODO Add support using PMSetDuplex / PMGetDuplex
|
||||
ret = QPrinter::DuplexNone;
|
||||
break;
|
||||
case PPK_FontEmbedding:
|
||||
ret = false;
|
||||
break;
|
||||
case PPK_PageOrder:
|
||||
// TODO Check if can be supported via Cups Options
|
||||
ret = QPrinter::FirstPageFirst;
|
||||
break;
|
||||
case PPK_PaperSource:
|
||||
// TODO Check if can be supported via Cups Options
|
||||
ret = QPrinter::Auto;
|
||||
break;
|
||||
case PPK_PaperSources: {
|
||||
// TODO Check if can be supported via Cups Options
|
||||
QList<QVariant> out;
|
||||
out << int(QPrinter::Auto);
|
||||
ret = out;
|
||||
break;
|
||||
}
|
||||
case PPK_PrinterProgram:
|
||||
ret = QString();
|
||||
break;
|
||||
case PPK_SelectionOption:
|
||||
ret = QString();
|
||||
break;
|
||||
case PPK_WindowsPageSize:
|
||||
// Special case, leave null
|
||||
break;
|
||||
|
||||
// The following keys are properties and settings that are supported by the Mac PrintEngine
|
||||
case PPK_FullPage:
|
||||
ret = d->fullPage;
|
||||
break;
|
||||
@ -757,10 +830,6 @@ QVariant QMacPrintEngine::property(PrintEnginePropertyKey key) const
|
||||
case PPK_OutputFileName:
|
||||
ret = d->outputFilename;
|
||||
break;
|
||||
case PPK_PageOrder:
|
||||
break;
|
||||
case PPK_PaperSource:
|
||||
break;
|
||||
case PPK_PageRect: {
|
||||
// PageRect is returned in device pixels
|
||||
QRect r;
|
||||
@ -855,8 +924,7 @@ QVariant QMacPrintEngine::property(PrintEnginePropertyKey key) const
|
||||
ret = margins;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
// No default so that compiler will complain if new keys added and not handled in this engine
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -147,6 +147,28 @@ void QPdfPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &va
|
||||
Q_D(QPdfPrintEngine);
|
||||
|
||||
switch (int(key)) {
|
||||
|
||||
// The following keys are properties or derived values and so cannot be set
|
||||
case PPK_PageRect:
|
||||
break;
|
||||
case PPK_PaperRect:
|
||||
break;
|
||||
case PPK_PaperSources:
|
||||
break;
|
||||
case PPK_SupportsMultipleCopies:
|
||||
break;
|
||||
case PPK_SupportedResolutions:
|
||||
break;
|
||||
|
||||
// The following keys are settings that are unsupported by the PDF PrintEngine
|
||||
case PPK_CustomBase:
|
||||
break;
|
||||
case PPK_PaperName:
|
||||
break;
|
||||
case PPK_WindowsPageSize:
|
||||
break;
|
||||
|
||||
// The following keys are properties and settings that are supported by the PDF PrintEngine
|
||||
case PPK_CollateCopies:
|
||||
d->collate = value.toBool();
|
||||
break;
|
||||
@ -216,8 +238,7 @@ void QPdfPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &va
|
||||
d->pageMarginsSet = true;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
// No default so that compiler will complain if new keys added and not handled in this engine
|
||||
}
|
||||
}
|
||||
|
||||
@ -227,6 +248,20 @@ QVariant QPdfPrintEngine::property(PrintEnginePropertyKey key) const
|
||||
|
||||
QVariant ret;
|
||||
switch (int(key)) {
|
||||
|
||||
// The following keys are settings that are unsupported by the PDF PrintEngine
|
||||
// Return sensible default values to ensure consistent behavior across platforms
|
||||
case PPK_CustomBase:
|
||||
// Special case, leave null
|
||||
break;
|
||||
case PPK_PaperName:
|
||||
ret = QString();
|
||||
break;
|
||||
case PPK_WindowsPageSize:
|
||||
// Special case, leave null
|
||||
break;
|
||||
|
||||
// The following keys are properties and settings that are supported by the PDF PrintEngine
|
||||
case PPK_CollateCopies:
|
||||
ret = d->collate;
|
||||
break;
|
||||
@ -307,8 +342,7 @@ QVariant QPdfPrintEngine::property(PrintEnginePropertyKey key) const
|
||||
ret = margins;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
// No default so that compiler will complain if new keys added and not handled in this engine
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -1273,6 +1273,38 @@ void QWin32PrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &
|
||||
{
|
||||
Q_D(QWin32PrintEngine);
|
||||
switch (key) {
|
||||
|
||||
// The following keys are properties or derived values and so cannot be set
|
||||
case PPK_PageRect:
|
||||
break;
|
||||
case PPK_PaperRect:
|
||||
break;
|
||||
case PPK_PaperSources:
|
||||
break;
|
||||
case PPK_SupportsMultipleCopies:
|
||||
break;
|
||||
case PPK_SupportedResolutions:
|
||||
break;
|
||||
|
||||
// The following keys are settings that are unsupported by the Windows PrintEngine
|
||||
case PPK_Creator:
|
||||
// TODO Add value preservation support by using local variable
|
||||
break;
|
||||
case PPK_CustomBase:
|
||||
break;
|
||||
case PPK_Duplex:
|
||||
// TODO Add support using DEVMODE.dmDuplex
|
||||
break;
|
||||
case PPK_FontEmbedding:
|
||||
break;
|
||||
case PPK_PageOrder:
|
||||
break;
|
||||
case PPK_PrinterProgram:
|
||||
break;
|
||||
case PPK_SelectionOption:
|
||||
break;
|
||||
|
||||
// The following keys are properties and settings that are supported by the Windows PrintEngine
|
||||
case PPK_CollateCopies:
|
||||
{
|
||||
if (!d->devMode)
|
||||
@ -1291,10 +1323,6 @@ void QWin32PrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &
|
||||
}
|
||||
break;
|
||||
|
||||
case PPK_Creator:
|
||||
|
||||
break;
|
||||
|
||||
case PPK_DocumentName:
|
||||
if (isActive()) {
|
||||
qWarning("QWin32PrintEngine: Cannot change document name while printing is active");
|
||||
@ -1347,6 +1375,7 @@ void QWin32PrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &
|
||||
setDevModePaperFlags(d->devMode, d->has_custom_paper_size);
|
||||
d->doReinit();
|
||||
break;
|
||||
|
||||
case PPK_PaperName:
|
||||
{
|
||||
if (!d->devMode)
|
||||
@ -1416,15 +1445,6 @@ void QWin32PrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &
|
||||
}
|
||||
break;
|
||||
|
||||
case PPK_SelectionOption:
|
||||
|
||||
break;
|
||||
|
||||
case PPK_SupportedResolutions:
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case PPK_WindowsPageSize:
|
||||
if (!d->devMode)
|
||||
break;
|
||||
@ -1468,9 +1488,9 @@ void QWin32PrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &
|
||||
d->setPageMargins(left, top, right, bottom);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
// Do nothing
|
||||
break;
|
||||
|
||||
// No default so that compiler will complain if new keys added and not handled in this engine
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -1480,10 +1500,33 @@ QVariant QWin32PrintEngine::property(PrintEnginePropertyKey key) const
|
||||
QVariant value;
|
||||
switch (key) {
|
||||
|
||||
// The following keys are settings that are unsupported by the Windows PrintEngine
|
||||
// Return sensible default values to ensure consistent behavior across platforms
|
||||
case PPK_CollateCopies:
|
||||
// TODO Add support using DEVMODE.dmCollate to match setting
|
||||
value = false;
|
||||
break;
|
||||
case PPK_Creator:
|
||||
value = QString();
|
||||
break;
|
||||
case PPK_Duplex:
|
||||
// TODO Add support using DEVMODE.dmDuplex
|
||||
value = QPrinter::DuplexNone;
|
||||
break;
|
||||
case PPK_FontEmbedding:
|
||||
value = false;
|
||||
break;
|
||||
case PPK_PageOrder:
|
||||
value = QPrinter::FirstPageFirst;
|
||||
break;
|
||||
case PPK_PrinterProgram:
|
||||
value = QString();
|
||||
break;
|
||||
case PPK_SelectionOption:
|
||||
value = QString();
|
||||
break;
|
||||
|
||||
// The following keys are properties and settings that are supported by the Windows PrintEngine
|
||||
case PPK_ColorMode:
|
||||
{
|
||||
if (!d->devMode) {
|
||||
@ -1567,6 +1610,7 @@ QVariant QWin32PrintEngine::property(PrintEnginePropertyKey key) const
|
||||
value = QTransform(1/d->stretch_x, 0, 0, 1/d->stretch_y, 0, 0).mapRect(d->devPaperRect);
|
||||
}
|
||||
break;
|
||||
|
||||
case PPK_PaperName:
|
||||
if (!d->devMode) {
|
||||
value = QLatin1String("A4");
|
||||
@ -1596,6 +1640,7 @@ QVariant QWin32PrintEngine::property(PrintEnginePropertyKey key) const
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case PPK_PaperSource:
|
||||
if (!d->devMode) {
|
||||
value = QPrinter::Auto;
|
||||
@ -1670,9 +1715,9 @@ QVariant QWin32PrintEngine::property(PrintEnginePropertyKey key) const
|
||||
value = margins;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
// Do nothing
|
||||
break;
|
||||
|
||||
// No default so that compiler will complain if new keys added and not handled in this engine
|
||||
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
@ -226,7 +226,6 @@ void QPrinterPrivate::changeEngines(QPrinter::OutputFormat format, const QPrinte
|
||||
prop = QVariant(q_ptr->copyCount());
|
||||
else if (key != QPrintEngine::PPK_PrinterName)
|
||||
prop = oldPrintEngine->property(key);
|
||||
|
||||
if (prop.isValid())
|
||||
setProperty(key, prop);
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user