From ceccdff4e9fc93819d819b8ed15d95822f980505 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Mon, 4 Dec 2017 13:10:17 +0100 Subject: [PATCH 07/54] Remove QPageSetupWidget::selectPrinter t's only ever called after setPrinter so merge the code Change-Id: I4b5d593edbe62b64354e81c19112fa87b0555fdc Reviewed-by: Andy Shaw --- src/printsupport/dialogs/qpagesetupdialog_unix.cpp | 12 ++---------- src/printsupport/dialogs/qpagesetupdialog_unix_p.h | 3 +-- src/printsupport/dialogs/qprintdialog_unix.cpp | 3 +-- 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/src/printsupport/dialogs/qpagesetupdialog_unix.cpp b/src/printsupport/dialogs/qpagesetupdialog_unix.cpp index c321552a19..49c0184289 100644 --- a/src/printsupport/dialogs/qpagesetupdialog_unix.cpp +++ b/src/printsupport/dialogs/qpagesetupdialog_unix.cpp @@ -210,7 +210,7 @@ void QUnixPageSetupDialogPrivate::init() Q_Q(QPageSetupDialog); widget = new QPageSetupWidget(q); - widget->setPrinter(printer); + widget->setPrinter(printer, printer->outputFormat(), printer->printerName()); QDialogButtonBox *buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, @@ -371,7 +371,7 @@ void QPageSetupWidget::initPageSizes() // Set the dialog to use the given QPrinter // Usually only called on first creation -void QPageSetupWidget::setPrinter(QPrinter *printer) +void QPageSetupWidget::setPrinter(QPrinter *printer, QPrinter::OutputFormat outputFormat, const QString &printerName) { m_printer = printer; @@ -387,14 +387,6 @@ void QPageSetupWidget::setPrinter(QPrinter *printer) m_units = m_pageLayout.units(); m_pagePreview->setPageLayout(m_pageLayout); - // Then update the widget with the current printer details - selectPrinter(m_printer->outputFormat(), m_printer->printerName()); -} - -// The printer selected in the QPrintDialog has been changed, update the widget to reflect this -// Note the QPrinter is not updated at this time in case the user presses the Cancel button in QPrintDialog -void QPageSetupWidget::selectPrinter(QPrinter::OutputFormat outputFormat, const QString &printerName) -{ m_outputFormat = outputFormat; m_printerName = printerName; initPageSizes(); diff --git a/src/printsupport/dialogs/qpagesetupdialog_unix_p.h b/src/printsupport/dialogs/qpagesetupdialog_unix_p.h index 658f103bea..c57b01c2d6 100644 --- a/src/printsupport/dialogs/qpagesetupdialog_unix_p.h +++ b/src/printsupport/dialogs/qpagesetupdialog_unix_p.h @@ -72,8 +72,7 @@ public: explicit QPageSetupWidget(QWidget *parent = 0); explicit QPageSetupWidget(QPrinter *printer, QWidget *parent = 0); - void setPrinter(QPrinter *printer); - void selectPrinter(QPrinter::OutputFormat outputFormat, const QString &printerName); + void setPrinter(QPrinter *printer, QPrinter::OutputFormat outputFormat, const QString &printerName); void setupPrinter() const; private slots: diff --git a/src/printsupport/dialogs/qprintdialog_unix.cpp b/src/printsupport/dialogs/qprintdialog_unix.cpp index c7f7488917..f87630f1a0 100644 --- a/src/printsupport/dialogs/qprintdialog_unix.cpp +++ b/src/printsupport/dialogs/qprintdialog_unix.cpp @@ -248,8 +248,7 @@ QPrintPropertiesDialog::QPrintPropertiesDialog(QPrinter *printer, QPrinter::Outp connect(m_buttons->button(QDialogButtonBox::Ok), SIGNAL(clicked()), this, SLOT(accept())); connect(m_buttons->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), this, SLOT(reject())); - widget.pageSetup->setPrinter(printer); - widget.pageSetup->selectPrinter(outputFormat, printerName); + widget.pageSetup->setPrinter(printer, outputFormat, printerName); #if QT_CONFIG(cupsjobwidget) m_jobOptions = new QCupsJobWidget(printer); -- 2.15.1