From f56f47bc64aeb7a2eea28c3734b57197fd4faa28 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Fri, 12 Jan 2018 15:02:43 +0100 Subject: [PATCH] Unix: Fix default printer page size margins Regressed with ff67dedaaff2dc68571ca9c8c6c6eeaaf084eae4 Before ff67dedaaff2dc68571ca9c8c6c6eeaaf084eae4 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 --- src/printsupport/dialogs/qpagesetupdialog_unix.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/printsupport/dialogs/qpagesetupdialog_unix.cpp b/src/printsupport/dialogs/qpagesetupdialog_unix.cpp index 20634085f8..13c91742f2 100644 --- a/src/printsupport/dialogs/qpagesetupdialog_unix.cpp +++ b/src/printsupport/dialogs/qpagesetupdialog_unix.cpp @@ -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) {