summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2020-09-23 12:58:08 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2020-09-24 10:36:38 +0200
commitfb18fe0316540d93f1bc2d4faf8eb1822e1481cb (patch)
treefe51c30b0aa36a71150af9ec117e89892e240ab8
parentab428e30004448dcff3c65163a8eb6533dd81542 (diff)
Windows: Build print support plugin directly into QtPrintSupport
Task-number: QTBUG-83259 Change-Id: I23042e1eb89d407692a96bfb2d6c4efdddbfb50f Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
-rw-r--r--src/plugins/printsupport/.prev_CMakeLists.txt3
-rw-r--r--src/plugins/printsupport/CMakeLists.txt3
-rw-r--r--src/plugins/printsupport/printsupport.pro1
-rw-r--r--src/plugins/printsupport/windows/main.cpp66
-rw-r--r--src/plugins/printsupport/windows/windows.pro26
-rw-r--r--src/printsupport/CMakeLists.txt21
-rw-r--r--src/printsupport/dialogs/qpagesetupdialog_win.cpp2
-rw-r--r--src/printsupport/dialogs/qprintdialog_win.cpp2
-rw-r--r--src/printsupport/kernel/kernel.pri9
-rw-r--r--src/printsupport/platform/windows/qprintengine_win.cpp (renamed from src/printsupport/kernel/qprintengine_win.cpp)4
-rw-r--r--src/printsupport/platform/windows/qprintengine_win_p.h (renamed from src/printsupport/kernel/qprintengine_win_p.h)8
-rw-r--r--src/printsupport/platform/windows/qwindowsprintdevice.cpp (renamed from src/plugins/printsupport/windows/qwindowsprintdevice.cpp)11
-rw-r--r--src/printsupport/platform/windows/qwindowsprintdevice_p.h (renamed from src/plugins/printsupport/windows/qwindowsprintdevice.h)13
-rw-r--r--src/printsupport/platform/windows/qwindowsprinterinfo.cpp (renamed from src/plugins/printsupport/windows/qwindowsprinterinfo.cpp)0
-rw-r--r--src/printsupport/platform/windows/qwindowsprintersupport.cpp (renamed from src/plugins/printsupport/windows/qwindowsprintersupport.cpp)36
-rw-r--r--src/printsupport/platform/windows/qwindowsprintersupport_p.h (renamed from src/plugins/printsupport/windows/qwindowsprintersupport.h)21
-rw-r--r--src/printsupport/platform/windows/windows.json (renamed from src/plugins/printsupport/windows/windows.json)0
-rw-r--r--src/printsupport/platform/windows/windows.pri16
-rw-r--r--src/printsupport/printsupport.pro1
19 files changed, 101 insertions, 142 deletions
diff --git a/src/plugins/printsupport/.prev_CMakeLists.txt b/src/plugins/printsupport/.prev_CMakeLists.txt
index 14b36b4b7f..6d265f9285 100644
--- a/src/plugins/printsupport/.prev_CMakeLists.txt
+++ b/src/plugins/printsupport/.prev_CMakeLists.txt
@@ -1,8 +1,5 @@
# Generated from printsupport.pro.
-if(WIN32)
- add_subdirectory(windows)
-endif()
if(QT_FEATURE_cups AND UNIX AND NOT APPLE)
add_subdirectory(cups)
endif()
diff --git a/src/plugins/printsupport/CMakeLists.txt b/src/plugins/printsupport/CMakeLists.txt
index 811e33c93f..6d265f9285 100644
--- a/src/plugins/printsupport/CMakeLists.txt
+++ b/src/plugins/printsupport/CMakeLists.txt
@@ -1,8 +1,5 @@
# Generated from printsupport.pro.
-if(WIN32)
- # add_subdirectory(windows) # special case TODO
-endif()
if(QT_FEATURE_cups AND UNIX AND NOT APPLE)
add_subdirectory(cups)
endif()
diff --git a/src/plugins/printsupport/printsupport.pro b/src/plugins/printsupport/printsupport.pro
index c7110ec338..a7397a7390 100644
--- a/src/plugins/printsupport/printsupport.pro
+++ b/src/plugins/printsupport/printsupport.pro
@@ -1,5 +1,4 @@
TEMPLATE = subdirs
QT_FOR_CONFIG += printsupport-private
-win32: SUBDIRS += windows
unix:!darwin:qtConfig(cups): SUBDIRS += cups
diff --git a/src/plugins/printsupport/windows/main.cpp b/src/plugins/printsupport/windows/main.cpp
deleted file mode 100644
index 7575006569..0000000000
--- a/src/plugins/printsupport/windows/main.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the plugins 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$
-**
-****************************************************************************/
-
-
-#include <qpa/qplatformprintplugin.h>
-#include <QtCore/QStringList>
-
-#include "qwindowsprintersupport.h"
-
-QT_BEGIN_NAMESPACE
-
-class QWindowsPrinterSupportPlugin : public QPlatformPrinterSupportPlugin
-{
- Q_OBJECT
- Q_PLUGIN_METADATA(IID QPlatformPrinterSupportFactoryInterface_iid FILE "windows.json")
-
-public:
- QPlatformPrinterSupport *create(const QString &);
-};
-
-QPlatformPrinterSupport *QWindowsPrinterSupportPlugin::create(const QString &key)
-{
- if (key.compare(key, QLatin1String("windowsprintsupport"), Qt::CaseInsensitive) == 0)
- return new QWindowsPrinterSupport;
- return 0;
-}
-
-QT_END_NAMESPACE
-
-#include "main.moc"
diff --git a/src/plugins/printsupport/windows/windows.pro b/src/plugins/printsupport/windows/windows.pro
deleted file mode 100644
index 6ca601b2a4..0000000000
--- a/src/plugins/printsupport/windows/windows.pro
+++ /dev/null
@@ -1,26 +0,0 @@
-TARGET = windowsprintersupport
-MODULE = windowsprintersupport
-
-QT *= core-private
-QT *= gui-private
-QT *= printsupport-private
-
-INCLUDEPATH *= $$QT_SOURCE_TREE/src/printsupport/kernel
-
-SOURCES += \
- main.cpp \
- qwindowsprintersupport.cpp \
- qwindowsprintdevice.cpp \
-
-HEADERS += \
- qwindowsprintersupport.h \
- qwindowsprintdevice.h \
-
-OTHER_FILES += windows.json
-
-LIBS += -lwinspool -lcomdlg32
-QMAKE_USE_PRIVATE += user32 gdi32
-
-PLUGIN_TYPE = printsupport
-PLUGIN_CLASS_NAME = QWindowsPrinterSupportPlugin
-load(qt_plugin)
diff --git a/src/printsupport/CMakeLists.txt b/src/printsupport/CMakeLists.txt
index 6372030148..1967f3d29a 100644
--- a/src/printsupport/CMakeLists.txt
+++ b/src/printsupport/CMakeLists.txt
@@ -57,20 +57,25 @@ qt_internal_extend_target(PrintSupport CONDITION MACOS
"platform/macos/qcocoaprintersupport.mm"
)
-qt_internal_extend_target(PrintSupport CONDITION QT_FEATURE_printpreviewwidget
- SOURCES
- kernel/qpaintengine_preview.cpp kernel/qpaintengine_preview_p.h
- widgets/qprintpreviewwidget.cpp widgets/qprintpreviewwidget.h
-)
-
qt_internal_extend_target(PrintSupport CONDITION WIN32
SOURCES
- kernel/qprintengine_win.cpp kernel/qprintengine_win_p.h
+ platform/windows/qprintengine_win.cpp platform/windows/qprintengine_win_p.h
+ platform/windows/qwindowsprintdevice.cpp platform/windows/qwindowsprintdevice_p.h
+ platform/windows/qwindowsprintersupport.cpp platform/windows/qwindowsprintersupport_p.h
LIBRARIES
- comdlg32
gdi32
user32
+ PUBLIC_LIBRARIES
+ comdlg32
winspool
+ NO_PCH_SOURCES
+ "platform/windows/qwindowsprintersupport.cpp"
+)
+
+qt_internal_extend_target(PrintSupport CONDITION QT_FEATURE_printpreviewwidget
+ SOURCES
+ kernel/qpaintengine_preview.cpp kernel/qpaintengine_preview_p.h
+ widgets/qprintpreviewwidget.cpp widgets/qprintpreviewwidget.h
)
qt_internal_extend_target(PrintSupport CONDITION QT_FEATURE_cups AND UNIX AND NOT APPLE
diff --git a/src/printsupport/dialogs/qpagesetupdialog_win.cpp b/src/printsupport/dialogs/qpagesetupdialog_win.cpp
index 464381bbe4..2e2b41b372 100644
--- a/src/printsupport/dialogs/qpagesetupdialog_win.cpp
+++ b/src/printsupport/dialogs/qpagesetupdialog_win.cpp
@@ -41,7 +41,7 @@
#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>
diff --git a/src/printsupport/dialogs/qprintdialog_win.cpp b/src/printsupport/dialogs/qprintdialog_win.cpp
index c103bd911d..4f2ee83f62 100644
--- a/src/printsupport/dialogs/qprintdialog_win.cpp
+++ b/src/printsupport/dialogs/qprintdialog_win.cpp
@@ -47,7 +47,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)
diff --git a/src/printsupport/kernel/kernel.pri b/src/printsupport/kernel/kernel.pri
index 5c0feaf7a9..c47ea9c87c 100644
--- a/src/printsupport/kernel/kernel.pri
+++ b/src/printsupport/kernel/kernel.pri
@@ -28,15 +28,6 @@ qtConfig(printpreviewwidget) {
SOURCES += $$PWD/qpaintengine_preview.cpp
}
-win32 {
- HEADERS += \
- $$PWD/qprintengine_win_p.h
- SOURCES += \
- $$PWD/qprintengine_win.cpp
- LIBS_PRIVATE += -lwinspool -lcomdlg32
- QMAKE_USE_PRIVATE += user32 gdi32
-}
-
unix:!darwin:qtConfig(cups) {
SOURCES += $$PWD/qcups.cpp
HEADERS += $$PWD/qcups_p.h
diff --git a/src/printsupport/kernel/qprintengine_win.cpp b/src/printsupport/platform/windows/qprintengine_win.cpp
index e8bbbcfb1e..3d00f2683c 100644
--- a/src/printsupport/kernel/qprintengine_win.cpp
+++ b/src/printsupport/platform/windows/qprintengine_win.cpp
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
-** This file is part of the QtGui module of the Qt Toolkit.
+** This file is part of the QtPrintSupport module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
diff --git a/src/printsupport/kernel/qprintengine_win_p.h b/src/printsupport/platform/windows/qprintengine_win_p.h
index 878de9a7ac..eb8609e511 100644
--- a/src/printsupport/kernel/qprintengine_win_p.h
+++ b/src/printsupport/platform/windows/qprintengine_win_p.h
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
-** This file is part of the QtGui module of the Qt Toolkit.
+** This file is part of the QtPrintSupport module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
@@ -44,8 +44,8 @@
// W A R N I N G
// -------------
//
-// This file is not part of the Qt API. It exists for the convenience
-// of other Qt classes. This header file may change from version to
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
diff --git a/src/plugins/printsupport/windows/qwindowsprintdevice.cpp b/src/printsupport/platform/windows/qwindowsprintdevice.cpp
index bfd7a9a946..5ccc12fe9f 100644
--- a/src/plugins/printsupport/windows/qwindowsprintdevice.cpp
+++ b/src/printsupport/platform/windows/qwindowsprintdevice.cpp
@@ -4,7 +4,7 @@
** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
-** This file is part of the plugins of the Qt Toolkit.
+** This file is part of the QtPrintSupport module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
@@ -38,9 +38,9 @@
**
****************************************************************************/
-#include "qwindowsprintdevice.h"
+#include "qwindowsprintdevice_p.h"
-#include <qdebug.h>
+#include <QtCore/qdebug.h>
#ifndef DC_COLLATE
# define DC_COLLATE 22
@@ -247,7 +247,7 @@ QPageSize QWindowsPrintDevice::defaultPageSize() const
// Get the default paper size
if (pDevMode->dmFields & DM_PAPERSIZE) {
// Find the supported page size that matches, in theory default should be one of them
- foreach (const QPageSize &ps, m_pageSizes) {
+ for (const QPageSize &ps : m_pageSizes) {
if (ps.windowsId() == pDevMode->dmPaperSize) {
pageSize = ps;
break;
@@ -388,7 +388,8 @@ QPrint::InputSlot QWindowsPrintDevice::defaultInputSlot() const
// Get the default input slot
if (pDevMode->dmFields & DM_DEFAULTSOURCE) {
QPrint::InputSlot tempSlot = paperBinToInputSlot(pDevMode->dmDefaultSource, QString());
- foreach (const QPrint::InputSlot &slot, supportedInputSlots()) {
+ const auto inputSlots = supportedInputSlots();
+ for (const QPrint::InputSlot &slot : inputSlots) {
if (slot.key == tempSlot.key) {
inputSlot = slot;
break;
diff --git a/src/plugins/printsupport/windows/qwindowsprintdevice.h b/src/printsupport/platform/windows/qwindowsprintdevice_p.h
index 8b63998181..bbae4971b7 100644
--- a/src/plugins/printsupport/windows/qwindowsprintdevice.h
+++ b/src/printsupport/platform/windows/qwindowsprintdevice_p.h
@@ -1,10 +1,10 @@
/****************************************************************************
**
** Copyright (C) 2014 John Layt <jlayt@kde.org>
-** Copyright (C) 2018 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
-** This file is part of the plugins of the Qt Toolkit.
+** This file is part of the QtPrintSupport module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
@@ -45,8 +45,8 @@
// W A R N I N G
// -------------
//
-// This file is not part of the Qt API. It exists for the convenience
-// of internal files. This header file may change from version to version
+// This file is not part of the Qt API. It exists for the convenience
+// of internal files. This header file may change from version to version
// without notice, or even be removed.
//
// We mean it.
@@ -54,11 +54,12 @@
#include <qpa/qplatformprintdevice.h>
+#include <QtPrintSupport/qtprintsupportglobal.h>
#include <QtCore/qt_windows.h>
QT_BEGIN_NAMESPACE
-class QWindowsPrinterInfo
+class Q_PRINTSUPPORT_EXPORT QWindowsPrinterInfo
{
public:
bool operator==(const QWindowsPrinterInfo &other) const
@@ -95,7 +96,7 @@ public:
bool m_haveColorModes = false;
};
-class QWindowsPrintDevice : public QPlatformPrintDevice
+class Q_PRINTSUPPORT_EXPORT QWindowsPrintDevice : public QPlatformPrintDevice
{
public:
QWindowsPrintDevice();
diff --git a/src/plugins/printsupport/windows/qwindowsprinterinfo.cpp b/src/printsupport/platform/windows/qwindowsprinterinfo.cpp
index e416dd7a21..e416dd7a21 100644
--- a/src/plugins/printsupport/windows/qwindowsprinterinfo.cpp
+++ b/src/printsupport/platform/windows/qwindowsprinterinfo.cpp
diff --git a/src/plugins/printsupport/windows/qwindowsprintersupport.cpp b/src/printsupport/platform/windows/qwindowsprintersupport.cpp
index a52ad55576..6fd5aef47f 100644
--- a/src/plugins/printsupport/windows/qwindowsprintersupport.cpp
+++ b/src/printsupport/platform/windows/qwindowsprintersupport.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
-** This file is part of the plugins of the Qt Toolkit.
+** This file is part of the QtPrintSupport module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
@@ -37,13 +37,19 @@
**
****************************************************************************/
-#include "qwindowsprintersupport.h"
-#include "qwindowsprintdevice.h"
+#include "qwindowsprintersupport_p.h"
+
+#ifndef QT_NO_PRINTER
+
+#include "qwindowsprintdevice_p.h"
#include <QtCore/QStringList>
-#include <qprintengine_win_p.h>
+#include <private/qprintengine_win_p.h>
#include <private/qprintdevice_p.h>
+#define QT_STATICPLUGIN
+#include <qpa/qplatformprintplugin.h>
+
QT_BEGIN_NAMESPACE
QWindowsPrinterSupport::QWindowsPrinterSupport()
@@ -81,4 +87,26 @@ QString QWindowsPrinterSupport::defaultPrintDeviceId() const
return QWindowsPrintDevice::defaultPrintDeviceId();
}
+class QWindowsPrinterSupportPlugin : public QPlatformPrinterSupportPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID QPlatformPrinterSupportFactoryInterface_iid FILE "windows.json")
+
+public:
+ QPlatformPrinterSupport *create(const QString &);
+};
+
+QPlatformPrinterSupport *QWindowsPrinterSupportPlugin::create(const QString &key)
+{
+ if (key.compare(key, QLatin1String("windowsprintsupport"), Qt::CaseInsensitive) == 0)
+ return new QWindowsPrinterSupport;
+ return nullptr;
+}
+
+Q_IMPORT_PLUGIN(QWindowsPrinterSupportPlugin)
+
+#include "qwindowsprintersupport.moc"
+
QT_END_NAMESPACE
+
+#endif // QT_NO_PRINTER
diff --git a/src/plugins/printsupport/windows/qwindowsprintersupport.h b/src/printsupport/platform/windows/qwindowsprintersupport_p.h
index 400701628e..a43fdb8d0a 100644
--- a/src/plugins/printsupport/windows/qwindowsprintersupport.h
+++ b/src/printsupport/platform/windows/qwindowsprintersupport_p.h
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
-** This file is part of the plugins of the Qt Toolkit.
+** This file is part of the QtPrintSupport module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
@@ -40,11 +40,25 @@
#ifndef WINDOWSPRINTERSUPPORT_H
#define WINDOWSPRINTERSUPPORT_H
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of internal files. This header file may change from version to version
+// without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtPrintSupport/qtprintsupportglobal.h>
+
#include <qpa/qplatformprintersupport.h>
+#ifndef QT_NO_PRINTER
QT_BEGIN_NAMESPACE
-class QWindowsPrinterSupport : public QPlatformPrinterSupport
+class Q_PRINTSUPPORT_EXPORT QWindowsPrinterSupport : public QPlatformPrinterSupport
{
Q_DISABLE_COPY_MOVE(QWindowsPrinterSupport)
public:
@@ -61,4 +75,5 @@ public:
QT_END_NAMESPACE
+#endif // QT_NO_PRINTER
#endif // WINDOWSPRINTERSUPPORT_H
diff --git a/src/plugins/printsupport/windows/windows.json b/src/printsupport/platform/windows/windows.json
index 803052854e..803052854e 100644
--- a/src/plugins/printsupport/windows/windows.json
+++ b/src/printsupport/platform/windows/windows.json
diff --git a/src/printsupport/platform/windows/windows.pri b/src/printsupport/platform/windows/windows.pri
new file mode 100644
index 0000000000..89d765dc28
--- /dev/null
+++ b/src/printsupport/platform/windows/windows.pri
@@ -0,0 +1,16 @@
+SOURCES += \
+ $$PWD/qprintengine_win.cpp \
+ $$PWD/qwindowsprintdevice.cpp
+
+# Disable PCH to allow selectively enabling QT_STATICPLUGIN
+NO_PCH_SOURCES += $$PWD/qwindowsprintersupport.cpp
+
+HEADERS += \
+ $$PWD/qprintengine_win_p.h \
+ $$PWD/qwindowsprintersupport_p.h \
+ $$PWD/qwindowsprintdevice_p.h
+
+OTHER_FILES += $$PWD/windows.json
+
+LIBS += -lwinspool -lcomdlg32
+QMAKE_USE_PRIVATE += user32 gdi32
diff --git a/src/printsupport/printsupport.pro b/src/printsupport/printsupport.pro
index e64fbb634c..53bdccb3a3 100644
--- a/src/printsupport/printsupport.pro
+++ b/src/printsupport/printsupport.pro
@@ -12,6 +12,7 @@ include(widgets/widgets.pri)
include(dialogs/dialogs.pri)
macos: include(platform/macos/macos.pri)
+win32: include(platform/windows/windows.pri)
MODULE_PLUGIN_TYPES = \
printsupport