From d2a589e1f0c9c7770bc1161296f7041046c3c369 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Tue, 10 Jan 2017 06:33:55 +0100 Subject: [PATCH] When changing the printer used, try to preserve the original page settings Since not all elements of the original page settings can be kept, it needs to be set bit by bit in order to apply what it can. Change-Id: I82a2de91e3b8e344a61a290bb4486885fde62b4e Reviewed-by: Friedemann Kleint --- src/printsupport/kernel/qprintengine_win.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/printsupport/kernel/qprintengine_win.cpp b/src/printsupport/kernel/qprintengine_win.cpp index 706a7c4b02..5a48e92a3a 100644 --- a/src/printsupport/kernel/qprintengine_win.cpp +++ b/src/printsupport/kernel/qprintengine_win.cpp @@ -1224,11 +1224,20 @@ void QWin32PrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant & QPlatformPrinterSupport *ps = QPlatformPrinterSupportPlugin::get(); if (!ps) return; + + QVariant pageSize = QVariant::fromValue(d->m_pageLayout.pageSize()); + const bool isFullPage = (d->m_pageLayout.mode() == QPageLayout::FullPageMode); + QVariant orientation = QVariant::fromValue(d->m_pageLayout.orientation()); + QVariant margins = QVariant::fromValue( + QPair(d->m_pageLayout.margins(), d->m_pageLayout.units())); QPrintDevice printDevice = ps->createPrintDevice(id.isEmpty() ? ps->defaultPrintDeviceId() : id); if (printDevice.isValid()) { d->m_printDevice = printDevice; - // TODO Do we need to check if the page size is valid on new printer? d->initialize(); + setProperty(PPK_QPageSize, pageSize); + setProperty(PPK_FullPage, QVariant(isFullPage)); + setProperty(PPK_Orientation, orientation); + setProperty(PPK_QPageMargins, margins); } break; }