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 <Friedemann.Kleint@qt.io>
bb10
Andy Shaw 2017-01-10 06:33:55 +01:00
parent 11875b89f4
commit d2a589e1f0
1 changed files with 10 additions and 1 deletions

View File

@ -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<QMarginsF, QPageLayout::Unit>(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;
}