diff options
author | Albert Astals Cid <albert.astals.cid@kdab.com> | 2017-12-27 11:12:19 +0100 |
---|---|---|
committer | Albert Astals Cid <albert.astals.cid@kdab.com> | 2018-01-12 12:04:35 +0000 |
commit | d94ccf310a9ca01593750a34f743ec652f6a344e (patch) | |
tree | 433bb5afded8f1ab5c9070f0062a98fd879e318a /src/printsupport/dialogs/qpagesetupdialog_unix.cpp | |
parent | 114f7952217c9cbe7d0054bdcbef775a5923e4a0 (diff) |
Unix: Fix usability of the print properties dialog
Previous behavior:
* Open, change setting, cancel, open again, setting was as originally (i.e. unchanged)
* Open, change setting, accept, open, change setting, cancel, open again, the setting would be as before pressing cancel
* Open, change setting, accept, open, press cancel without changing anything, print, the initially changed setting is not applied
New behavior:
* Pressing cancel just cancels the changes since you opened the dialog, everything you accepted previously stays correctly selected
Change-Id: I483647504682f26d3d21c5229cc6530bf14fe519
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
Diffstat (limited to 'src/printsupport/dialogs/qpagesetupdialog_unix.cpp')
-rw-r--r-- | src/printsupport/dialogs/qpagesetupdialog_unix.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/printsupport/dialogs/qpagesetupdialog_unix.cpp b/src/printsupport/dialogs/qpagesetupdialog_unix.cpp index 408621252f..20634085f8 100644 --- a/src/printsupport/dialogs/qpagesetupdialog_unix.cpp +++ b/src/printsupport/dialogs/qpagesetupdialog_unix.cpp @@ -234,6 +234,9 @@ QPageSetupWidget::QPageSetupWidget(QWidget *parent) m_printer(nullptr), m_outputFormat(QPrinter::PdfFormat), m_units(QPageLayout::Point), + m_savedUnits(QPageLayout::Point), + m_savedPagesPerSheet(-1), + m_savedPagesPerSheetLayout(-1), m_blockSignals(false), m_realCustomPageSizeIndex(-1) { @@ -404,6 +407,7 @@ void QPageSetupWidget::setPrinter(QPrinter *printer, QPrintDevice *printDevice, m_printerName = printerName; initPageSizes(); updateWidget(); + updateSavedValues(); } // Update the widget with the current settings @@ -487,6 +491,7 @@ void QPageSetupWidget::updateWidget() m_ui.pageHeight->setEnabled(isCustom); m_ui.heightLabel->setEnabled(isCustom); + m_ui.portrait->setChecked(m_pageLayout.orientation() == QPageLayout::Portrait); m_ui.landscape->setChecked(m_pageLayout.orientation() == QPageLayout::Landscape); m_ui.pagesPerSheetButtonGroup->setEnabled(m_outputFormat == QPrinter::NativeFormat); @@ -515,6 +520,26 @@ void QPageSetupWidget::setupPrinter() const #endif } +void QPageSetupWidget::updateSavedValues() +{ + m_savedUnits = m_units; + m_savedPageLayout = m_pageLayout; + m_savedPagesPerSheet = m_ui.pagesPerSheetCombo->currentIndex(); + m_savedPagesPerSheetLayout = m_ui.pagesPerSheetLayoutCombo->currentIndex(); +} + +void QPageSetupWidget::revertToSavedValues() +{ + m_units = m_savedUnits; + m_pageLayout = m_savedPageLayout; + m_pagePreview->setPageLayout(m_pageLayout); + + updateWidget(); + + m_ui.pagesPerSheetCombo->setCurrentIndex(m_savedPagesPerSheet); + m_ui.pagesPerSheetLayoutCombo->setCurrentIndex(m_savedPagesPerSheetLayout); +} + // Updates size/preview after the combobox has been changed. void QPageSetupWidget::pageSizeChanged() { |