summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorJohn Layt <jlayt@kde.org>2013-12-30 18:04:40 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-17 13:46:10 +0100
commitdbc50e06df8465e6de02ac0b4458e1a3f3f8568c (patch)
tree58375129a608575a7b99e6a3167baa668c9d7c25 /src/plugins
parent70081096a152d6973d85a1c1466bbc058fe0b24b (diff)
QPrinter - Use QPageSize and QPageLayout
Use QPageSize and QPageMargins to get/set values in the print engines, add api to directly set the values, and rewrite the docs to make the paper-based api obsolete instead of the page-based api. Add new PPK keys to pass QPageSize, QPageMargins and QPageLayout to the print engines to ensure no level of detail is lost, e.g. for custom sizes passed to QPrinter. [ChangeLog][QtPrintSupport][QPrinter] QPrinter can now use QPageSize and QPageLayout in the public api to control the page layout for a print job. Change-Id: Iee39a4042bcd6141d29b0a82b49066d7a7a78120 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/platforms/cocoa/qprintengine_mac.mm32
-rw-r--r--src/plugins/printsupport/cups/qcupsprintengine.cpp12
2 files changed, 43 insertions, 1 deletions
diff --git a/src/plugins/platforms/cocoa/qprintengine_mac.mm b/src/plugins/platforms/cocoa/qprintengine_mac.mm
index bfe44c7ab3..95713eba59 100644
--- a/src/plugins/platforms/cocoa/qprintengine_mac.mm
+++ b/src/plugins/platforms/cocoa/qprintengine_mac.mm
@@ -42,7 +42,7 @@
#include "qprintengine_mac_p.h"
#include "qcocoaprintersupport.h"
#include <quuid.h>
-#include <QtGui/qpagesize.h>
+#include <QtGui/qpagelayout.h>
#include <QtCore/qcoreapplication.h>
#include <QtCore/qdebug.h>
@@ -559,6 +559,26 @@ void QMacPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &va
margins.at(2).toReal(), margins.at(3).toReal()));
break;
}
+ case PPK_QPageSize:
+ d->setPageSize(value.value<QPageSize>());
+ break;
+ case PPK_QPageMargins: {
+ QPair<QMarginsF, QPageLayout::Unit> pair = value.value<QPair<QMarginsF, QPageLayout::Unit> >();
+ d->m_pageLayout.setUnits(pair.second);
+ d->m_pageLayout.setMargins(pair.first);
+ break;
+ }
+ case PPK_QPageLayout: {
+ QPageLayout pageLayout = value.value<QPageLayout>();
+ if (pageLayout.isValid() && d->m_printDevice->isValidPageLayout(pageLayout, d->resolution.hRes)) {
+ setProperty(PPK_QPageSize, QVariant::fromValue(pageLayout.pageSize()));
+ setProperty(PPK_FullPage, pageLayout.mode() == QPageLayout::FullPageMode);
+ setProperty(PPK_Orientation, QVariant::fromValue(pageLayout.orientation()));
+ d->m_pageLayout.setUnits(pageLayout.units());
+ d->m_pageLayout.setMargins(pageLayout.margins());
+ }
+ break;
+ }
// No default so that compiler will complain if new keys added and not handled in this engine
}
}
@@ -688,6 +708,16 @@ QVariant QMacPrintEngine::property(PrintEnginePropertyKey key) const
ret = list;
break;
}
+ case PPK_QPageSize:
+ ret.setValue(d->m_pageLayout.pageSize());
+ break;
+ case PPK_QPageMargins: {
+ QPair<QMarginsF, QPageLayout::Unit> pair = qMakePair(d->m_pageLayout.margins(), d->m_pageLayout.units());
+ ret.setValue(pair);
+ break;
+ }
+ case PPK_QPageLayout:
+ ret.setValue(d->m_pageLayout);
// No default so that compiler will complain if new keys added and not handled in this engine
}
return ret;
diff --git a/src/plugins/printsupport/cups/qcupsprintengine.cpp b/src/plugins/printsupport/cups/qcupsprintengine.cpp
index 2c05a76084..90de1a2a8b 100644
--- a/src/plugins/printsupport/cups/qcupsprintengine.cpp
+++ b/src/plugins/printsupport/cups/qcupsprintengine.cpp
@@ -96,6 +96,18 @@ void QCupsPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &v
case PPK_CupsOptions:
d->cupsOptions = value.toStringList();
break;
+ case PPK_QPageSize:
+ d->setPageSize(value.value<QPageSize>());
+ break;
+ case PPK_QPageLayout: {
+ QPageLayout pageLayout = value.value<QPageLayout>();
+ if (pageLayout.isValid() && d->m_printDevice.isValidPageLayout(pageLayout, d->resolution)) {
+ d->m_pageLayout = pageLayout;
+ // Replace the page size with the CUPS page size
+ d->setPageSize(d->m_printDevice.supportedPageSize(pageLayout.pageSize()));
+ }
+ break;
+ }
default:
QPdfPrintEngine::setProperty(key, value);
break;