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.cpp94
-rw-r--r--src/printsupport/dialogs/qabstractprintdialog.h51
-rw-r--r--src/printsupport/dialogs/qabstractprintdialog_p.h42
-rw-r--r--src/printsupport/dialogs/qpagesetupdialog.cpp40
-rw-r--r--src/printsupport/dialogs/qpagesetupdialog.h42
-rw-r--r--src/printsupport/dialogs/qpagesetupdialog_mac.mm44
-rw-r--r--src/printsupport/dialogs/qpagesetupdialog_p.h40
-rw-r--r--src/printsupport/dialogs/qpagesetupdialog_unix.cpp49
-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.h40
-rw-r--r--src/printsupport/dialogs/qprintdialog.qdoc28
-rw-r--r--src/printsupport/dialogs/qprintdialog.qrc38
-rw-r--r--src/printsupport/dialogs/qprintdialog_mac.mm65
-rw-r--r--src/printsupport/dialogs/qprintdialog_unix.cpp142
-rw-r--r--src/printsupport/dialogs/qprintdialog_win.cpp110
-rw-r--r--src/printsupport/dialogs/qprintpreviewdialog.cpp121
-rw-r--r--src/printsupport/dialogs/qprintpreviewdialog.h40
31 files changed, 240 insertions, 919 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 b0d03037e6..9cbba6bdbb 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)
@@ -483,3 +395,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 372716adfc..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,15 +30,11 @@ public:
};
enum PrintDialogOption {
- None = 0x0000, // obsolete
PrintToFile = 0x0001,
PrintSelection = 0x0002,
PrintPageRange = 0x0004,
PrintShowPageSize = 0x0008,
PrintCollateCopies = 0x0010,
-#if QT_DEPRECATED_SINCE(5, 14)
- DontUseSheet Q_DECL_ENUMERATOR_DEPRECATED = 0x0020,
-#endif
PrintCurrentPage = 0x0040
};
Q_ENUM(PrintDialogOption)
@@ -86,12 +45,6 @@ public:
explicit QAbstractPrintDialog(QPrinter *printer, QWidget *parent = nullptr);
~QAbstractPrintDialog();
- // 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 ce2a0416c8..0bc80c1f6f 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>
diff --git a/src/printsupport/dialogs/qpagesetupdialog.h b/src/printsupport/dialogs/qpagesetupdialog.h
index a7aaa03134..80d9c7a7fd 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_MAC) || 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 b88d03696a..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>
@@ -49,6 +13,8 @@
#include <QtPrintSupport/private/qprintengine_mac_p.h>
+#include <QtCore/private/qcore_mac_p.h>
+
QT_USE_NAMESPACE
@class QT_MANGLE_NAMESPACE(QCocoaPageLayoutDelegate);
@@ -84,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);
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 739deaa6e1..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"
@@ -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;
@@ -298,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);
}
@@ -529,6 +495,7 @@ 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 = qvariant_cast<QCUPSSupport::PagesPerSheet>(m_ui.pagesPerSheetCombo->currentData()
);
@@ -749,4 +716,6 @@ int QPageSetupDialog::exec()
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..fa05f42bea 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
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 9f84f98588..fa4fac1884 100644
--- a/src/printsupport/dialogs/qprintdialog_mac.mm
+++ b/src/printsupport/dialogs/qprintdialog_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>
@@ -53,6 +17,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
extern qreal qt_pointMultiplier(QPageLayout::Unit unit);
class QPrintDialogPrivate : public QAbstractPrintDialogPrivate
@@ -117,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
@@ -135,7 +101,7 @@ QT_USE_NAMESPACE
UInt8 localFile[2048]; // Assuming there's a POSIX file system here.
CFURLGetFileSystemRepresentation(file, true, localFile, sizeof(localFile));
auto outputFile = QFileInfo(QString::fromUtf8(reinterpret_cast<const char *>(localFile)));
- if (outputFile.suffix() == QLatin1String("pdf"))
+ if (outputFile.suffix() == "pdf"_L1)
printer->setOutputFileName(outputFile.absoluteFilePath());
else
qWarning() << "Can not print to file type" << outputFile.suffix();
@@ -144,7 +110,7 @@ QT_USE_NAMESPACE
auto documentName = printer->docName();
if (documentName.isEmpty())
documentName = QGuiApplication::applicationDisplayName();
- auto fileName = printPreviews.filePath(QString(QLatin1String("%1.pdf")).arg(documentName));
+ 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
@@ -152,7 +118,7 @@ QT_USE_NAMESPACE
// 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 openFile:fileName.toNSString()];
+ [NSWorkspace.sharedWorkspace openURL:[NSURL fileURLWithPath:fileName.toNSString()]];
});
} else if (dest == kPMDestinationProcessPDF) {
qWarning("Printing workflows are not supported");
@@ -204,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);
}
@@ -221,7 +187,13 @@ void QPrintDialogPrivate::openCocoaPrintPanel(Qt::WindowModality modality)
printInfo = static_cast<QMacPrintEngine *>(printer->printEngine())->printInfo();
[printInfo retain];
} else {
- printInfo = [NSPrintInfo.sharedPrintInfo retain];
+ 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
@@ -266,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
@@ -299,6 +271,7 @@ QPrintDialog::QPrintDialog(QWidget *parent)
QPrintDialog::~QPrintDialog()
{
+ hide();
}
int QPrintDialog::exec()
diff --git a/src/printsupport/dialogs/qprintdialog_unix.cpp b/src/printsupport/dialogs/qprintdialog_unix.cpp
index 6dcb613ff5..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>
@@ -54,12 +18,11 @@
#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>
#include <QtPrintSupport/qprinter.h>
-#include <QtGui/qrangecollection.h>
#include <qpa/qplatformprintplugin.h>
#include <qpa/qplatformprintersupport.h>
@@ -120,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
@@ -209,7 +174,7 @@ public:
QUnixPrintWidget * const parent;
QPrintPropertiesDialog *propertiesDialog;
Ui::QPrintWidget widget;
- QAbstractPrintDialog * q;
+ QPrintDialog * q;
QPrinter *printer;
QPrintDevice m_currentPrintDevice;
@@ -357,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"),
@@ -619,7 +584,7 @@ QPrintDialogPrivate::QPrintDialogPrivate()
: top(nullptr), bottom(nullptr), buttons(nullptr), collapseButton(nullptr),
explicitDuplexMode(QPrint::DuplexAuto)
{
- initResources();
+ _q_pdu_initResources();
}
QPrintDialogPrivate::~QPrintDialogPrivate()
@@ -634,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
@@ -709,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;
@@ -797,39 +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()) {
- p->setPrintRange(QPrinter::PageRange);
- p->rangeCollection()->parse(options.pagesLineEdit->text());
+ 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, p->rangeCollection()->toString());
+ 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 = qvariant_cast<QCUPSSupport::PageSet>(options.pageSetCombo->itemData(options.pageSetCombo->currentIndex()));
- if (q->isOptionEnabled(QPrintDialog::PrintPageRange)
+ if (q->testOption(QPrintDialog::PrintPageRange)
&& p->printRange() == QPrinter::PageRange
&& (q->fromPage() % 2 == 0)) {
@@ -849,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
@@ -898,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 {
@@ -918,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);
@@ -940,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);
}
@@ -1021,8 +990,8 @@ int QPrintDialog::exec()
void QPrintDialog::accept()
{
Q_D(QPrintDialog);
-#if QT_CONFIG(cups)
- if (d->options.pagesRadioButton->isChecked() && printer()->rangeCollection()->isEmpty()) {
+#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 "
@@ -1066,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);
@@ -1104,12 +1073,14 @@ QUnixPrintWidgetPrivate::QUnixPrintWidgetPrivate(QUnixPrintWidget *p, QPrinter *
void QUnixPrintWidgetPrivate::updateWidget()
{
- const bool printToFile = q == nullptr || 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);
@@ -1131,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()
@@ -1166,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;
}
}
@@ -1278,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 {
@@ -1350,15 +1322,15 @@ 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 {
#if QT_CONFIG(regularexpression)
const QRegularExpression re(QStringLiteral("(.*)\\.\\S+"));
@@ -1368,7 +1340,7 @@ QUnixPrintWidget::QUnixPrintWidget(QPrinter *printer, QWidget *parent)
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 e9f2b5e882..2028287b55 100644
--- a/src/printsupport/dialogs/qprintpreviewdialog.cpp
+++ b/src/printsupport/dialogs/qprintpreviewdialog.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 "qprintpreviewdialog.h"
#include "qprintpreviewwidget.h"
@@ -64,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) {
@@ -75,6 +41,8 @@ static void initResources()
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
namespace {
class QPrintPreviewMainWindow : public QMainWindow
{
@@ -94,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());
@@ -226,7 +194,7 @@ void QPrintPreviewDialogPrivate::init(QPrinter *_printer)
{
Q_Q(QPrintPreviewDialog);
- initResources();
+ _q_ppd_initResources();
if (_printer) {
preview = new QPrintPreviewWidget(_printer, q);
@@ -338,7 +306,7 @@ void QPrintPreviewDialogPrivate::init(QPrinter *_printer)
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()
@@ -350,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);
}
@@ -370,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);
@@ -401,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()));
@@ -411,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);
@@ -427,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);
@@ -484,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);
@@ -574,11 +542,10 @@ void QPrintPreviewDialogPrivate::_q_print()
#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
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())
@@ -609,7 +576,7 @@ void QPrintPreviewDialogPrivate::_q_pageSetup()
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 {
@@ -630,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);
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