From 072dd59de771d0c942afd68260251be71bd59542 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Mon, 4 Dec 2017 13:05:02 +0100 Subject: [PATCH 06/54] Remove QPrintPropertiesDialog::selectPrinter It is only ever called after the constructor, so merge the code Change-Id: I5c75a2cd367af401b41920f51754a64dc6c6eb40 Reviewed-by: Andy Shaw --- src/printsupport/dialogs/qprintdialog_unix.cpp | 30 +++++++++++++------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/printsupport/dialogs/qprintdialog_unix.cpp b/src/printsupport/dialogs/qprintdialog_unix.cpp index 8c9997d572..c7f7488917 100644 --- a/src/printsupport/dialogs/qprintdialog_unix.cpp +++ b/src/printsupport/dialogs/qprintdialog_unix.cpp @@ -124,11 +124,10 @@ class QPrintPropertiesDialog : public QDialog { Q_OBJECT public: - QPrintPropertiesDialog(QPrinter *printer, QAbstractPrintDialog *parent = nullptr); + QPrintPropertiesDialog(QPrinter *printer, QPrinter::OutputFormat outputFormat, + const QString &printerName, QAbstractPrintDialog *parent = nullptr); ~QPrintPropertiesDialog(); - void selectPrinter(QPrinter::OutputFormat outputFormat, const QString &printerName); - void setupPrinter() const; private: @@ -234,7 +233,8 @@ public: */ -QPrintPropertiesDialog::QPrintPropertiesDialog(QPrinter *printer, QAbstractPrintDialog *parent) +QPrintPropertiesDialog::QPrintPropertiesDialog(QPrinter *printer, QPrinter::OutputFormat outputFormat, + const QString &printerName, QAbstractPrintDialog *parent) : QDialog(parent) { setWindowTitle(tr("Printer Properties")); @@ -249,6 +249,7 @@ QPrintPropertiesDialog::QPrintPropertiesDialog(QPrinter *printer, QAbstractPrint connect(m_buttons->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), this, SLOT(reject())); widget.pageSetup->setPrinter(printer); + widget.pageSetup->selectPrinter(outputFormat, printerName); #if QT_CONFIG(cupsjobwidget) m_jobOptions = new QCupsJobWidget(printer); @@ -268,11 +269,6 @@ void QPrintPropertiesDialog::setupPrinter() const #endif } -void QPrintPropertiesDialog::selectPrinter(QPrinter::OutputFormat outputFormat, const QString &printerName) -{ - widget.pageSetup->selectPrinter(outputFormat, printerName); -} - //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// @@ -838,16 +834,20 @@ void QUnixPrintWidgetPrivate::setupPrinterProperties() if (propertiesDialog) delete propertiesDialog; - propertiesDialog = new QPrintPropertiesDialog(q->printer(), q); - propertiesDialog->setResult(QDialog::Rejected); - propertiesDialogShown = false; + QPrinter::OutputFormat outputFormat; + QString printerName; if (q->isOptionEnabled(QPrintDialog::PrintToFile) && (widget.printers->currentIndex() == widget.printers->count() - 1)) {// PDF - propertiesDialog->selectPrinter(QPrinter::PdfFormat, QString()); + outputFormat = QPrinter::PdfFormat; + } else { + outputFormat = QPrinter::NativeFormat; + printerName = widget.printers->currentText(); } - else - propertiesDialog->selectPrinter(QPrinter::NativeFormat, widget.printers->currentText()); + + propertiesDialog = new QPrintPropertiesDialog(q->printer(), outputFormat, printerName, q); + propertiesDialog->setResult(QDialog::Rejected); + propertiesDialogShown = false; } void QUnixPrintWidgetPrivate::_q_btnPropertiesClicked() -- 2.15.1