summaryrefslogtreecommitdiffstats
path: root/src/printsupport/dialogs
diff options
context:
space:
mode:
Diffstat (limited to 'src/printsupport/dialogs')
-rw-r--r--src/printsupport/dialogs/dialogs.pri46
-rw-r--r--src/printsupport/dialogs/images/printer-24.png (renamed from src/printsupport/dialogs/images/print-24.png)bin914 -> 914 bytes
-rw-r--r--src/printsupport/dialogs/images/printer-32.png (renamed from src/printsupport/dialogs/images/print-32.png)bin1202 -> 1202 bytes
-rw-r--r--src/printsupport/dialogs/images/view-pages-facing-24.png (renamed from src/printsupport/dialogs/images/view-page-sided-24.png)bin700 -> 700 bytes
-rw-r--r--src/printsupport/dialogs/images/view-pages-facing-32.png (renamed from src/printsupport/dialogs/images/view-page-sided-32.png)bin908 -> 908 bytes
-rw-r--r--src/printsupport/dialogs/images/view-pages-overview-24.png (renamed from src/printsupport/dialogs/images/view-page-multi-24.png)bin390 -> 390 bytes
-rw-r--r--src/printsupport/dialogs/images/view-pages-overview-32.png (renamed from src/printsupport/dialogs/images/view-page-multi-32.png)bin556 -> 556 bytes
-rw-r--r--src/printsupport/dialogs/images/view-pages-single-24.png (renamed from src/printsupport/dialogs/images/view-page-one-24.png)bin662 -> 662 bytes
-rw-r--r--src/printsupport/dialogs/images/view-pages-single-32.png (renamed from src/printsupport/dialogs/images/view-page-one-32.png)bin810 -> 810 bytes
-rw-r--r--src/printsupport/dialogs/images/zoom-fit-page-24.png (renamed from src/printsupport/dialogs/images/fit-page-24.png)bin985 -> 985 bytes
-rw-r--r--src/printsupport/dialogs/images/zoom-fit-page-32.png (renamed from src/printsupport/dialogs/images/fit-page-32.png)bin1330 -> 1330 bytes
-rw-r--r--src/printsupport/dialogs/images/zoom-fit-width-24.png (renamed from src/printsupport/dialogs/images/fit-width-24.png)bin706 -> 706 bytes
-rw-r--r--src/printsupport/dialogs/images/zoom-fit-width-32.png (renamed from src/printsupport/dialogs/images/fit-width-32.png)bin1004 -> 1004 bytes
-rw-r--r--src/printsupport/dialogs/qabstractprintdialog.cpp111
-rw-r--r--src/printsupport/dialogs/qabstractprintdialog.h51
-rw-r--r--src/printsupport/dialogs/qabstractprintdialog_p.h42
-rw-r--r--src/printsupport/dialogs/qpagesetupdialog.cpp44
-rw-r--r--src/printsupport/dialogs/qpagesetupdialog.h42
-rw-r--r--src/printsupport/dialogs/qpagesetupdialog_mac.mm54
-rw-r--r--src/printsupport/dialogs/qpagesetupdialog_p.h40
-rw-r--r--src/printsupport/dialogs/qpagesetupdialog_unix.cpp122
-rw-r--r--src/printsupport/dialogs/qpagesetupdialog_unix_p.h40
-rw-r--r--src/printsupport/dialogs/qpagesetupdialog_win.cpp87
-rw-r--r--src/printsupport/dialogs/qprintdialog.h44
-rw-r--r--src/printsupport/dialogs/qprintdialog.qdoc28
-rw-r--r--src/printsupport/dialogs/qprintdialog.qrc38
-rw-r--r--src/printsupport/dialogs/qprintdialog_mac.mm125
-rw-r--r--src/printsupport/dialogs/qprintdialog_unix.cpp296
-rw-r--r--src/printsupport/dialogs/qprintdialog_win.cpp110
-rw-r--r--src/printsupport/dialogs/qprintpreviewdialog.cpp148
-rw-r--r--src/printsupport/dialogs/qprintpreviewdialog.h40
-rw-r--r--src/printsupport/dialogs/qprintsettingsoutput.ui8
32 files changed, 388 insertions, 1128 deletions
diff --git a/src/printsupport/dialogs/dialogs.pri b/src/printsupport/dialogs/dialogs.pri
deleted file mode 100644
index 0a7b947c79..0000000000
--- a/src/printsupport/dialogs/dialogs.pri
+++ /dev/null
@@ -1,46 +0,0 @@
-# Qt dialogs module
-
-INCLUDEPATH += $$PWD
-
-qtConfig(printdialog) {
- HEADERS += \
- dialogs/qabstractprintdialog.h \
- dialogs/qabstractprintdialog_p.h \
- dialogs/qpagesetupdialog_p.h \
- dialogs/qpagesetupdialog.h \
- dialogs/qprintdialog.h
-
- macos {
- OBJECTIVE_SOURCES += dialogs/qpagesetupdialog_mac.mm \
- dialogs/qprintdialog_mac.mm
- LIBS_PRIVATE += -framework AppKit
- }
-
- win32 {
- SOURCES += dialogs/qpagesetupdialog_win.cpp \
- dialogs/qprintdialog_win.cpp
- }
-
- unix:!darwin {
- INCLUDEPATH += $$QT_SOURCE_TREE/src/plugins/printsupport/cups
- HEADERS += dialogs/qpagesetupdialog_unix_p.h
- SOURCES += dialogs/qprintdialog_unix.cpp \
- dialogs/qpagesetupdialog_unix.cpp
- FORMS += dialogs/qprintsettingsoutput.ui \
- dialogs/qprintwidget.ui \
- dialogs/qprintpropertieswidget.ui
- }
-
- SOURCES += \
- dialogs/qabstractprintdialog.cpp \
- dialogs/qpagesetupdialog.cpp
-
- FORMS += dialogs/qpagesetupwidget.ui
- RESOURCES += dialogs/qprintdialog.qrc
-}
-
-qtConfig(printpreviewdialog) {
- HEADERS += dialogs/qprintpreviewdialog.h
- SOURCES += dialogs/qprintpreviewdialog.cpp
-}
-
diff --git a/src/printsupport/dialogs/images/print-24.png b/src/printsupport/dialogs/images/printer-24.png
index c6bf3e8672..c6bf3e8672 100644
--- a/src/printsupport/dialogs/images/print-24.png
+++ b/src/printsupport/dialogs/images/printer-24.png
Binary files differ
diff --git a/src/printsupport/dialogs/images/print-32.png b/src/printsupport/dialogs/images/printer-32.png
index 5830888653..5830888653 100644
--- a/src/printsupport/dialogs/images/print-32.png
+++ b/src/printsupport/dialogs/images/printer-32.png
Binary files differ
diff --git a/src/printsupport/dialogs/images/view-page-sided-24.png b/src/printsupport/dialogs/images/view-pages-facing-24.png
index 2131305c41..2131305c41 100644
--- a/src/printsupport/dialogs/images/view-page-sided-24.png
+++ b/src/printsupport/dialogs/images/view-pages-facing-24.png
Binary files differ
diff --git a/src/printsupport/dialogs/images/view-page-sided-32.png b/src/printsupport/dialogs/images/view-pages-facing-32.png
index e4d63f9992..e4d63f9992 100644
--- a/src/printsupport/dialogs/images/view-page-sided-32.png
+++ b/src/printsupport/dialogs/images/view-pages-facing-32.png
Binary files differ
diff --git a/src/printsupport/dialogs/images/view-page-multi-24.png b/src/printsupport/dialogs/images/view-pages-overview-24.png
index 87241472ae..87241472ae 100644
--- a/src/printsupport/dialogs/images/view-page-multi-24.png
+++ b/src/printsupport/dialogs/images/view-pages-overview-24.png
Binary files differ
diff --git a/src/printsupport/dialogs/images/view-page-multi-32.png b/src/printsupport/dialogs/images/view-pages-overview-32.png
index 130885a041..130885a041 100644
--- a/src/printsupport/dialogs/images/view-page-multi-32.png
+++ b/src/printsupport/dialogs/images/view-pages-overview-32.png
Binary files differ
diff --git a/src/printsupport/dialogs/images/view-page-one-24.png b/src/printsupport/dialogs/images/view-pages-single-24.png
index 4c6457b892..4c6457b892 100644
--- a/src/printsupport/dialogs/images/view-page-one-24.png
+++ b/src/printsupport/dialogs/images/view-pages-single-24.png
Binary files differ
diff --git a/src/printsupport/dialogs/images/view-page-one-32.png b/src/printsupport/dialogs/images/view-pages-single-32.png
index 537193984e..537193984e 100644
--- a/src/printsupport/dialogs/images/view-page-one-32.png
+++ b/src/printsupport/dialogs/images/view-pages-single-32.png
Binary files differ
diff --git a/src/printsupport/dialogs/images/fit-page-24.png b/src/printsupport/dialogs/images/zoom-fit-page-24.png
index c7b39d8853..c7b39d8853 100644
--- a/src/printsupport/dialogs/images/fit-page-24.png
+++ b/src/printsupport/dialogs/images/zoom-fit-page-24.png
Binary files differ
diff --git a/src/printsupport/dialogs/images/fit-page-32.png b/src/printsupport/dialogs/images/zoom-fit-page-32.png
index 98bc12d3ed..98bc12d3ed 100644
--- a/src/printsupport/dialogs/images/fit-page-32.png
+++ b/src/printsupport/dialogs/images/zoom-fit-page-32.png
Binary files differ
diff --git a/src/printsupport/dialogs/images/fit-width-24.png b/src/printsupport/dialogs/images/zoom-fit-width-24.png
index a729ffda54..a729ffda54 100644
--- a/src/printsupport/dialogs/images/fit-width-24.png
+++ b/src/printsupport/dialogs/images/zoom-fit-width-24.png
Binary files differ
diff --git a/src/printsupport/dialogs/images/fit-width-32.png b/src/printsupport/dialogs/images/zoom-fit-width-32.png
index 470a8b45d0..470a8b45d0 100644
--- a/src/printsupport/dialogs/images/fit-width-32.png
+++ b/src/printsupport/dialogs/images/zoom-fit-width-32.png
Binary files differ
diff --git a/src/printsupport/dialogs/qabstractprintdialog.cpp b/src/printsupport/dialogs/qabstractprintdialog.cpp
index 1a2aa7afac..30276a6121 100644
--- a/src/printsupport/dialogs/qabstractprintdialog.cpp
+++ b/src/printsupport/dialogs/qabstractprintdialog.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qabstractprintdialog_p.h"
#include "qcoreapplication.h"
@@ -78,20 +42,12 @@ QT_BEGIN_NAMESPACE
Used to specify which parts of the print dialog should be visible.
- \value None None of the options are enabled.
\value PrintToFile The print to file option is enabled.
\value PrintSelection The print selection option is enabled.
\value PrintPageRange The page range selection option is enabled.
\value PrintShowPageSize Show the page size + margins page only if this is enabled.
\value PrintCollateCopies The collate copies option is enabled
\value PrintCurrentPage The print current page option is enabled
-
- This value is obsolete and does nothing since Qt 4.5:
-
- \value DontUseSheet In previous versions of Qt, exec() the print dialog
- would create a sheet by default the dialog was given a parent.
- This is no longer supported in Qt 4.5. If you want to use sheets, use
- QPrintDialog::open() instead.
*/
/*!
@@ -188,50 +144,6 @@ QPrintDialog::PrintDialogOptions QPrintDialog::options() const
}
/*!
- \obsolete
-
- Use QPrintDialog::setOptions() instead.
-*/
-void QAbstractPrintDialog::setEnabledOptions(PrintDialogOptions options)
-{
- Q_D(QAbstractPrintDialog);
- d->options = options;
-}
-
-/*!
- \obsolete
-
- Use QPrintDialog::setOption(\a option, true) instead.
-*/
-void QAbstractPrintDialog::addEnabledOption(PrintDialogOption option)
-{
- Q_D(QAbstractPrintDialog);
- d->options |= option;
-}
-
-/*!
- \obsolete
-
- Use QPrintDialog::options() instead.
-*/
-QAbstractPrintDialog::PrintDialogOptions QAbstractPrintDialog::enabledOptions() const
-{
- Q_D(const QAbstractPrintDialog);
- return d->options;
-}
-
-/*!
- \obsolete
-
- Use QPrintDialog::testOption(\a option) instead.
-*/
-bool QAbstractPrintDialog::isOptionEnabled(PrintDialogOption option) const
-{
- Q_D(const QAbstractPrintDialog);
- return d->options & option;
-}
-
-/*!
Sets the print range option in to be \a range.
*/
void QAbstractPrintDialog::setPrintRange(PrintRange range)
@@ -344,13 +256,6 @@ void QAbstractPrintDialogPrivate::setPrinter(QPrinter *newPrinter)
}
/*!
- \fn int QAbstractPrintDialog::exec()
-
- This virtual function is called to pop up the dialog. It must be
- reimplemented in subclasses.
-*/
-
-/*!
\class QPrintDialog
\brief The QPrintDialog class provides a dialog for specifying
@@ -460,9 +365,15 @@ void QAbstractPrintDialog::setOptionTabs(const QList<QWidget*> &tabs)
void QPrintDialog::done(int result)
{
auto *d = static_cast<QAbstractPrintDialogPrivate *>(d_ptr.data());
+ if (result == Accepted) {
+ // Emit accepted(QPrinter*) at the same time as the dialog
+ // is accepted. Doing it here is too late, as done() will
+ // also emit finished().
+ QObject::connect(this, &QDialog::accepted, this, [this]{
+ emit accepted(printer());
+ }, Qt::SingleShotConnection);
+ }
QDialog::done(result);
- if (result == Accepted)
- emit accepted(printer());
if (d->receiverToDisconnectOnClose) {
disconnect(this, SIGNAL(accepted(QPrinter*)),
d->receiverToDisconnectOnClose, d->memberToDisconnectOnClose);
@@ -490,3 +401,5 @@ void QPrintDialog::open(QObject *receiver, const char *member)
}
QT_END_NAMESPACE
+
+#include "moc_qabstractprintdialog.cpp"
diff --git a/src/printsupport/dialogs/qabstractprintdialog.h b/src/printsupport/dialogs/qabstractprintdialog.h
index 3cc89890fc..7f3f929d8a 100644
--- a/src/printsupport/dialogs/qabstractprintdialog.h
+++ b/src/printsupport/dialogs/qabstractprintdialog.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QABSTRACTPRINTDIALOG_H
#define QABSTRACTPRINTDIALOG_H
@@ -51,7 +15,6 @@ QT_BEGIN_NAMESPACE
class QAbstractPrintDialogPrivate;
class QPrinter;
-// ### QtPrintNG: merge this class with QPrintDialog
class Q_PRINTSUPPORT_EXPORT QAbstractPrintDialog : public QDialog
{
Q_DECLARE_PRIVATE(QAbstractPrintDialog)
@@ -67,13 +30,11 @@ public:
};
enum PrintDialogOption {
- None = 0x0000, // obsolete
PrintToFile = 0x0001,
PrintSelection = 0x0002,
PrintPageRange = 0x0004,
PrintShowPageSize = 0x0008,
PrintCollateCopies = 0x0010,
- DontUseSheet = 0x0020,
PrintCurrentPage = 0x0040
};
Q_ENUM(PrintDialogOption)
@@ -84,14 +45,6 @@ public:
explicit QAbstractPrintDialog(QPrinter *printer, QWidget *parent = nullptr);
~QAbstractPrintDialog();
- int exec() override = 0;
-
- // obsolete
- void addEnabledOption(PrintDialogOption option);
- void setEnabledOptions(PrintDialogOptions options);
- PrintDialogOptions enabledOptions() const;
- bool isOptionEnabled(PrintDialogOption option) const;
-
void setOptionTabs(const QList<QWidget*> &tabs);
void setPrintRange(PrintRange range);
diff --git a/src/printsupport/dialogs/qabstractprintdialog_p.h b/src/printsupport/dialogs/qabstractprintdialog_p.h
index b646b74f34..40f25d454a 100644
--- a/src/printsupport/dialogs/qabstractprintdialog_p.h
+++ b/src/printsupport/dialogs/qabstractprintdialog_p.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QABSTRACTPRINTDIALOG_P_H
#define QABSTRACTPRINTDIALOG_P_H
@@ -56,6 +20,8 @@
#include "private/qdialog_p.h"
#include "QtPrintSupport/qabstractprintdialog.h"
+#include <QtCore/qpointer.h>
+
QT_REQUIRE_CONFIG(printdialog);
QT_BEGIN_NAMESPACE
diff --git a/src/printsupport/dialogs/qpagesetupdialog.cpp b/src/printsupport/dialogs/qpagesetupdialog.cpp
index dc0457d20d..40893cddab 100644
--- a/src/printsupport/dialogs/qpagesetupdialog.cpp
+++ b/src/printsupport/dialogs/qpagesetupdialog.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qpagesetupdialog.h"
#include <private/qpagesetupdialog_p.h>
@@ -114,10 +78,8 @@ void QPageSetupDialogPrivate::setPrinter(QPrinter *newPrinter)
printer = new QPrinter;
ownsPrinter = true;
}
-#if 1 // Used to be excluded in Qt4 for Q_WS_X11
if (printer->outputFormat() != QPrinter::NativeFormat)
qWarning("QPageSetupDialog: Cannot be used on non-native printers");
-#endif
}
/*!
@@ -138,7 +100,7 @@ void QPageSetupDialog::open(QObject *receiver, const char *member)
QDialog::open();
}
-#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
+#if defined(Q_OS_MACOS) || defined(Q_OS_WIN)
/*! \fn void QPageSetupDialog::setVisible(bool visible)
\reimp
*/
diff --git a/src/printsupport/dialogs/qpagesetupdialog.h b/src/printsupport/dialogs/qpagesetupdialog.h
index a7aaa03134..89056c70dd 100644
--- a/src/printsupport/dialogs/qpagesetupdialog.h
+++ b/src/printsupport/dialogs/qpagesetupdialog.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QPAGESETUPDIALOG_H
#define QPAGESETUPDIALOG_H
@@ -61,7 +25,7 @@ public:
explicit QPageSetupDialog(QWidget *parent = nullptr);
~QPageSetupDialog();
-#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
+#if defined(Q_OS_MACOS) || defined(Q_OS_WIN) || defined(Q_QDOC)
void setVisible(bool visible) override;
#endif
int exec() override;
diff --git a/src/printsupport/dialogs/qpagesetupdialog_mac.mm b/src/printsupport/dialogs/qpagesetupdialog_mac.mm
index a3511fe7b6..046a1021af 100644
--- a/src/printsupport/dialogs/qpagesetupdialog_mac.mm
+++ b/src/printsupport/dialogs/qpagesetupdialog_mac.mm
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include <AppKit/AppKit.h>
@@ -47,6 +11,10 @@
#include <qpa/qplatformnativeinterface.h>
#include <QtPrintSupport/qprintengine.h>
+#include <QtPrintSupport/private/qprintengine_mac_p.h>
+
+#include <QtCore/private/qcore_mac_p.h>
+
QT_USE_NAMESPACE
@class QT_MANGLE_NAMESPACE(QCocoaPageLayoutDelegate);
@@ -82,7 +50,7 @@ QT_USE_NAMESPACE
PMGetOrientation(format, &orientation);
QSizeF paperSize = QSizeF(paperRect.right - paperRect.left, paperRect.bottom - paperRect.top);
printer->printEngine()->setProperty(QPrintEngine::PPK_CustomPaperSize, paperSize);
- printer->printEngine()->setProperty(QPrintEngine::PPK_Orientation, orientation == kPMLandscape ? QPrinter::Landscape : QPrinter::Portrait);
+ printer->printEngine()->setProperty(QPrintEngine::PPK_Orientation, orientation == kPMLandscape ? QPageLayout::Landscape : QPageLayout::Portrait);
}
dialog->done((returnCode == NSModalResponseOK) ? QDialog::Accepted : QDialog::Rejected);
@@ -114,13 +82,7 @@ void QMacPageSetupDialogPrivate::openCocoaPageLayout(Qt::WindowModality modality
{
Q_Q(QPageSetupDialog);
- // get the NSPrintInfo from the print engine in the platform plugin
- void *voidp = 0;
- (void) QMetaObject::invokeMethod(qApp->platformNativeInterface(),
- "NSPrintInfoForPrintEngine",
- Q_RETURN_ARG(void *, voidp),
- Q_ARG(QPrintEngine *, printer->printEngine()));
- printInfo = static_cast<NSPrintInfo *>(voidp);
+ printInfo = static_cast<QMacPrintEngine *>(printer->printEngine())->printInfo();
[printInfo retain];
pageLayout = [NSPageLayout pageLayout];
diff --git a/src/printsupport/dialogs/qpagesetupdialog_p.h b/src/printsupport/dialogs/qpagesetupdialog_p.h
index a2b3f8363c..1b02f1e62d 100644
--- a/src/printsupport/dialogs/qpagesetupdialog_p.h
+++ b/src/printsupport/dialogs/qpagesetupdialog_p.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QPAGESETUPDIALOG_P_H
#define QPAGESETUPDIALOG_P_H
diff --git a/src/printsupport/dialogs/qpagesetupdialog_unix.cpp b/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
index d9b4a84aa9..6c65eafc21 100644
--- a/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
+++ b/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qpagesetupdialog.h"
@@ -49,7 +13,7 @@
#include "qpainter.h"
#include "qprintdialog.h"
-#include "qtextcodec.h"
+#include "qstringconverter.h"
#include "qdialogbuttonbox.h"
#include <ui_qpagesetupwidget.h>
@@ -60,6 +24,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
extern QMarginsF qt_convertMargins(const QMarginsF &margins, QPageLayout::Unit fromUnits, QPageLayout::Unit toUnits);
// Disabled until we have support for papersources on unix
@@ -157,7 +123,7 @@ protected:
font.setPointSizeF(font.pointSizeF()*0.25);
p.setFont(font);
p.setPen(palette().color(QPalette::Dark));
- QString text(QLatin1String("Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi."));
+ QString text("Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi."_L1);
for (int i=0; i<3; ++i)
text += text;
@@ -249,9 +215,6 @@ QPageSetupWidget::QPageSetupWidget(QWidget *parent)
{
m_ui.setupUi(this);
- if (!QMetaType::hasRegisteredComparators<QPageSize>())
- QMetaType::registerEqualsComparator<QPageSize>();
-
QVBoxLayout *lay = new QVBoxLayout(m_ui.preview);
m_pagePreview = new QPagePreview(m_ui.preview);
m_pagePreview->setPagePreviewLayout(1, 1);
@@ -274,21 +237,21 @@ QPageSetupWidget::QPageSetupWidget(QWidget *parent)
initUnits();
initPagesPerSheet();
- connect(m_ui.unitCombo, QOverload<int>::of(&QComboBox::activated), this, &QPageSetupWidget::unitChanged);
+ connect(m_ui.unitCombo, &QComboBox::activated, this, &QPageSetupWidget::unitChanged);
- connect(m_ui.pageSizeCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &QPageSetupWidget::pageSizeChanged);
- connect(m_ui.pageWidth, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &QPageSetupWidget::pageSizeChanged);
- connect(m_ui.pageHeight, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &QPageSetupWidget::pageSizeChanged);
+ connect(m_ui.pageSizeCombo, &QComboBox::currentIndexChanged, this, &QPageSetupWidget::pageSizeChanged);
+ connect(m_ui.pageWidth, &QDoubleSpinBox::valueChanged, this, &QPageSetupWidget::pageSizeChanged);
+ connect(m_ui.pageHeight, &QDoubleSpinBox::valueChanged, this, &QPageSetupWidget::pageSizeChanged);
- connect(m_ui.leftMargin, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &QPageSetupWidget::leftMarginChanged);
- connect(m_ui.topMargin, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &QPageSetupWidget::topMarginChanged);
- connect(m_ui.rightMargin, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &QPageSetupWidget::rightMarginChanged);
- connect(m_ui.bottomMargin, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &QPageSetupWidget::bottomMarginChanged);
+ connect(m_ui.leftMargin, &QDoubleSpinBox::valueChanged, this, &QPageSetupWidget::leftMarginChanged);
+ connect(m_ui.topMargin, &QDoubleSpinBox::valueChanged, this, &QPageSetupWidget::topMarginChanged);
+ connect(m_ui.rightMargin, &QDoubleSpinBox::valueChanged, this, &QPageSetupWidget::rightMarginChanged);
+ connect(m_ui.bottomMargin, &QDoubleSpinBox::valueChanged, this, &QPageSetupWidget::bottomMarginChanged);
connect(m_ui.portrait, &QRadioButton::clicked, this, &QPageSetupWidget::pageOrientationChanged);
connect(m_ui.landscape, &QRadioButton::clicked, this, &QPageSetupWidget::pageOrientationChanged);
- connect(m_ui.pagesPerSheetCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &QPageSetupWidget::pagesPerSheetChanged);
+ connect(m_ui.pagesPerSheetCombo, &QComboBox::currentIndexChanged, this, &QPageSetupWidget::pagesPerSheetChanged);
}
// Init the Units combo box
@@ -301,7 +264,7 @@ void QPageSetupWidget::initUnits()
m_ui.unitCombo->addItem(tr("Didot (DD)"), QVariant::fromValue(QPageLayout::Didot));
m_ui.unitCombo->addItem(tr("Cicero (CC)"), QVariant::fromValue(QPageLayout::Cicero));
- // Initailly default to locale measurement system, mm if metric, in otherwise
+ // Initially default to locale measurement system, mm if metric, in otherwise
m_ui.unitCombo->setCurrentIndex(QLocale().measurementSystem() != QLocale::MetricSystem);
}
@@ -361,13 +324,21 @@ void QPageSetupWidget::initPageSizes()
QPlatformPrinterSupport *ps = QPlatformPrinterSupportPlugin::get();
if (ps) {
QPrintDevice printDevice = ps->createPrintDevice(m_printerName);
+ const QPageSize defaultSize = printDevice.defaultPageSize();
const auto pageSizes = printDevice.supportedPageSizes();
for (const QPageSize &pageSize : pageSizes)
m_ui.pageSizeCombo->addItem(pageSize.name(), QVariant::fromValue(pageSize));
- if (m_ui.pageSizeCombo->count() > 0 && printDevice.supportsCustomPageSizes()) {
- m_ui.pageSizeCombo->addItem(tr("Custom"));
- m_realCustomPageSizeIndex = m_ui.pageSizeCombo->count() - 1;
+ if (m_ui.pageSizeCombo->count() > 0) {
+ if (printDevice.supportsCustomPageSizes()) {
+ m_ui.pageSizeCombo->addItem(tr("Custom"));
+ m_realCustomPageSizeIndex = m_ui.pageSizeCombo->count() - 1;
+ }
m_blockSignals = false;
+
+ // If the defaultSize is index 0, setCurrentIndex won't emit the currentIndexChanged
+ // signal; workaround the issue by initially setting the currentIndex to -1
+ m_ui.pageSizeCombo->setCurrentIndex(-1);
+ m_ui.pageSizeCombo->setCurrentIndex(m_ui.pageSizeCombo->findData(QVariant::fromValue(defaultSize)));
return;
}
}
@@ -403,12 +374,6 @@ void QPageSetupWidget::setPrinter(QPrinter *printer, QPrintDevice *printDevice,
// Initialize the layout to the current QPrinter layout
m_pageLayout = m_printer->pageLayout();
- 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) {
if (QLocale().measurementSystem() == QLocale::MetricSystem)
@@ -530,11 +495,12 @@ void QPageSetupWidget::updateWidget()
void QPageSetupWidget::setupPrinter() const
{
m_printer->setPageLayout(m_pageLayout);
+ m_printer->setPageOrientation(m_pageLayout.orientation());
#if QT_CONFIG(cups)
- QCUPSSupport::PagesPerSheet pagesPerSheet = m_ui.pagesPerSheetCombo->currentData()
- .value<QCUPSSupport::PagesPerSheet>();
- QCUPSSupport::PagesPerSheetLayout pagesPerSheetLayout = m_ui.pagesPerSheetLayoutCombo->currentData()
- .value<QCUPSSupport::PagesPerSheetLayout>();
+ QCUPSSupport::PagesPerSheet pagesPerSheet = qvariant_cast<QCUPSSupport::PagesPerSheet>(m_ui.pagesPerSheetCombo->currentData()
+);
+ QCUPSSupport::PagesPerSheetLayout pagesPerSheetLayout = qvariant_cast<QCUPSSupport::PagesPerSheetLayout>(m_ui.pagesPerSheetLayoutCombo->currentData()
+);
QCUPSSupport::setPagesPerSheetLayout(m_printer, pagesPerSheet, pagesPerSheetLayout);
#endif
#ifdef PSD_ENABLE_PAPERSOURCE
@@ -585,15 +551,19 @@ void QPageSetupWidget::pageSizeChanged()
{
QPageSize pageSize;
if (m_ui.pageSizeCombo->currentIndex() != m_realCustomPageSizeIndex) {
- pageSize = m_ui.pageSizeCombo->currentData().value<QPageSize>();
+ pageSize = qvariant_cast<QPageSize>(m_ui.pageSizeCombo->currentData());
#if QT_CONFIG(cups)
if (m_pageSizePpdOption) {
- ppd_file_t *ppd = m_printDevice->property(PDPK_PpdFile).value<ppd_file_t*>();
- QTextCodec *cupsCodec = QTextCodec::codecForName(ppd->lang_encoding);
+ ppd_file_t *ppd = qvariant_cast<ppd_file_t*>(m_printDevice->property(PDPK_PpdFile));
+ QStringDecoder toUtf16(ppd->lang_encoding, QStringDecoder::Flag::Stateless);
+ if (!toUtf16.isValid()) {
+ qWarning() << "QPrinSupport: Cups uses unsupported encoding" << ppd->lang_encoding;
+ toUtf16 = QStringDecoder(QStringDecoder::Utf8);
+ }
for (int i = 0; i < m_pageSizePpdOption->num_choices; ++i) {
const ppd_choice_t *choice = &m_pageSizePpdOption->choices[i];
- if (cupsCodec->toUnicode(choice->text) == m_ui.pageSizeCombo->currentText()) {
+ if (toUtf16(choice->text) == m_ui.pageSizeCombo->currentText()) {
const auto values = QStringList{} << QString::fromLatin1(m_pageSizePpdOption->keyword)
<< QString::fromLatin1(choice->choice);
m_printDevice->setProperty(PDPK_PpdOption, values);
@@ -674,7 +644,7 @@ void QPageSetupWidget::unitChanged()
{
if (m_blockSignals)
return;
- m_units = m_ui.unitCombo->currentData().value<QPageLayout::Unit>();
+ m_units = qvariant_cast<QPageLayout::Unit>(m_ui.unitCombo->currentData());
m_pageLayout.setUnits(m_units);
updateWidget();
}
@@ -723,7 +693,7 @@ QPageSetupDialog::QPageSetupDialog(QPrinter *printer, QWidget *parent)
}
QPageSetupDialog::QPageSetupDialog(QWidget *parent)
- : QDialog(*(new QUnixPageSetupDialogPrivate(0)), parent)
+ : QDialog(*(new QUnixPageSetupDialogPrivate(nullptr)), parent)
{
Q_D(QPageSetupDialog);
setWindowTitle(QCoreApplication::translate("QPrintPreviewDialog", "Page Setup"));
@@ -735,11 +705,17 @@ int QPageSetupDialog::exec()
Q_D(QPageSetupDialog);
int ret = QDialog::exec();
- if (ret == Accepted)
+ if (ret == Accepted) {
static_cast <QUnixPageSetupDialogPrivate*>(d)->widget->setupPrinter();
+ static_cast <QUnixPageSetupDialogPrivate*>(d)->widget->updateSavedValues();
+ } else {
+ static_cast <QUnixPageSetupDialogPrivate*>(d)->widget->revertToSavedValues();
+ }
return ret;
}
QT_END_NAMESPACE
+#include "moc_qpagesetupdialog_unix_p.cpp"
+
#include "moc_qpagesetupdialog.cpp"
diff --git a/src/printsupport/dialogs/qpagesetupdialog_unix_p.h b/src/printsupport/dialogs/qpagesetupdialog_unix_p.h
index 7bfdaed740..0fe3a2e559 100644
--- a/src/printsupport/dialogs/qpagesetupdialog_unix_p.h
+++ b/src/printsupport/dialogs/qpagesetupdialog_unix_p.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QPAGESETUPDIALOG_UNIX_P_H
#define QPAGESETUPDIALOG_UNIX_P_H
diff --git a/src/printsupport/dialogs/qpagesetupdialog_win.cpp b/src/printsupport/dialogs/qpagesetupdialog_win.cpp
index 464381bbe4..1d2fdc98b7 100644
--- a/src/printsupport/dialogs/qpagesetupdialog_win.cpp
+++ b/src/printsupport/dialogs/qpagesetupdialog_win.cpp
@@ -1,47 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qpagesetupdialog.h"
#include <qapplication.h>
-#include "../kernel/qprintengine_win_p.h"
+#include <private/qprintengine_win_p.h>
#include "qpagesetupdialog_p.h"
#include "qprinter.h"
#include <qpa/qplatformnativeinterface.h>
@@ -56,7 +20,7 @@ QPageSetupDialog::QPageSetupDialog(QPrinter *printer, QWidget *parent)
}
QPageSetupDialog::QPageSetupDialog(QWidget *parent)
- : QDialog(*(new QPageSetupDialogPrivate(0)), parent)
+ : QDialog(*(new QPageSetupDialogPrivate(nullptr)), parent)
{
setWindowTitle(QCoreApplication::translate("QPrintPreviewDialog", "Page Setup"));
setAttribute(Qt::WA_DontShowOnScreen);
@@ -77,7 +41,7 @@ int QPageSetupDialog::exec()
psd.lStructSize = sizeof(PAGESETUPDLG);
// we need a temp DEVMODE struct if we don't have a global DEVMODE
- HGLOBAL hDevMode = 0;
+ HGLOBAL hDevMode = nullptr;
int devModeSize = 0;
if (!engine->globalDevMode()) {
devModeSize = sizeof(DEVMODE) + ep->devMode->dmDriverExtra;
@@ -99,9 +63,10 @@ int QPageSetupDialog::exec()
parent = parent ? parent->window() : QApplication::activeWindow();
Q_ASSERT(!parent ||parent->testAttribute(Qt::WA_WState_Created));
- QWindow *parentWindow = parent ? parent->windowHandle() : 0;
- psd.hwndOwner = parentWindow ? (HWND)QGuiApplication::platformNativeInterface()->nativeResourceForWindow("handle", parentWindow) : 0;
-
+ QWindow *parentWindow = parent ? parent->windowHandle() : nullptr;
+ psd.hwndOwner = parentWindow
+ ? HWND(QGuiApplication::platformNativeInterface()->nativeResourceForWindow("handle", parentWindow))
+ : nullptr;
psd.Flags = PSD_MARGINS;
QPageLayout layout = d->printer->pageLayout();
switch (layout.units()) {
@@ -134,17 +99,43 @@ int QPageSetupDialog::exec()
QDialog::setVisible(false);
if (result) {
engine->setGlobalDevMode(psd.hDevNames, psd.hDevMode);
- d->printer->setPageSize(QPageSize(QSizeF(psd.ptPaperSize.x / multiplier, psd.ptPaperSize.y / multiplier),
- layout.units() == QPageLayout::Inch ? QPageSize::Inch : QPageSize::Millimeter));
+ QPageSize pageSize;
+ // try to read orientation and paper size ID from the dialog's devmode struct
+ if (psd.hDevMode) {
+ DEVMODE *rDevmode = reinterpret_cast<DEVMODE*>(GlobalLock(psd.hDevMode));
+ if (rDevmode->dmFields & DM_ORIENTATION) {
+ layout.setOrientation(rDevmode->dmOrientation == DMORIENT_PORTRAIT
+ ? QPageLayout::Portrait : QPageLayout::Landscape);
+ }
+ if (rDevmode->dmFields & DM_PAPERSIZE)
+ pageSize = QPageSize::id(rDevmode->dmPaperSize);
+ GlobalUnlock(rDevmode);
+ }
+ // fall back to use our own matching, and assume that paper that's wider than long means landscape
+ if (!pageSize.isValid() || pageSize.id() == QPageSize::Custom) {
+ QSizeF unitSize(psd.ptPaperSize.x / multiplier, psd.ptPaperSize.y / multiplier);
+ if (unitSize.width() > unitSize.height()) {
+ layout.setOrientation(QPageLayout::Landscape);
+ unitSize.transpose();
+ } else {
+ layout.setOrientation(QPageLayout::Portrait);
+ }
+ pageSize = QPageSize(unitSize, layout.units() == QPageLayout::Inch
+ ? QPageSize::Inch : QPageSize::Millimeter);
+ }
+ layout.setPageSize(pageSize, layout.minimumMargins());
+
const QMarginsF margins(psd.rtMargin.left, psd.rtMargin.top, psd.rtMargin.right, psd.rtMargin.bottom);
- d->printer->setPageMargins(margins / multiplier, layout.units());
+ layout.setMargins(margins / multiplier, QPageLayout::OutOfBoundsPolicy::Clamp);
+ d->printer->setPageLayout(layout);
// copy from our temp DEVMODE struct
if (!engine->globalDevMode() && hDevMode) {
// Make sure memory is allocated
if (ep->ownsDevMode && ep->devMode)
free(ep->devMode);
- ep->devMode = (DEVMODE *) malloc(devModeSize);
+ ep->devMode = reinterpret_cast<DEVMODE *>(malloc(devModeSize));
+ QWin32PrintEnginePrivate::initializeDevMode(ep->devMode);
ep->ownsDevMode = true;
// Copy
diff --git a/src/printsupport/dialogs/qprintdialog.h b/src/printsupport/dialogs/qprintdialog.h
index bbb12202f0..4ba6ddfd48 100644
--- a/src/printsupport/dialogs/qprintdialog.h
+++ b/src/printsupport/dialogs/qprintdialog.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QPRINTDIALOG_H
#define QPRINTDIALOG_H
@@ -64,7 +28,7 @@ public:
~QPrintDialog();
int exec() override;
-#if defined (Q_OS_UNIX) && !defined(Q_OS_MAC)
+#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
virtual void accept() override;
#endif
void done(int result) override;
@@ -91,7 +55,7 @@ Q_SIGNALS:
void accepted(QPrinter *printer);
private:
-#if defined (Q_OS_UNIX) && !defined(Q_OS_MAC)
+#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
Q_PRIVATE_SLOT(d_func(), void _q_togglePageSetCombo(bool))
Q_PRIVATE_SLOT(d_func(), void _q_collapseOrExpandDialog())
#if QT_CONFIG(messagebox)
diff --git a/src/printsupport/dialogs/qprintdialog.qdoc b/src/printsupport/dialogs/qprintdialog.qdoc
index 90195db138..5fa4a021ae 100644
--- a/src/printsupport/dialogs/qprintdialog.qdoc
+++ b/src/printsupport/dialogs/qprintdialog.qdoc
@@ -1,27 +1,3 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
diff --git a/src/printsupport/dialogs/qprintdialog.qrc b/src/printsupport/dialogs/qprintdialog.qrc
deleted file mode 100644
index 5a579baa55..0000000000
--- a/src/printsupport/dialogs/qprintdialog.qrc
+++ /dev/null
@@ -1,38 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource prefix="/qt-project.org/dialogs/qprintpreviewdialog">
-<file>images/fit-page-24.png</file>
-<file>images/fit-page-32.png</file>
-<file>images/fit-width-24.png</file>
-<file>images/fit-width-32.png</file>
-<file>images/go-first-24.png</file>
-<file>images/go-first-32.png</file>
-<file>images/go-last-24.png</file>
-<file>images/go-last-32.png</file>
-<file>images/go-next-24.png</file>
-<file>images/go-next-32.png</file>
-<file>images/go-previous-24.png</file>
-<file>images/go-previous-32.png</file>
-<file>images/layout-landscape-24.png</file>
-<file>images/layout-landscape-32.png</file>
-<file>images/layout-portrait-24.png</file>
-<file>images/layout-portrait-32.png</file>
-<file>images/page-setup-24.png</file>
-<file>images/page-setup-32.png</file>
-<file>images/print-24.png</file>
-<file>images/print-32.png</file>
-<file>images/view-page-multi-24.png</file>
-<file>images/view-page-multi-32.png</file>
-<file>images/view-page-one-24.png</file>
-<file>images/view-page-one-32.png</file>
-<file>images/view-page-sided-24.png</file>
-<file>images/view-page-sided-32.png</file>
-<file>images/zoom-in-24.png</file>
-<file>images/zoom-in-32.png</file>
-<file>images/zoom-out-24.png</file>
-<file>images/zoom-out-32.png</file>
-</qresource>
-<qresource prefix="/qt-project.org/dialogs/qprintdialog">
-<file>images/status-color.png</file>
-<file>images/status-gray-scale.png</file>
-</qresource>
-</RCC>
diff --git a/src/printsupport/dialogs/qprintdialog_mac.mm b/src/printsupport/dialogs/qprintdialog_mac.mm
index ed2d0908c4..fa4fac1884 100644
--- a/src/printsupport/dialogs/qprintdialog_mac.mm
+++ b/src/printsupport/dialogs/qprintdialog_mac.mm
@@ -1,55 +1,24 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include <AppKit/AppKit.h>
#include "qprintdialog.h"
#include "qabstractprintdialog_p.h"
+#include <QtCore/qtemporarydir.h>
#include <QtCore/private/qcore_mac_p.h>
#include <QtWidgets/private/qapplication_p.h>
#include <QtPrintSupport/qprinter.h>
#include <QtPrintSupport/qprintengine.h>
#include <qpa/qplatformprintdevice.h>
+#include <QtPrintSupport/private/qprintengine_mac_p.h>
+
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
extern qreal qt_pointMultiplier(QPageLayout::Unit unit);
class QPrintDialogPrivate : public QAbstractPrintDialogPrivate
@@ -114,7 +83,7 @@ QT_USE_NAMESPACE
// (Apologies to the folks with more than INT_MAX pages)
if (dialog->fromPage() == 1 && dialog->toPage() == INT_MAX) {
dialog->setPrintRange(QPrintDialog::AllPages);
- dialog->setFromTo(0, 0);
+ printer->setPageRanges(QPageRanges());
} else {
dialog->setPrintRange(QPrintDialog::PageRange); // In a way a lie, but it shouldn't hurt.
// Carbon hands us back a very large number here even for ALL, set it to max
@@ -127,21 +96,36 @@ QT_USE_NAMESPACE
PMDestinationType dest;
PMSessionGetDestinationType(session, settings, &dest);
if (dest == kPMDestinationFile) {
- // QTBUG-38820
- // If user selected Print to File, leave OSX to generate the PDF,
- // otherwise setting PdfFormat would prevent us showing dialog again.
- // TODO Restore this when QTBUG-36112 is fixed.
- /*
QCFType<CFURLRef> file;
PMSessionCopyDestinationLocation(session, settings, &file);
UInt8 localFile[2048]; // Assuming there's a POSIX file system here.
CFURLGetFileSystemRepresentation(file, true, localFile, sizeof(localFile));
- printer->setOutputFileName(QString::fromUtf8(reinterpret_cast<const char *>(localFile)));
- */
- } else {
+ auto outputFile = QFileInfo(QString::fromUtf8(reinterpret_cast<const char *>(localFile)));
+ if (outputFile.suffix() == "pdf"_L1)
+ printer->setOutputFileName(outputFile.absoluteFilePath());
+ else
+ qWarning() << "Can not print to file type" << outputFile.suffix();
+ } else if (dest == kPMDestinationPreview) {
+ static QTemporaryDir printPreviews;
+ auto documentName = printer->docName();
+ if (documentName.isEmpty())
+ documentName = QGuiApplication::applicationDisplayName();
+ auto fileName = printPreviews.filePath(QString("%1.pdf"_L1).arg(documentName));
+ printer->setOutputFileName(fileName);
+ // Ideally we would have a callback when the PDF engine is done writing
+ // to the file, and open Preview in response to that. Lacking that, we
+ // use the quick and dirty assumption that the the print operation will
+ // happen synchronously after the dialog is accepted, so we can defer
+ // the opening of the file to the next runloop pass.
+ dispatch_async(dispatch_get_main_queue(), ^{
+ [NSWorkspace.sharedWorkspace openURL:[NSURL fileURLWithPath:fileName.toNSString()]];
+ });
+ } else if (dest == kPMDestinationProcessPDF) {
+ qWarning("Printing workflows are not supported");
+ } else if (dest == kPMDestinationPrinter) {
PMPrinter macPrinter;
PMSessionGetCurrentPrinter(session, &macPrinter);
- QString printerId = QString::fromCFString(PMPrinterGetID(macPrinter));
+ QString printerId = QString::fromCFString(PMPrinterGetID(macPrinter)).trimmed();
if (printer->printerName() != printerId)
printer->setPrinterName(printerId);
}
@@ -186,7 +170,7 @@ QT_USE_NAMESPACE
}
if (pageSize.isValid() && !pageSize.isEquivalentTo(printer->pageLayout().pageSize()))
printer->setPageSize(pageSize);
- printer->setOrientation(orientation == kPMLandscape ? QPrinter::Landscape : QPrinter::Portrait);
+ printer->setPageOrientation(orientation == kPMLandscape ? QPageLayout::Landscape : QPageLayout::Portrait);
dialog->done((returnCode == NSModalResponseOK) ? QDialog::Accepted : QDialog::Rejected);
}
@@ -199,14 +183,18 @@ void QPrintDialogPrivate::openCocoaPrintPanel(Qt::WindowModality modality)
{
Q_Q(QPrintDialog);
- // get the NSPrintInfo from the print engine in the platform plugin
- void *voidp = 0;
- (void) QMetaObject::invokeMethod(qApp->platformNativeInterface(),
- "NSPrintInfoForPrintEngine",
- Q_RETURN_ARG(void *, voidp),
- Q_ARG(QPrintEngine *, printer->printEngine()));
- printInfo = static_cast<NSPrintInfo *>(voidp);
- [printInfo retain];
+ if (printer->outputFormat() == QPrinter::NativeFormat) {
+ printInfo = static_cast<QMacPrintEngine *>(printer->printEngine())->printInfo();
+ [printInfo retain];
+ } else {
+ const QPageLayout pageLayout = printer->pageLayout();
+ // initialize the printInfo using the dictionary from the application-wide print info
+ const auto dictionary = [NSPrintInfo.sharedPrintInfo dictionary];
+ printInfo = [[NSPrintInfo alloc] initWithDictionary:dictionary];
+ printInfo.orientation = pageLayout.orientation() == QPageLayout::Landscape
+ ? NSPaperOrientationLandscape : NSPaperOrientationPortrait;
+ printInfo.paperSize = pageLayout.pageSize().size(QPageSize::Point).toCGSize();
+ }
// It seems the only way that PM lets you use all is if the minimum
// for the page range is 1. This _kind of_ makes sense if you think about
@@ -250,8 +238,8 @@ void QPrintDialogPrivate::openCocoaPrintPanel(Qt::WindowModality modality)
int rval = [printPanel runModalWithPrintInfo:printInfo];
[delegate printPanelDidEnd:printPanel returnCode:rval contextInfo:q];
} else {
- Q_ASSERT(q->parentWidget());
- QWindow *parentWindow = q->parentWidget()->windowHandle();
+ Q_ASSERT(q->window());
+ QWindow *parentWindow = q->window()->windowHandle();
NSWindow *window = static_cast<NSWindow *>(qApp->platformNativeInterface()->nativeResourceForWindow("nswindow", parentWindow));
[printPanel beginSheetWithPrintInfo:printInfo
modalForWindow:window
@@ -269,43 +257,26 @@ void QPrintDialogPrivate::closeCocoaPrintPanel()
printPanel = 0;
}
-static bool warnIfNotNative(QPrinter *printer)
-{
- if (printer->outputFormat() != QPrinter::NativeFormat) {
- qWarning("QPrintDialog: Cannot be used on non-native printers");
- return false;
- }
- return true;
-}
-
-
QPrintDialog::QPrintDialog(QPrinter *printer, QWidget *parent)
: QAbstractPrintDialog(*(new QPrintDialogPrivate), printer, parent)
{
- Q_D(QPrintDialog);
- if (!warnIfNotNative(d->printer))
- return;
setAttribute(Qt::WA_DontShowOnScreen);
}
QPrintDialog::QPrintDialog(QWidget *parent)
: QAbstractPrintDialog(*(new QPrintDialogPrivate), 0, parent)
{
- Q_D(QPrintDialog);
- if (!warnIfNotNative(d->printer))
- return;
setAttribute(Qt::WA_DontShowOnScreen);
}
QPrintDialog::~QPrintDialog()
{
+ hide();
}
int QPrintDialog::exec()
{
Q_D(QPrintDialog);
- if (!warnIfNotNative(d->printer))
- return QDialog::Rejected;
QDialog::setVisible(true);
diff --git a/src/printsupport/dialogs/qprintdialog_unix.cpp b/src/printsupport/dialogs/qprintdialog_unix.cpp
index 5390a8b2f2..aab5e2c7f0 100644
--- a/src/printsupport/dialogs/qprintdialog_unix.cpp
+++ b/src/printsupport/dialogs/qprintdialog_unix.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qplatformdefs.h"
#include <QtPrintSupport/private/qtprintsupportglobal_p.h>
@@ -51,10 +15,10 @@
#include <QtCore/qdebug.h>
#include <QtCore/qdir.h>
#include <QtCore/qglobal.h>
-#include <QtCore/qtextcodec.h>
+#include <QtCore/qstringconverter.h>
#include <QtGui/qevent.h>
#if QT_CONFIG(filesystemmodel)
-#include <QtWidgets/qfilesystemmodel.h>
+#include <QtGui/qfilesystemmodel.h>
#endif
#include <QtWidgets/qstyleditemdelegate.h>
#include <QtWidgets/qformlayout.h>
@@ -67,6 +31,10 @@
#include <QtWidgets/qdialogbuttonbox.h>
+#if QT_CONFIG(regularexpression)
+#include <qregularexpression.h>
+#endif
+
#if QT_CONFIG(completer)
#include <private/qcompleter_p.h>
#endif
@@ -115,13 +83,15 @@ Print dialog class declarations
Layout in qprintpropertieswidget.ui
*/
-static void initResources()
+static void _q_pdu_initResources()
{
Q_INIT_RESOURCE(qprintdialog);
}
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
class QPrintPropertiesDialog : public QDialog
{
Q_OBJECT
@@ -159,8 +129,9 @@ private:
bool anyAdvancedOptionConflict() const;
QPrintDevice *m_currentPrintDevice;
- QTextCodec *m_cupsCodec = nullptr;
- QVector<QComboBox*> m_advancedOptionsCombos;
+
+ QStringDecoder toUnicode;
+ QList<QComboBox*> m_advancedOptionsCombos;
#endif
};
@@ -203,7 +174,7 @@ public:
QUnixPrintWidget * const parent;
QPrintPropertiesDialog *propertiesDialog;
Ui::QPrintWidget widget;
- QAbstractPrintDialog * q;
+ QPrintDialog * q;
QPrinter *printer;
QPrintDevice m_currentPrintDevice;
@@ -307,7 +278,7 @@ QPrintPropertiesDialog::QPrintPropertiesDialog(QPrinter *printer, QPrintDevice *
});
#else
- Q_UNUSED(currentPrintDevice)
+ Q_UNUSED(currentPrintDevice);
widget.tabs->setTabEnabled(advancedTabIndex, false);
#endif
}
@@ -351,7 +322,7 @@ void QPrintPropertiesDialog::reject()
void QPrintPropertiesDialog::accept()
{
-#if QT_CONFIG(cups)
+#if QT_CONFIG(cups) && QT_CONFIG(messagebox)
if (widget.pageSetup->hasPpdConflict()) {
widget.tabs->setCurrentWidget(widget.tabPage);
const QMessageBox::StandardButton answer = QMessageBox::warning(this, tr("Page Setup Conflicts"),
@@ -398,12 +369,12 @@ static const char *ppdOriginallySelectedChoiceProperty = "_q_ppd_originally_sele
// Used to store the warning label pointer for each QComboBox that represents an advanced option
static const char *warningLabelProperty = "_q_warning_label";
-static bool isBlacklistedGroup(const ppd_group_t *group) Q_DECL_NOTHROW
+static bool isBlacklistedGroup(const ppd_group_t *group) noexcept
{
return qstrcmp(group->name, "InstallableOptions") == 0;
};
-static bool isBlacklistedOption(const char *keyword) Q_DECL_NOTHROW
+static bool isBlacklistedOption(const char *keyword) noexcept
{
// We already let the user set these options elsewhere
const char *cupsOptionBlacklist[] = {
@@ -426,10 +397,14 @@ bool QPrintPropertiesDialog::createAdvancedOptionsWidget()
{
bool anyWidgetCreated = false;
- ppd_file_t *ppd = m_currentPrintDevice->property(PDPK_PpdFile).value<ppd_file_t*>();
+ ppd_file_t *ppd = qvariant_cast<ppd_file_t*>(m_currentPrintDevice->property(PDPK_PpdFile));
if (ppd) {
- m_cupsCodec = QTextCodec::codecForName(ppd->lang_encoding);
+ toUnicode = QStringDecoder(ppd->lang_encoding, QStringDecoder::Flag::Stateless);
+ if (!toUnicode.isValid()) {
+ qWarning() << "QPrinSupport: Cups uses unsupported encoding" << ppd->lang_encoding;
+ toUnicode = QStringDecoder(QStringDecoder::Utf8, QStringDecoder::Flag::Stateless);
+ }
QWidget *holdingWidget = new QWidget();
QVBoxLayout *layout = new QVBoxLayout(holdingWidget);
@@ -466,7 +441,7 @@ bool QPrintPropertiesDialog::createAdvancedOptionsWidget()
if (choiceIsInstallableConflict && static_cast<int>(choice->marked) == 1) {
markedChoiceNotAvailable = true;
} else if (!choiceIsInstallableConflict) {
- choicesCb->addItem(m_cupsCodec->toUnicode(choice->text), i);
+ choicesCb->addItem(toUnicode(choice->text), i);
if (static_cast<int>(choice->marked) == 1) {
choicesCb->setCurrentIndex(choicesCb->count() - 1);
choicesCb->setProperty(ppdOriginallySelectedChoiceProperty, QVariant(i));
@@ -487,7 +462,7 @@ bool QPrintPropertiesDialog::createAdvancedOptionsWidget()
if (choicesCb->count() > 1) {
- connect(choicesCb, QOverload<int>::of(&QComboBox::currentIndexChanged), this, setPpdOptionFromCombo);
+ connect(choicesCb, &QComboBox::currentIndexChanged, this, setPpdOptionFromCombo);
// We need an extra label at the end to show the conflict warning
QWidget *choicesCbWithLabel = new QWidget();
@@ -497,7 +472,7 @@ bool QPrintPropertiesDialog::createAdvancedOptionsWidget()
choicesCbWithLabelLayout->addWidget(choicesCb);
choicesCbWithLabelLayout->addWidget(warningLabel);
- QLabel *optionLabel = new QLabel(m_cupsCodec->toUnicode(option->text));
+ QLabel *optionLabel = new QLabel(toUnicode(option->text));
groupLayout->addRow(optionLabel, choicesCbWithLabel);
anyWidgetCreated = true;
choicesCb->setProperty(ppdOptionProperty, QVariant::fromValue(option));
@@ -510,7 +485,7 @@ bool QPrintPropertiesDialog::createAdvancedOptionsWidget()
}
if (groupLayout->rowCount() > 0) {
- QGroupBox *groupBox = new QGroupBox(m_cupsCodec->toUnicode(group->text));
+ QGroupBox *groupBox = new QGroupBox(toUnicode(group->text));
groupBox->setLayout(groupLayout);
layout->addWidget(groupBox);
} else {
@@ -523,16 +498,13 @@ bool QPrintPropertiesDialog::createAdvancedOptionsWidget()
widget.scrollArea->setWidget(holdingWidget);
}
- if (!m_cupsCodec)
- m_cupsCodec = QTextCodec::codecForLocale();
-
return anyWidgetCreated;
}
void QPrintPropertiesDialog::setPrinterAdvancedCupsOptions() const
{
for (const QComboBox *choicesCb : m_advancedOptionsCombos) {
- const ppd_option_t *option = choicesCb->property(ppdOptionProperty).value<const ppd_option_t *>();
+ const ppd_option_t *option = qvariant_cast<const ppd_option_t *>(choicesCb->property(ppdOptionProperty));
// We can't use choicesCb->currentIndex() to know the index of the option in the choices[] array
// because some of them may not be present in the list because they conflict with the
@@ -551,7 +523,7 @@ void QPrintPropertiesDialog::setPrinterAdvancedCupsOptions() const
void QPrintPropertiesDialog::revertAdvancedOptionsToSavedValues() const
{
for (QComboBox *choicesCb : m_advancedOptionsCombos) {
- const int originallySelectedChoice = choicesCb->property(ppdOriginallySelectedChoiceProperty).value<int>();
+ const int originallySelectedChoice = qvariant_cast<int>(choicesCb->property(ppdOriginallySelectedChoiceProperty));
const int newComboIndexToSelect = choicesCb->findData(originallySelectedChoice);
choicesCb->setCurrentIndex(newComboIndexToSelect);
// The currentIndexChanged lambda takes care of resetting the ppd option
@@ -580,8 +552,8 @@ bool QPrintPropertiesDialog::anyAdvancedOptionConflict() const
bool anyConflicted = false;
for (const QComboBox *choicesCb : m_advancedOptionsCombos) {
- const ppd_option_t *option = choicesCb->property(ppdOptionProperty).value<const ppd_option_t *>();
- QLabel *warningLabel = choicesCb->property(warningLabelProperty).value<QLabel *>();
+ const ppd_option_t *option = qvariant_cast<const ppd_option_t *>(choicesCb->property(ppdOptionProperty));
+ QLabel *warningLabel = qvariant_cast<QLabel *>(choicesCb->property(warningLabelProperty));
if (option->conflicted) {
anyConflicted = true;
const int pixmap_size = choicesCb->sizeHint().height() * .75;
@@ -612,7 +584,7 @@ QPrintDialogPrivate::QPrintDialogPrivate()
: top(nullptr), bottom(nullptr), buttons(nullptr), collapseButton(nullptr),
explicitDuplexMode(QPrint::DuplexAuto)
{
- initResources();
+ _q_pdu_initResources();
}
QPrintDialogPrivate::~QPrintDialogPrivate()
@@ -627,9 +599,9 @@ void QPrintDialogPrivate::init()
bottom = new QWidget(q);
options.setupUi(bottom);
options.color->setIconSize(QSize(32, 32));
- options.color->setIcon(QIcon(QLatin1String(":/qt-project.org/dialogs/qprintdialog/images/status-color.png")));
+ options.color->setIcon(QIcon(":/qt-project.org/dialogs/qprintdialog/images/status-color.png"_L1));
options.grayscale->setIconSize(QSize(32, 32));
- options.grayscale->setIcon(QIcon(QLatin1String(":/qt-project.org/dialogs/qprintdialog/images/status-gray-scale.png")));
+ options.grayscale->setIcon(QIcon(":/qt-project.org/dialogs/qprintdialog/images/status-gray-scale.png"_L1));
#if QT_CONFIG(cups)
// Add Page Set widget if CUPS is available
@@ -637,8 +609,10 @@ void QPrintDialogPrivate::init()
options.pageSetCombo->addItem(tr("Odd Pages"), QVariant::fromValue(QCUPSSupport::OddPages));
options.pageSetCombo->addItem(tr("Even Pages"), QVariant::fromValue(QCUPSSupport::EvenPages));
#else
- for (int i = options.pagesLayout->count() - 1; i >= 0; --i)
- delete options.pagesLayout->itemAt(i)->widget();
+ delete options.pagesRadioButton;
+ delete options.pagesLineEdit;
+ options.pagesRadioButton = nullptr;
+ options.pagesLineEdit = nullptr;
#endif
top->d->setOptionsPane(this);
@@ -700,13 +674,14 @@ void QPrintDialogPrivate::selectPrinter(const QPrinter::OutputFormat outputForma
else
options.grayscale->setChecked(true);
- // keep duplex value explicitly set by user, if any, and selected printer supports it;
- // use device default otherwise
+ // duplex priorities to be as follows:
+ // 1) a user-selected duplex value in the dialog has highest priority
+ // 2) duplex value set in the QPrinter
QPrint::DuplexMode duplex;
if (explicitDuplexMode != QPrint::DuplexAuto && supportedDuplexMode.contains(explicitDuplexMode))
duplex = explicitDuplexMode;
else
- duplex = top->d->m_currentPrintDevice.defaultDuplexMode();
+ duplex = static_cast<QPrint::DuplexMode>(p->duplex());
switch (duplex) {
case QPrint::DuplexNone:
options.noDuplex->setChecked(true); break;
@@ -728,91 +703,17 @@ void QPrintDialogPrivate::selectPrinter(const QPrinter::OutputFormat outputForma
options.pageSetCombo->setEnabled(true);
#if QT_CONFIG(cups)
+ // Disable complex page ranges widget when printing to pdf
+ // It doesn't work since it relies on cups to do the heavy lifting and cups
+ // is not used when printing to PDF
+ options.pagesRadioButton->setEnabled(outputFormat != QPrinter::PdfFormat);
+
// Disable color options on main dialog if not printing to file, it will be handled by CUPS advanced dialog
options.colorMode->setVisible(outputFormat == QPrinter::PdfFormat);
#endif
}
#if QT_CONFIG(cups)
-static std::vector<std::pair<int, int>> pageRangesFromString(const QString &pagesString) Q_DECL_NOTHROW
-{
- std::vector<std::pair<int, int>> result;
- const QStringList items = pagesString.split(',');
- for (const QString item : items) {
- if (item.isEmpty())
- return {};
-
- if (item.contains(QLatin1Char('-'))) {
- const QStringList rangeItems = item.split('-');
- if (rangeItems.count() != 2)
- return {};
-
- bool ok;
- const int number1 = rangeItems[0].toInt(&ok);
- if (!ok)
- return {};
-
- const int number2 = rangeItems[1].toInt(&ok);
- if (!ok)
- return {};
-
- if (number1 < 1 || number2 < 1 || number2 < number1)
- return {};
-
- result.push_back(std::make_pair(number1, number2));
-
- } else {
- bool ok;
- const int number = item.toInt(&ok);
- if (!ok)
- return {};
-
- if (number < 1)
- return {};
-
- result.push_back(std::make_pair(number, number));
- }
- }
-
- // check no range intersects with the next
- std::sort(result.begin(), result.end(),
- [](const std::pair<int, int> &it1, const std::pair<int, int> &it2) { return it1.first < it2.first; });
- int previousSecond = -1;
- for (auto pair : result) {
- if (pair.first <= previousSecond)
- return {};
-
- previousSecond = pair.second;
- }
-
- return result;
-}
-
-static QString stringFromPageRanges(const std::vector<std::pair<int, int>> &pageRanges) Q_DECL_NOTHROW
-{
- QString result;
-
- for (auto pair : pageRanges) {
- if (!result.isEmpty())
- result += QLatin1Char(',');
-
- if (pair.first == pair.second)
- result += QString::number(pair.first);
- else
- result += QStringLiteral("%1-%2").arg(pair.first).arg(pair.second);
- }
-
- return result;
-}
-
-static bool isValidPagesString(const QString &pagesString) Q_DECL_NOTHROW
-{
- if (pagesString.isEmpty())
- return false;
-
- auto pagesRanges = pageRangesFromString(pagesString);
- return !pagesRanges.empty();
-}
void QPrintDialogPrivate::updatePpdDuplexOption(QRadioButton *radio)
{
@@ -862,41 +763,42 @@ void QPrintDialogPrivate::setupPrinter()
// print range
if (options.printAll->isChecked()) {
p->setPrintRange(QPrinter::AllPages);
- p->setFromTo(0,0);
+ p->setPageRanges(QPageRanges());
} else if (options.printSelection->isChecked()) {
p->setPrintRange(QPrinter::Selection);
- p->setFromTo(0,0);
+ p->setPageRanges(QPageRanges());
} else if (options.printCurrentPage->isChecked()) {
p->setPrintRange(QPrinter::CurrentPage);
- p->setFromTo(0,0);
+ p->setPageRanges(QPageRanges());
} else if (options.printRange->isChecked()) {
- if (q->isOptionEnabled(QPrintDialog::PrintPageRange)) {
+ if (q->testOption(QPrintDialog::PrintPageRange)) {
p->setPrintRange(QPrinter::PageRange);
p->setFromTo(options.from->value(), qMax(options.from->value(), options.to->value()));
} else {
// This case happens when CUPS server-side page range is enabled
// Setting the range to the printer occurs below
p->setPrintRange(QPrinter::AllPages);
- p->setFromTo(0,0);
+ p->setPageRanges(QPageRanges());
}
}
#if QT_CONFIG(cups)
if (options.pagesRadioButton->isChecked()) {
- auto pageRanges = pageRangesFromString(options.pagesLineEdit->text());
-
- p->setPrintRange(QPrinter::AllPages);
- p->setFromTo(0, 0);
+ const QPageRanges ranges = QPageRanges::fromString(options.pagesLineEdit->text());
+ if (!ranges.isEmpty()) {
+ p->setPrintRange(QPrinter::PageRange);
+ p->setPageRanges(ranges);
+ }
// server-side page filtering
- QCUPSSupport::setPageRange(p, stringFromPageRanges(pageRanges));
+ QCUPSSupport::setPageRange(p, ranges.toString());
}
// page set
if (p->printRange() == QPrinter::AllPages || p->printRange() == QPrinter::PageRange) {
//If the application is selecting pages and the first page number is even then need to adjust the odd-even accordingly
- QCUPSSupport::PageSet pageSet = options.pageSetCombo->itemData(options.pageSetCombo->currentIndex()).value<QCUPSSupport::PageSet>();
- if (q->isOptionEnabled(QPrintDialog::PrintPageRange)
+ QCUPSSupport::PageSet pageSet = qvariant_cast<QCUPSSupport::PageSet>(options.pageSetCombo->itemData(options.pageSetCombo->currentIndex()));
+ if (q->testOption(QPrintDialog::PrintPageRange)
&& p->printRange() == QPrinter::PageRange
&& (q->fromPage() % 2 == 0)) {
@@ -916,7 +818,7 @@ void QPrintDialogPrivate::setupPrinter()
// server-side page range, since we set the page range on the printer to 0-0/AllPages above,
// we need to take the values directly from the widget as q->fromPage() will return 0
- if (!q->isOptionEnabled(QPrintDialog::PrintPageRange) && options.printRange->isChecked())
+ if (!q->testOption(QPrintDialog::PrintPageRange) && options.printRange->isChecked())
QCUPSSupport::setPageRange(p, options.from->value(), qMax(options.from->value(), options.to->value()));
}
#endif
@@ -965,19 +867,19 @@ void QPrintDialogPrivate::_q_checkFields()
void QPrintDialogPrivate::updateWidgets()
{
Q_Q(QPrintDialog);
- options.gbPrintRange->setVisible(q->isOptionEnabled(QPrintDialog::PrintPageRange) ||
- q->isOptionEnabled(QPrintDialog::PrintSelection) ||
- q->isOptionEnabled(QPrintDialog::PrintCurrentPage));
+ options.gbPrintRange->setVisible(q->testOption(QPrintDialog::PrintPageRange) ||
+ q->testOption(QPrintDialog::PrintSelection) ||
+ q->testOption(QPrintDialog::PrintCurrentPage));
- options.printRange->setEnabled(q->isOptionEnabled(QPrintDialog::PrintPageRange));
- options.printSelection->setVisible(q->isOptionEnabled(QPrintDialog::PrintSelection));
- options.printCurrentPage->setVisible(q->isOptionEnabled(QPrintDialog::PrintCurrentPage));
- options.collate->setVisible(q->isOptionEnabled(QPrintDialog::PrintCollateCopies));
+ options.printRange->setEnabled(q->testOption(QPrintDialog::PrintPageRange));
+ options.printSelection->setVisible(q->testOption(QPrintDialog::PrintSelection));
+ options.printCurrentPage->setVisible(q->testOption(QPrintDialog::PrintCurrentPage));
+ options.collate->setVisible(q->testOption(QPrintDialog::PrintCollateCopies));
#if QT_CONFIG(cups)
// Don't display Page Set if only Selection or Current Page are enabled
- if (!q->isOptionEnabled(QPrintDialog::PrintPageRange)
- && (q->isOptionEnabled(QPrintDialog::PrintSelection) || q->isOptionEnabled(QPrintDialog::PrintCurrentPage))) {
+ if (!q->testOption(QPrintDialog::PrintPageRange)
+ && (q->testOption(QPrintDialog::PrintSelection) || q->testOption(QPrintDialog::PrintCurrentPage))) {
options.pageSetCombo->setVisible(false);
options.pageSetLabel->setVisible(false);
} else {
@@ -985,7 +887,7 @@ void QPrintDialogPrivate::updateWidgets()
options.pageSetLabel->setVisible(true);
}
- if (!q->isOptionEnabled(QPrintDialog::PrintPageRange)) {
+ if (!q->testOption(QPrintDialog::PrintPageRange)) {
// If we can do CUPS server side pages selection,
// display the page range widgets
options.gbPrintRange->setVisible(true);
@@ -1007,7 +909,7 @@ void QPrintDialogPrivate::updateWidgets()
options.pageSetCombo->setEnabled(true);
break;
case QPrintDialog::CurrentPage:
- if (q->isOptionEnabled(QPrintDialog::PrintCurrentPage)) {
+ if (q->testOption(QPrintDialog::PrintCurrentPage)) {
options.printCurrentPage->setChecked(true);
options.pageSetCombo->setEnabled(false);
}
@@ -1082,14 +984,14 @@ void QPrintDialog::setVisible(bool visible)
int QPrintDialog::exec()
{
- return QDialog::exec();
+ return QAbstractPrintDialog::exec();
}
void QPrintDialog::accept()
{
Q_D(QPrintDialog);
-#if QT_CONFIG(cups)
- if (d->options.pagesRadioButton->isChecked() && !isValidPagesString(d->options.pagesLineEdit->text())) {
+#if QT_CONFIG(cups) && QT_CONFIG(messagebox)
+ if (d->options.pagesRadioButton->isChecked() && printer()->pageRanges().isEmpty()) {
QMessageBox::critical(this, tr("Invalid Pages Definition"),
tr("%1 does not follow the correct syntax. Please use ',' to separate "
"ranges and pages, '-' to define ranges and make sure ranges do "
@@ -1133,7 +1035,7 @@ QUnixPrintWidgetPrivate::QUnixPrintWidgetPrivate(QUnixPrintWidget *p, QPrinter *
{
q = nullptr;
if (parent)
- q = qobject_cast<QAbstractPrintDialog*> (parent->parent());
+ q = qobject_cast<QPrintDialog*> (parent->parent());
widget.setupUi(parent);
@@ -1171,12 +1073,14 @@ QUnixPrintWidgetPrivate::QUnixPrintWidgetPrivate(QUnixPrintWidget *p, QPrinter *
void QUnixPrintWidgetPrivate::updateWidget()
{
- const bool printToFile = q == 0 || q->isOptionEnabled(QPrintDialog::PrintToFile);
+ const bool printToFile = q == nullptr || q->testOption(QPrintDialog::PrintToFile);
if (printToFile && !filePrintersAdded) {
if (widget.printers->count())
widget.printers->insertSeparator(widget.printers->count());
widget.printers->addItem(QPrintDialog::tr("Print to File (PDF)"));
filePrintersAdded = true;
+ if (widget.printers->count() == 1)
+ _q_printerChanged(0);
}
if (!printToFile && filePrintersAdded) {
widget.printers->removeItem(widget.printers->count()-1);
@@ -1198,7 +1102,8 @@ void QUnixPrintWidgetPrivate::updateWidget()
widget.lOutput->setVisible(printToFile);
widget.fileBrowser->setVisible(printToFile);
- widget.properties->setVisible(q->isOptionEnabled(QAbstractPrintDialog::PrintShowPageSize));
+ if (q)
+ widget.properties->setVisible(q->testOption(QAbstractPrintDialog::PrintShowPageSize));
}
QUnixPrintWidgetPrivate::~QUnixPrintWidgetPrivate()
@@ -1233,10 +1138,10 @@ void QUnixPrintWidgetPrivate::_q_printerChanged(int index)
QString filename = widget.filename->text();
widget.filename->setText(filename);
widget.lOutput->setEnabled(true);
- if (optionsPane)
- optionsPane->selectPrinter(QPrinter::PdfFormat);
printer->setOutputFormat(QPrinter::PdfFormat);
m_currentPrintDevice = QPrintDevice();
+ if (optionsPane)
+ optionsPane->selectPrinter(QPrinter::PdfFormat);
return;
}
}
@@ -1318,10 +1223,10 @@ bool QUnixPrintWidgetPrivate::checkFields()
#if QT_CONFIG(cups)
if (propertiesDialog) {
- QCUPSSupport::PagesPerSheet pagesPerSheet = propertiesDialog->widget.pageSetup->m_ui.pagesPerSheetCombo
- ->currentData().value<QCUPSSupport::PagesPerSheet>();
+ QCUPSSupport::PagesPerSheet pagesPerSheet = qvariant_cast<QCUPSSupport::PagesPerSheet>(propertiesDialog->widget.pageSetup->m_ui.pagesPerSheetCombo
+ ->currentData());
- QCUPSSupport::PageSet pageSet = optionsPane->options.pageSetCombo->currentData().value<QCUPSSupport::PageSet>();
+ QCUPSSupport::PageSet pageSet = qvariant_cast<QCUPSSupport::PageSet>(optionsPane->options.pageSetCombo->currentData());
if (pagesPerSheet != QCUPSSupport::OnePagePerSheet
@@ -1345,7 +1250,7 @@ void QUnixPrintWidgetPrivate::setupPrinterProperties()
QPrinter::OutputFormat outputFormat;
QString printerName;
- if (q->isOptionEnabled(QPrintDialog::PrintToFile)
+ if (q->testOption(QPrintDialog::PrintToFile)
&& (widget.printers->currentIndex() == widget.printers->count() - 1)) {// PDF
outputFormat = QPrinter::PdfFormat;
} else {
@@ -1417,22 +1322,25 @@ QUnixPrintWidget::QUnixPrintWidget(QPrinter *printer, QWidget *parent)
if (printer->outputFileName().isEmpty()) {
QString home = QDir::homePath();
QString cur = QDir::currentPath();
- if (!home.endsWith(QLatin1Char('/')))
- home += QLatin1Char('/');
+ if (!home.endsWith(u'/'))
+ home += u'/';
if (!cur.startsWith(home))
cur = home;
- else if (!cur.endsWith(QLatin1Char('/')))
- cur += QLatin1Char('/');
- if (QGuiApplication::platformName() == QStringLiteral("xcb")) {
+ else if (!cur.endsWith(u'/'))
+ cur += u'/';
+ if (QGuiApplication::platformName() == "xcb"_L1) {
if (printer->docName().isEmpty()) {
- cur += QStringLiteral("print.pdf");
+ cur += "print.pdf"_L1;
} else {
- const QRegExp re(QStringLiteral("(.*)\\.\\S+"));
- if (re.exactMatch(printer->docName()))
- cur += re.cap(1);
+#if QT_CONFIG(regularexpression)
+ const QRegularExpression re(QStringLiteral("(.*)\\.\\S+"));
+ auto match = re.match(printer->docName());
+ if (match.hasMatch())
+ cur += match.captured(1);
else
+#endif
cur += printer->docName();
- cur += QStringLiteral(".pdf");
+ cur += ".pdf"_L1;
}
} // xcb
diff --git a/src/printsupport/dialogs/qprintdialog_win.cpp b/src/printsupport/dialogs/qprintdialog_win.cpp
index 11f2fa3259..6d8c2d0f4d 100644
--- a/src/printsupport/dialogs/qprintdialog_win.cpp
+++ b/src/printsupport/dialogs/qprintdialog_win.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include <QtPrintSupport/qtprintsupportglobal.h>
@@ -47,7 +11,7 @@
#include <private/qapplication_p.h>
#include "qabstractprintdialog_p.h"
-#include "../kernel/qprintengine_win_p.h"
+#include <private/qprintengine_win_p.h>
#include "../kernel/qprinter_p.h"
#if !defined(PD_NOCURRENTPAGE)
@@ -59,6 +23,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
//extern void qt_win_eatMouseMove();
class QPrintDialogPrivate : public QAbstractPrintDialogPrivate
@@ -76,7 +42,7 @@ public:
QWin32PrintEnginePrivate *ep;
};
-static void qt_win_setup_PRINTDLGEX(PRINTDLGEX *pd, QWidget *parent,
+static void qt_win_setup_PRINTDLGEX(PRINTDLGEX *pd, QWindow *parentWindow,
QPrintDialog *pdlg,
QPrintDialogPrivate *d, HGLOBAL *tempDevNames)
{
@@ -98,21 +64,21 @@ static void qt_win_setup_PRINTDLGEX(PRINTDLGEX *pd, QWidget *parent,
pd->Flags = PD_RETURNDC;
pd->Flags |= PD_USEDEVMODECOPIESANDCOLLATE;
- if (!pdlg->isOptionEnabled(QPrintDialog::PrintSelection))
+ if (!pdlg->testOption(QPrintDialog::PrintSelection))
pd->Flags |= PD_NOSELECTION;
- if (pdlg->isOptionEnabled(QPrintDialog::PrintPageRange)) {
+ if (pdlg->testOption(QPrintDialog::PrintPageRange)) {
pd->nMinPage = pdlg->minPage();
pd->nMaxPage = pdlg->maxPage();
}
- if(!pdlg->isOptionEnabled(QPrintDialog::PrintToFile))
+ if (!pdlg->testOption(QPrintDialog::PrintToFile))
pd->Flags |= PD_DISABLEPRINTTOFILE;
- if (pdlg->isOptionEnabled(QPrintDialog::PrintSelection) && pdlg->printRange() == QPrintDialog::Selection)
+ if (pdlg->testOption(QPrintDialog::PrintSelection) && pdlg->printRange() == QPrintDialog::Selection)
pd->Flags |= PD_SELECTION;
- else if (pdlg->isOptionEnabled(QPrintDialog::PrintPageRange) && pdlg->printRange() == QPrintDialog::PageRange)
+ else if (pdlg->testOption(QPrintDialog::PrintPageRange) && pdlg->printRange() == QPrintDialog::PageRange)
pd->Flags |= PD_PAGENUMS;
- else if (pdlg->isOptionEnabled(QPrintDialog::PrintCurrentPage) && pdlg->printRange() == QPrintDialog::CurrentPage)
+ else if (pdlg->testOption(QPrintDialog::PrintCurrentPage) && pdlg->printRange() == QPrintDialog::CurrentPage)
pd->Flags |= PD_CURRENTPAGE;
else
pd->Flags |= PD_ALLPAGES;
@@ -123,7 +89,7 @@ static void qt_win_setup_PRINTDLGEX(PRINTDLGEX *pd, QWidget *parent,
pd->Flags |= PD_NOPAGENUMS;
// Disable Current Page option if not required as default is Enabled
- if (!pdlg->isOptionEnabled(QPrintDialog::PrintCurrentPage))
+ if (!pdlg->testOption(QPrintDialog::PrintCurrentPage))
pd->Flags |= PD_NOCURRENTPAGE;
// Default to showing the General tab first
@@ -135,9 +101,12 @@ static void qt_win_setup_PRINTDLGEX(PRINTDLGEX *pd, QWidget *parent,
if (d->ep->printToFile)
pd->Flags |= PD_PRINTTOFILE;
- Q_ASSERT(parent);
- QWindow *parentWindow = parent->windowHandle();
- pd->hwndOwner = parentWindow ? (HWND)QGuiApplication::platformNativeInterface()->nativeResourceForWindow("handle", parentWindow) : 0;
+
+ WId wId = parentWindow ? parentWindow->winId() : 0;
+ //QTBUG-118899 PrintDlg needs valid window handle in hwndOwner
+ //So in case there is no valid handle in the application,
+ //use the desktop as valid handle.
+ pd->hwndOwner = wId != 0 ? HWND(wId) : GetDesktopWindow();
pd->lpPageRanges[0].nFromPage = qMax(pdlg->fromPage(), pdlg->minPage());
pd->lpPageRanges[0].nToPage = (pdlg->toPage() > 0) ? qMin(pdlg->toPage(), pdlg->maxPage()) : 1;
pd->nCopies = d->printer->copyCount();
@@ -147,16 +116,16 @@ static void qt_win_read_back_PRINTDLGEX(PRINTDLGEX *pd, QPrintDialog *pdlg, QPri
{
if (pd->Flags & PD_SELECTION) {
pdlg->setPrintRange(QPrintDialog::Selection);
- pdlg->setFromTo(0, 0);
+ pdlg->printer()->setPageRanges(QPageRanges());
} else if (pd->Flags & PD_PAGENUMS) {
pdlg->setPrintRange(QPrintDialog::PageRange);
pdlg->setFromTo(pd->lpPageRanges[0].nFromPage, pd->lpPageRanges[0].nToPage);
} else if (pd->Flags & PD_CURRENTPAGE) {
pdlg->setPrintRange(QPrintDialog::CurrentPage);
- pdlg->setFromTo(0, 0);
+ pdlg->printer()->setPageRanges(QPageRanges());
} else { // PD_ALLPAGES
pdlg->setPrintRange(QPrintDialog::AllPages);
- pdlg->setFromTo(0, 0);
+ pdlg->printer()->setPageRanges(QPageRanges());
}
d->ep->printToFile = (pd->Flags & PD_PRINTTOFILE) != 0;
@@ -164,8 +133,8 @@ static void qt_win_read_back_PRINTDLGEX(PRINTDLGEX *pd, QPrintDialog *pdlg, QPri
d->engine->setGlobalDevMode(pd->hDevNames, pd->hDevMode);
if (d->ep->printToFile && d->ep->fileName.isEmpty())
- d->ep->fileName = QLatin1String("FILE:");
- else if (!d->ep->printToFile && d->ep->fileName == QLatin1String("FILE:"))
+ d->ep->fileName = "FILE:"_L1;
+ else if (!d->ep->printToFile && d->ep->fileName == "FILE:"_L1)
d->ep->fileName.clear();
}
@@ -216,15 +185,20 @@ int QPrintDialog::exec()
int QPrintDialogPrivate::openWindowsPrintDialogModally()
{
Q_Q(QPrintDialog);
- QWidget *parent = q->parentWidget();
- if (parent)
- parent = parent->window();
- else
- parent = QApplication::activeWindow();
-
- // If there is no window, fall back to the print dialog itself
- if (parent == 0)
- parent = q;
+ QWindow *parentWindow = q->windowHandle() ? q->windowHandle()->transientParent() : nullptr;
+ if (!parentWindow) {
+ QWidget *parent = q->parentWidget();
+ if (parent)
+ parent = parent->window();
+ else
+ parent = QApplication::activeWindow();
+
+ // If there is no window, fall back to the print dialog itself
+ if (!parent)
+ parent = q;
+
+ parentWindow = parent->windowHandle();
+ }
q->QDialog::setVisible(true);
@@ -239,7 +213,7 @@ int QPrintDialogPrivate::openWindowsPrintDialogModally()
memset(&pd, 0, sizeof(PRINTDLGEX));
pd.lStructSize = sizeof(PRINTDLGEX);
pd.lpPageRanges = &pageRange;
- qt_win_setup_PRINTDLGEX(&pd, parent, q, this, tempDevNames);
+ qt_win_setup_PRINTDLGEX(&pd, parentWindow, q, this, tempDevNames);
do {
done = true;
@@ -261,9 +235,9 @@ int QPrintDialogPrivate::openWindowsPrintDialogModally()
}
if (!done) {
- QMessageBox::warning(0, QPrintDialog::tr("Print"),
- QPrintDialog::tr("The 'From' value cannot be greater than the 'To' value."),
- QPrintDialog::tr("OK"));
+ QMessageBox::warning(nullptr,
+ QPrintDialog::tr("Print"),
+ QPrintDialog::tr("The 'From' value cannot be greater than the 'To' value."));
}
} while (!done);
diff --git a/src/printsupport/dialogs/qprintpreviewdialog.cpp b/src/printsupport/dialogs/qprintpreviewdialog.cpp
index 418bc47a59..3c19e25c64 100644
--- a/src/printsupport/dialogs/qprintpreviewdialog.cpp
+++ b/src/printsupport/dialogs/qprintpreviewdialog.cpp
@@ -1,48 +1,13 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qprintpreviewdialog.h"
#include "qprintpreviewwidget.h"
#include <private/qprinter_p.h>
#include "qprintdialog.h"
-#include <QtWidgets/qaction.h>
+#include <QtGui/qaction.h>
+#include <QtGui/qactiongroup.h>
#include <QtWidgets/qboxlayout.h>
#include <QtWidgets/qcombobox.h>
#include <QtWidgets/qlineedit.h>
@@ -63,7 +28,9 @@
#include <QtWidgets/qformlayout.h>
#include <QtWidgets/qlabel.h>
-static void initResources()
+#include <QtCore/qpointer.h>
+
+static void _q_ppd_initResources()
{
static bool resourcesInitialized = false;
if (!resourcesInitialized) {
@@ -74,6 +41,8 @@ static void initResources()
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
namespace {
class QPrintPreviewMainWindow : public QMainWindow
{
@@ -93,13 +62,13 @@ public:
State validate(QString &input, int &pos) const override
{
bool replacePercent = false;
- if (input.endsWith(QLatin1Char('%'))) {
- input = input.left(input.length() - 1);
+ if (input.endsWith(u'%')) {
+ input = input.left(input.size() - 1);
replacePercent = true;
}
State state = QDoubleValidator::validate(input, pos);
if (replacePercent)
- input += QLatin1Char('%');
+ input += u'%';
const int num_size = 4;
if (state == Intermediate) {
int i = input.indexOf(QLocale::system().decimalPoint());
@@ -152,8 +121,8 @@ class QPrintPreviewDialogPrivate : public QDialogPrivate
Q_DECLARE_PUBLIC(QPrintPreviewDialog)
public:
QPrintPreviewDialogPrivate()
- : printDialog(nullptr), ownPrinter(false),
- initialized(false) {}
+ : printDialog(nullptr), pageSetupDialog(nullptr),
+ ownPrinter(false), initialized(false) {}
// private slots
void _q_fit(QAction *action);
@@ -178,6 +147,7 @@ public:
void updateZoomFactor();
QPrintDialog *printDialog;
+ QPageSetupDialog *pageSetupDialog;
QPrintPreviewWidget *preview;
QPrinter *printer;
bool ownPrinter;
@@ -224,7 +194,7 @@ void QPrintPreviewDialogPrivate::init(QPrinter *_printer)
{
Q_Q(QPrintPreviewDialog);
- initResources();
+ _q_ppd_initResources();
if (_printer) {
preview = new QPrintPreviewWidget(_printer, q);
@@ -280,7 +250,7 @@ void QPrintPreviewDialogPrivate::init(QPrinter *_printer)
QWidget *pageEdit = new QWidget(toolbar);
QVBoxLayout *vboxLayout = new QVBoxLayout;
vboxLayout->setContentsMargins(0, 0, 0, 0);
-#ifdef Q_OS_MAC
+#ifdef Q_OS_MACOS
// We query the widgets about their size and then we fix the size.
// This should do the trick for the laying out part...
QSize pageNumEditSize, pageNumLabelSize;
@@ -290,7 +260,7 @@ void QPrintPreviewDialogPrivate::init(QPrinter *_printer)
pageNumLabel->resize(pageNumLabelSize);
#endif
QFormLayout *formLayout = new QFormLayout;
-#ifdef Q_OS_MAC
+#ifdef Q_OS_MACOS
// We have to change the growth policy in Mac.
formLayout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
#endif
@@ -331,16 +301,16 @@ void QPrintPreviewDialogPrivate::init(QPrinter *_printer)
QVBoxLayout *topLayout = new QVBoxLayout;
topLayout->addWidget(mw);
- topLayout->setMargin(0);
+ topLayout->setContentsMargins(0, 0, 0, 0);
q->setLayout(topLayout);
QString caption = QCoreApplication::translate("QPrintPreviewDialog", "Print Preview");
if (!printer->docName().isEmpty())
- caption += QLatin1String(": ") + printer->docName();
+ caption += ": "_L1 + printer->docName();
q->setWindowTitle(caption);
if (!printer->isValid()
-#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
+#if defined(Q_OS_WIN) || defined(Q_OS_APPLE)
|| printer->outputFormat() != QPrinter::NativeFormat
#endif
)
@@ -348,12 +318,12 @@ void QPrintPreviewDialogPrivate::init(QPrinter *_printer)
preview->setFocus();
}
-static inline void qt_setupActionIcon(QAction *action, QLatin1String name)
+static inline void qt_setupActionIcon(QAction *action, QLatin1StringView name)
{
- QLatin1String imagePrefix(":/qt-project.org/dialogs/qprintpreviewdialog/images/");
- QIcon icon;
- icon.addFile(imagePrefix + name + QLatin1String("-24.png"), QSize(24, 24));
- icon.addFile(imagePrefix + name + QLatin1String("-32.png"), QSize(32, 32));
+ const auto imagePrefix = ":/qt-project.org/dialogs/qprintpreviewdialog/images/"_L1;
+ QIcon icon = QIcon::fromTheme(name);
+ icon.addFile(imagePrefix + name + "-24.png"_L1, QSize(24, 24));
+ icon.addFile(imagePrefix + name + "-32.png"_L1, QSize(32, 32));
action->setIcon(icon);
}
@@ -368,30 +338,30 @@ void QPrintPreviewDialogPrivate::setupActions()
prevPageAction = navGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Previous page"));
firstPageAction = navGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "First page"));
lastPageAction = navGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Last page"));
- qt_setupActionIcon(nextPageAction, QLatin1String("go-next"));
- qt_setupActionIcon(prevPageAction, QLatin1String("go-previous"));
- qt_setupActionIcon(firstPageAction, QLatin1String("go-first"));
- qt_setupActionIcon(lastPageAction, QLatin1String("go-last"));
+ qt_setupActionIcon(nextPageAction, "go-next"_L1);
+ qt_setupActionIcon(prevPageAction, "go-previous"_L1);
+ qt_setupActionIcon(firstPageAction, "go-first"_L1);
+ qt_setupActionIcon(lastPageAction, "go-last"_L1);
QObject::connect(navGroup, SIGNAL(triggered(QAction*)), q, SLOT(_q_navigate(QAction*)));
fitGroup = new QActionGroup(q);
fitWidthAction = fitGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Fit width"));
fitPageAction = fitGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Fit page"));
- fitWidthAction->setObjectName(QLatin1String("fitWidthAction"));
- fitPageAction->setObjectName(QLatin1String("fitPageAction"));
+ fitWidthAction->setObjectName("fitWidthAction"_L1);
+ fitPageAction->setObjectName("fitPageAction"_L1);
fitWidthAction->setCheckable(true);
fitPageAction->setCheckable(true);
- qt_setupActionIcon(fitWidthAction, QLatin1String("fit-width"));
- qt_setupActionIcon(fitPageAction, QLatin1String("fit-page"));
+ qt_setupActionIcon(fitWidthAction, "zoom-fit-width"_L1);
+ qt_setupActionIcon(fitPageAction, "zoom-fit-page"_L1);
QObject::connect(fitGroup, SIGNAL(triggered(QAction*)), q, SLOT(_q_fit(QAction*)));
// Zoom
zoomGroup = new QActionGroup(q);
zoomInAction = zoomGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Zoom in"));
zoomOutAction = zoomGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Zoom out"));
- qt_setupActionIcon(zoomInAction, QLatin1String("zoom-in"));
- qt_setupActionIcon(zoomOutAction, QLatin1String("zoom-out"));
+ qt_setupActionIcon(zoomInAction, "zoom-in"_L1);
+ qt_setupActionIcon(zoomOutAction, "zoom-out"_L1);
// Portrait/Landscape
orientationGroup = new QActionGroup(q);
@@ -399,8 +369,8 @@ void QPrintPreviewDialogPrivate::setupActions()
landscapeAction = orientationGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Landscape"));
portraitAction->setCheckable(true);
landscapeAction->setCheckable(true);
- qt_setupActionIcon(portraitAction, QLatin1String("layout-portrait"));
- qt_setupActionIcon(landscapeAction, QLatin1String("layout-landscape"));
+ qt_setupActionIcon(portraitAction, "layout-portrait"_L1);
+ qt_setupActionIcon(landscapeAction, "layout-landscape"_L1);
QObject::connect(portraitAction, SIGNAL(triggered(bool)), preview, SLOT(setPortraitOrientation()));
QObject::connect(landscapeAction, SIGNAL(triggered(bool)), preview, SLOT(setLandscapeOrientation()));
@@ -409,12 +379,12 @@ void QPrintPreviewDialogPrivate::setupActions()
singleModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show single page"));
facingModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show facing pages"));
overviewModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show overview of all pages"));
- qt_setupActionIcon(singleModeAction, QLatin1String("view-page-one"));
- qt_setupActionIcon(facingModeAction, QLatin1String("view-page-sided"));
- qt_setupActionIcon(overviewModeAction, QLatin1String("view-page-multi"));
- singleModeAction->setObjectName(QLatin1String("singleModeAction"));
- facingModeAction->setObjectName(QLatin1String("facingModeAction"));
- overviewModeAction->setObjectName(QLatin1String("overviewModeAction"));
+ qt_setupActionIcon(singleModeAction, "view-pages-single"_L1);
+ qt_setupActionIcon(facingModeAction, "view-pages-facing"_L1);
+ qt_setupActionIcon(overviewModeAction, "view-pages-overview"_L1);
+ singleModeAction->setObjectName("singleModeAction"_L1);
+ facingModeAction->setObjectName("facingModeAction"_L1);
+ overviewModeAction->setObjectName("overviewModeAction"_L1);
singleModeAction->setCheckable(true);
facingModeAction->setCheckable(true);
@@ -425,15 +395,15 @@ void QPrintPreviewDialogPrivate::setupActions()
printerGroup = new QActionGroup(q);
printAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Print"));
pageSetupAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Page setup"));
- qt_setupActionIcon(printAction, QLatin1String("print"));
- qt_setupActionIcon(pageSetupAction, QLatin1String("page-setup"));
+ qt_setupActionIcon(printAction, "printer"_L1);
+ qt_setupActionIcon(pageSetupAction, "page-setup"_L1);
QObject::connect(printAction, SIGNAL(triggered(bool)), q, SLOT(_q_print()));
QObject::connect(pageSetupAction, SIGNAL(triggered(bool)), q, SLOT(_q_pageSetup()));
// Initial state:
fitPageAction->setChecked(true);
singleModeAction->setChecked(true);
- if (preview->orientation() == QPrinter::Portrait)
+ if (preview->orientation() == QPageLayout::Portrait)
portraitAction->setChecked(true);
else
landscapeAction->setChecked(true);
@@ -482,9 +452,9 @@ void QPrintPreviewDialogPrivate::updatePageNumLabel()
Q_Q(QPrintPreviewDialog);
int numPages = preview->pageCount();
- int maxChars = QString::number(numPages).length();
+ int maxChars = QString::number(numPages).size();
pageNumLabel->setText(QString::fromLatin1("/ %1").arg(numPages));
- int cyphersWidth = q->fontMetrics().horizontalAdvance(QString().fill(QLatin1Char('8'), maxChars));
+ int cyphersWidth = q->fontMetrics().horizontalAdvance(QString().fill(u'8', maxChars));
int maxWidth = pageNumEdit->minimumSizeHint().width() + cyphersWidth;
pageNumEdit->setMinimumWidth(maxWidth);
pageNumEdit->setMaximumWidth(maxWidth);
@@ -494,7 +464,7 @@ void QPrintPreviewDialogPrivate::updatePageNumLabel()
void QPrintPreviewDialogPrivate::updateZoomFactor()
{
- zoomFactor->lineEdit()->setText(QString().sprintf("%.1f%%", preview->zoomFactor()*100));
+ zoomFactor->lineEdit()->setText(QString::asprintf("%.1f%%", preview->zoomFactor()*100));
}
void QPrintPreviewDialogPrivate::_q_fit(QAction* action)
@@ -569,14 +539,13 @@ void QPrintPreviewDialogPrivate::_q_print()
{
Q_Q(QPrintPreviewDialog);
-#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
+#if defined(Q_OS_WIN) || defined(Q_OS_APPLE)
if (printer->outputFormat() != QPrinter::NativeFormat) {
QString title = QCoreApplication::translate("QPrintPreviewDialog", "Export to PDF");
- QString suffix = QLatin1String(".pdf");
+ QString suffix = ".pdf"_L1;
QString fileName;
#if QT_CONFIG(filedialog)
- fileName = QFileDialog::getSaveFileName(q, title, printer->outputFileName(),
- QLatin1Char('*') + suffix);
+ fileName = QFileDialog::getSaveFileName(q, title, printer->outputFileName(), u'*' + suffix);
#endif
if (!fileName.isEmpty()) {
if (QFileInfo(fileName).suffix().isEmpty())
@@ -602,10 +571,12 @@ void QPrintPreviewDialogPrivate::_q_pageSetup()
{
Q_Q(QPrintPreviewDialog);
- QPageSetupDialog pageSetup(printer, q);
- if (pageSetup.exec() == QDialog::Accepted) {
+ if (!pageSetupDialog)
+ pageSetupDialog = new QPageSetupDialog(printer, q);
+
+ if (pageSetupDialog->exec() == QDialog::Accepted) {
// update possible orientation changes
- if (preview->orientation() == QPrinter::Portrait) {
+ if (preview->orientation() == QPageLayout::Portrait) {
portraitAction->setChecked(true);
preview->setPortraitOrientation();
}else {
@@ -626,7 +597,7 @@ void QPrintPreviewDialogPrivate::_q_zoomFactorChanged()
{
QString text = zoomFactor->lineEdit()->text();
bool ok;
- qreal factor = text.remove(QLatin1Char('%')).toFloat(&ok);
+ qreal factor = text.remove(u'%').toFloat(&ok);
factor = qMax(qreal(1.0), qMin(qreal(1000.0), factor));
if (ok) {
preview->setZoomFactor(factor/100.0);
@@ -713,6 +684,7 @@ QPrintPreviewDialog::~QPrintPreviewDialog()
if (d->ownPrinter)
delete d->printer;
delete d->printDialog;
+ delete d->pageSetupDialog;
}
/*!
diff --git a/src/printsupport/dialogs/qprintpreviewdialog.h b/src/printsupport/dialogs/qprintpreviewdialog.h
index 53fede7e83..5c0cb8de98 100644
--- a/src/printsupport/dialogs/qprintpreviewdialog.h
+++ b/src/printsupport/dialogs/qprintpreviewdialog.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QPRINTPREVIEWDIALOG_H
#define QPRINTPREVIEWDIALOG_H
diff --git a/src/printsupport/dialogs/qprintsettingsoutput.ui b/src/printsupport/dialogs/qprintsettingsoutput.ui
index 290111a98c..360634aaa7 100644
--- a/src/printsupport/dialogs/qprintsettingsoutput.ui
+++ b/src/printsupport/dialogs/qprintsettingsoutput.ui
@@ -351,13 +351,13 @@
<item row="0" column="0">
<widget class="QGroupBox" name="duplex">
<property name="title">
- <string>Duplex Printing</string>
+ <string>Double Sided Printing</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QRadioButton" name="noDuplex">
<property name="text">
- <string>None</string>
+ <string>Off</string>
</property>
<property name="checked">
<bool>true</bool>
@@ -367,14 +367,14 @@
<item>
<widget class="QRadioButton" name="duplexLong">
<property name="text">
- <string>Long side</string>
+ <string>Long side binding</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="duplexShort">
<property name="text">
- <string>Short side</string>
+ <string>Short side binding</string>
</property>
</widget>
</item>