summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Layt <jlayt@kde.org>2013-11-29 19:13:49 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-02-05 19:33:54 +0100
commit0ee72b09fd99b756a85de78bafb03c7dee163ef5 (patch)
treee252fd5f7af2e21aea54eaa2611f28faee3d2bbb
parent27473f19bb26b5b4434689c663d483e48b43fdef (diff)
QPrintEngine - Fix PPK_CollateCopies
Mac supports Collate Copies using native api, so add support. Note this is mostly only useful for setting the print dialog default, as Mac supports server-side multiple copies so the app will never need to collate the copies itself. Change PDF and Windows to default to collate true to match Mac as this is the behavior users expect. Task-number: QTBUG-27724 Task-number: QTBUG-35251 Task-number: QTBUG-22144 Change-Id: Ia43dbc260b3a71aa5b267cca54c168ffbea794fc Reviewed-by: Lars Knoll <lars.knoll@digia.com>
-rw-r--r--src/plugins/platforms/cocoa/qprintengine_mac.mm16
-rw-r--r--src/plugins/printsupport/cups/qcupsprintengine.cpp2
-rw-r--r--src/printsupport/kernel/qprintengine_pdf.cpp2
-rw-r--r--src/printsupport/kernel/qprintengine_win.cpp9
-rw-r--r--tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp31
5 files changed, 30 insertions, 30 deletions
diff --git a/src/plugins/platforms/cocoa/qprintengine_mac.mm b/src/plugins/platforms/cocoa/qprintengine_mac.mm
index 170eccdd1b..b11afc745e 100644
--- a/src/plugins/platforms/cocoa/qprintengine_mac.mm
+++ b/src/plugins/platforms/cocoa/qprintengine_mac.mm
@@ -607,9 +607,6 @@ void QMacPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &va
// 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;
@@ -662,6 +659,9 @@ void QMacPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &va
PMSessionValidatePageFormat(d->session(), d->format(), kPMDontWantBoolean);
break;
}
+ case PPK_CollateCopies:
+ PMSetCollate(d->settings(), value.toBool());
+ break;
case PPK_DocumentName:
PMPrintSettingsSetJobName(d->settings(), QCFString(value.toString()));
break;
@@ -756,10 +756,6 @@ QVariant QMacPrintEngine::property(PrintEnginePropertyKey key) const
// 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;
@@ -802,6 +798,12 @@ QVariant QMacPrintEngine::property(PrintEnginePropertyKey key) const
break;
// The following keys are properties and settings that are supported by the Mac PrintEngine
+ case PPK_CollateCopies: {
+ Boolean status;
+ PMGetCollate(d->settings(), &status);
+ ret = bool(status);
+ break;
+ }
case PPK_DocumentName: {
CFStringRef name;
PMPrintSettingsGetJobName(d->settings(), &name);
diff --git a/src/plugins/printsupport/cups/qcupsprintengine.cpp b/src/plugins/printsupport/cups/qcupsprintengine.cpp
index 1c86420cb2..2fecdc00e9 100644
--- a/src/plugins/printsupport/cups/qcupsprintengine.cpp
+++ b/src/plugins/printsupport/cups/qcupsprintengine.cpp
@@ -221,7 +221,7 @@ void QCupsPrintEnginePrivate::closePrintDevice()
if (copies > 1)
options.append(QPair<QByteArray, QByteArray>("copies", QString::number(copies).toLocal8Bit()));
- if (collate)
+ if (copies > 1 && collate)
options.append(QPair<QByteArray, QByteArray>("Collate", "True"));
switch (duplex) {
diff --git a/src/printsupport/kernel/qprintengine_pdf.cpp b/src/printsupport/kernel/qprintengine_pdf.cpp
index f5c80b4cae..6c65300462 100644
--- a/src/printsupport/kernel/qprintengine_pdf.cpp
+++ b/src/printsupport/kernel/qprintengine_pdf.cpp
@@ -386,7 +386,7 @@ void QPdfPrintEnginePrivate::closePrintDevice()
QPdfPrintEnginePrivate::QPdfPrintEnginePrivate(QPrinter::PrinterMode m)
: QPdfEnginePrivate(),
duplex(QPrinter::DuplexNone),
- collate(false),
+ collate(true),
copies(1),
pageOrder(QPrinter::FirstPageFirst),
paperSource(QPrinter::Auto),
diff --git a/src/printsupport/kernel/qprintengine_win.cpp b/src/printsupport/kernel/qprintengine_win.cpp
index 34f3106313..d48c1a730d 100644
--- a/src/printsupport/kernel/qprintengine_win.cpp
+++ b/src/printsupport/kernel/qprintengine_win.cpp
@@ -1098,6 +1098,7 @@ void QWin32PrintEnginePrivate::initialize()
if (devMode) {
num_copies = devMode->dmCopies;
+ devMode->dmCollate = DMCOLLATE_TRUE;
}
initHDC();
@@ -1504,10 +1505,6 @@ QVariant QWin32PrintEngine::property(PrintEnginePropertyKey key) const
// 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;
@@ -1529,6 +1526,10 @@ QVariant QWin32PrintEngine::property(PrintEnginePropertyKey key) const
break;
// The following keys are properties and settings that are supported by the Windows PrintEngine
+ case PPK_CollateCopies:
+ value = d->devMode->dmCollate == DMCOLLATE_TRUE;
+ break;
+
case PPK_ColorMode:
{
if (!d->devMode) {
diff --git a/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp b/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp
index 322254602d..054800d829 100644
--- a/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp
+++ b/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp
@@ -890,21 +890,21 @@ void tst_QPrinter::testMultipleKeys()
QCOMPARE(native.fullPage(), false);
QCOMPARE(native.orientation(), QPrinter::Portrait);
QCOMPARE(native.copyCount(), 1);
- QCOMPARE(native.collateCopies(), false);
+ QCOMPARE(native.collateCopies(), true);
QCOMPARE(native.printRange(), QPrinter::AllPages);
// Change values
native.setFullPage(true);
native.setOrientation(QPrinter::Landscape);
native.setCopyCount(9);
- native.setCollateCopies(true);
+ native.setCollateCopies(false);
native.setPrintRange(QPrinter::CurrentPage);
// Check changed values
QCOMPARE(native.fullPage(), true);
QCOMPARE(native.orientation(), QPrinter::Landscape);
QCOMPARE(native.copyCount(), 9);
- QCOMPARE(native.collateCopies(), true);
+ QCOMPARE(native.collateCopies(), false);
QCOMPARE(native.printRange(), QPrinter::CurrentPage);
// Test value preservation
@@ -912,21 +912,21 @@ void tst_QPrinter::testMultipleKeys()
QCOMPARE(native.fullPage(), true);
QCOMPARE(native.orientation(), QPrinter::Landscape);
QCOMPARE(native.copyCount(), 9);
- QCOMPARE(native.collateCopies(), true);
+ QCOMPARE(native.collateCopies(), false);
QCOMPARE(native.printRange(), QPrinter::CurrentPage);
// Change values
native.setFullPage(false);
native.setOrientation(QPrinter::Portrait);
native.setCopyCount(5);
- native.setCollateCopies(false);
+ native.setCollateCopies(true);
native.setPrintRange(QPrinter::PageRange);
// Check changed values
QCOMPARE(native.fullPage(), false);
QCOMPARE(native.orientation(), QPrinter::Portrait);
QCOMPARE(native.copyCount(), 5);
- QCOMPARE(native.collateCopies(), false);
+ QCOMPARE(native.collateCopies(), true);
QCOMPARE(native.printRange(), QPrinter::PageRange);
} else {
QSKIP("No printers installed, cannot test NativeFormat, please install printers to test");
@@ -936,28 +936,25 @@ void tst_QPrinter::testMultipleKeys()
void tst_QPrinter::collateCopies()
{
// collateCopies() / setCollateCopies() / PPK_ColorMode
- // PdfFormat: Supported, default false
- // NativeFormat, Cups: Supported, default false
- // NativeFormat, Win: Part Supported if valid DevMode, can set but always returns false
- // NativeFormat, Mac: Unsupported, always false
+ // PdfFormat: Supported, default true
+ // NativeFormat, Cups: Supported, default true
+ // NativeFormat, Win: Supported, default true
+ // NativeFormat, Mac: Supported, default true
QPrinter pdf;
pdf.setOutputFormat(QPrinter::PdfFormat);
- QCOMPARE(pdf.collateCopies(), false);
- pdf.setCollateCopies(true);
QCOMPARE(pdf.collateCopies(), true);
+ pdf.setCollateCopies(false);
+ QCOMPARE(pdf.collateCopies(), false);
QPrinter native;
if (native.outputFormat() == QPrinter::NativeFormat) {
// Test default
- QCOMPARE(native.collateCopies(), false);
+ QCOMPARE(native.collateCopies(), true);
// Test set/get
- bool expected = true;
+ bool expected = false;
native.setCollateCopies(expected);
-#if defined Q_OS_MAC || defined Q_OS_WIN
- expected = false;
-#endif // Q_OS_MAC
QCOMPARE(native.collateCopies(), expected);
// Test value preservation