Unix: Fix default printer page size margins

Regressed with ff67dedaaf

Before ff67dedaaf the print dialog
would not let you select less margin than the minimum printer
supported margin, this brings back the old behavior

Change-Id: I22f4e8ebf8ffa7c1653d61b7073a9ee582cf453b
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
bb10
Albert Astals Cid 2018-01-12 15:02:43 +01:00 committed by Frederik Gladhorn
parent ef60435d2f
commit f56f47bc64
1 changed files with 7 additions and 2 deletions

View File

@ -59,6 +59,8 @@
QT_BEGIN_NAMESPACE
extern QMarginsF qt_convertMargins(const QMarginsF &margins, QPageLayout::Unit fromUnits, QPageLayout::Unit toUnits);
// Disabled until we have support for papersources on unix
// #define PSD_ENABLE_PAPERSOURCE
@ -390,8 +392,11 @@ void QPageSetupWidget::setPrinter(QPrinter *printer, QPrintDevice *printDevice,
// Initialize the layout to the current QPrinter layout
m_pageLayout = m_printer->pageLayout();
if (printDevice)
m_pageLayout.setPageSize(printDevice->defaultPageSize());
if (printDevice) {
const QPageSize pageSize = printDevice->defaultPageSize();
const QMarginsF printable = printDevice->printableMargins(pageSize, m_pageLayout.orientation(), m_printer->resolution());
m_pageLayout.setPageSize(pageSize, qt_convertMargins(printable, QPageLayout::Point, m_pageLayout.units()));
}
// Assume if margins are Points then is by default, so set to locale default units
if (m_pageLayout.units() == QPageLayout::Point) {