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>
This commit is contained in:
parent
ab428e3000
commit
fb18fe0316
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -1,5 +1,4 @@
|
||||
TEMPLATE = subdirs
|
||||
QT_FOR_CONFIG += printsupport-private
|
||||
|
||||
win32: SUBDIRS += windows
|
||||
unix:!darwin:qtConfig(cups): SUBDIRS += cups
|
||||
|
@ -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"
|
@ -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)
|
@ -57,22 +57,27 @@ qt_internal_extend_target(PrintSupport CONDITION MACOS
|
||||
"platform/macos/qcocoaprintersupport.mm"
|
||||
)
|
||||
|
||||
qt_internal_extend_target(PrintSupport CONDITION WIN32
|
||||
SOURCES
|
||||
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
|
||||
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 WIN32
|
||||
SOURCES
|
||||
kernel/qprintengine_win.cpp kernel/qprintengine_win_p.h
|
||||
LIBRARIES
|
||||
comdlg32
|
||||
gdi32
|
||||
user32
|
||||
winspool
|
||||
)
|
||||
|
||||
qt_internal_extend_target(PrintSupport CONDITION QT_FEATURE_cups AND UNIX AND NOT APPLE
|
||||
SOURCES
|
||||
kernel/qcups.cpp kernel/qcups_p.h
|
||||
|
@ -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>
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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
|
@ -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.
|
@ -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;
|
@ -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();
|
@ -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
|
@ -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
|
16
src/printsupport/platform/windows/windows.pri
Normal file
16
src/printsupport/platform/windows/windows.pri
Normal file
@ -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
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user