summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlbert Astals Cid <albert.astals.cid@kdab.com>2017-12-04 12:49:12 +0100
committerShawn Rutledge <shawn.rutledge@qt.io>2017-12-06 07:27:48 +0000
commitfb1836898f5f8f88accea92a5ad7adb625694700 (patch)
treedd843ea6f9f95187babf926b46fa2d86ec72b479
parent2ecfdf87b8362309f555e441f16e6c5b56f17e63 (diff)
Remove QUnixPrintWidgetPrivate::applyPrinterProperties
And move it's code to the only place it is called, the QUnixPrintWidget constructor, that means we can remove the if that checks if propertiesDialog is not null since at that stage we know it is null Change-Id: I81cdaa0505fa6fe64a45c7d1f5c3e277400cbbf7 Reviewed-by: Andy Shaw <andy.shaw@qt.io>
-rw-r--r--src/printsupport/dialogs/qprintdialog_unix.cpp80
1 files changed, 35 insertions, 45 deletions
diff --git a/src/printsupport/dialogs/qprintdialog_unix.cpp b/src/printsupport/dialogs/qprintdialog_unix.cpp
index 37a562125e..66d37dbec3 100644
--- a/src/printsupport/dialogs/qprintdialog_unix.cpp
+++ b/src/printsupport/dialogs/qprintdialog_unix.cpp
@@ -168,8 +168,6 @@ public:
QUnixPrintWidgetPrivate(QUnixPrintWidget *q, QPrinter *prn);
~QUnixPrintWidgetPrivate();
- /// copy printer properties to the widget
- void applyPrinterProperties();
bool checkFields();
void setupPrinter();
void setOptionsPane(QPrintDialogPrivate *pane);
@@ -790,48 +788,6 @@ void QUnixPrintWidgetPrivate::_q_btnBrowseClicked()
}
}
-void QUnixPrintWidgetPrivate::applyPrinterProperties()
-{
- if (printer == nullptr)
- return;
- if (printer->outputFileName().isEmpty()) {
- QString home = QDir::homePath();
- QString cur = QDir::currentPath();
- if (home.at(home.length()-1) != QLatin1Char('/'))
- home += QLatin1Char('/');
- if (!cur.isEmpty() && cur.at(cur.length()-1) != QLatin1Char('/'))
- cur += QLatin1Char('/');
- if (!cur.startsWith(home))
- cur = home;
- if (QGuiApplication::platformName() == QLatin1String("xcb")) {
- if (printer->docName().isEmpty()) {
- cur += QLatin1String("print.pdf");
- } else {
- QRegExp re(QString::fromLatin1("(.*)\\.\\S+"));
- if (re.exactMatch(printer->docName()))
- cur += re.cap(1);
- else
- cur += printer->docName();
- cur += QLatin1String(".pdf");
- }
- } // xcb
-
- widget.filename->setText(cur);
- }
- else
- widget.filename->setText( printer->outputFileName() );
- QString printerName = printer->printerName();
- if (!printerName.isEmpty()) {
- const int i = widget.printers->findText(printerName);
- if (i >= 0)
- widget.printers->setCurrentIndex(i);
- }
- // PDF printer not added to the dialog yet, we'll handle those cases in QUnixPrintWidgetPrivate::updateWidget
-
- if (propertiesDialog)
- propertiesDialog->applyPrinterProperties(printer);
-}
-
#if QT_CONFIG(messagebox)
bool QUnixPrintWidgetPrivate::checkFields()
{
@@ -951,7 +907,41 @@ void QUnixPrintWidgetPrivate::setupPrinter()
QUnixPrintWidget::QUnixPrintWidget(QPrinter *printer, QWidget *parent)
: QWidget(parent), d(new QUnixPrintWidgetPrivate(this, printer))
{
- d->applyPrinterProperties();
+ if (printer == nullptr)
+ return;
+ if (printer->outputFileName().isEmpty()) {
+ QString home = QDir::homePath();
+ QString cur = QDir::currentPath();
+ if (!home.endsWith(QLatin1Char('/')))
+ home += QLatin1Char('/');
+ if (!cur.startsWith(home))
+ cur = home;
+ else if (!cur.endsWith(QLatin1Char('/')))
+ cur += QLatin1Char('/');
+ if (QGuiApplication::platformName() == QStringLiteral("xcb")) {
+ if (printer->docName().isEmpty()) {
+ cur += QStringLiteral("print.pdf");
+ } else {
+ const QRegExp re(QStringLiteral("(.*)\\.\\S+"));
+ if (re.exactMatch(printer->docName()))
+ cur += re.cap(1);
+ else
+ cur += printer->docName();
+ cur += QStringLiteral(".pdf");
+ }
+ } // xcb
+
+ d->widget.filename->setText(cur);
+ }
+ else
+ d->widget.filename->setText(printer->outputFileName());
+ const QString printerName = printer->printerName();
+ if (!printerName.isEmpty()) {
+ const int i = d->widget.printers->findText(printerName);
+ if (i >= 0)
+ d->widget.printers->setCurrentIndex(i);
+ }
+ // PDF printer not added to the dialog yet, we'll handle those cases in QUnixPrintWidgetPrivate::updateWidget
}
/*! \internal