Move macOS print support from platform plugin into QtPrintSupport
Task-number: QTBUG-83256 Change-Id: I29044b6c3f952c259f501f94a175c8ef2cbaae55 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
parent
6a3c6f939f
commit
7f179eff61
@ -1,7 +1,6 @@
|
||||
# Generated from cocoa.pro.
|
||||
|
||||
# special case:
|
||||
qt_find_package(Cups PROVIDED_TARGETS Cups::Cups)
|
||||
|
||||
#####################################################################
|
||||
## QCocoaIntegrationPlugin Plugin:
|
||||
@ -55,7 +54,6 @@ qt_internal_add_plugin(QCocoaIntegrationPlugin
|
||||
${FWIOSurface}
|
||||
${FWMetal}
|
||||
${FWQuartzCore}
|
||||
Cups::Cups
|
||||
Qt::Core
|
||||
Qt::CorePrivate
|
||||
Qt::Gui
|
||||
@ -110,25 +108,9 @@ qt_extend_target(QCocoaIntegrationPlugin CONDITION QT_FEATURE_sessionmanager
|
||||
qcocoasessionmanager.cpp qcocoasessionmanager.h
|
||||
)
|
||||
|
||||
qt_extend_target(QCocoaIntegrationPlugin CONDITION TARGET Qt::Widgets
|
||||
SOURCES
|
||||
qpaintengine_mac.mm qpaintengine_mac_p.h
|
||||
PUBLIC_LIBRARIES
|
||||
Qt::WidgetsPrivate
|
||||
)
|
||||
|
||||
#### Keys ignored in scope 7:.:.:cocoa.pro:TARGET Qt::Widgets:
|
||||
# QT_FOR_CONFIG = "widgets"
|
||||
|
||||
qt_extend_target(QCocoaIntegrationPlugin CONDITION TARGET Qt::PrintSupport AND TARGET Qt::Widgets
|
||||
SOURCES
|
||||
qcocoaprintdevice.h qcocoaprintdevice.mm
|
||||
qcocoaprintersupport.h qcocoaprintersupport.mm
|
||||
qprintengine_mac.mm qprintengine_mac_p.h
|
||||
PUBLIC_LIBRARIES
|
||||
Qt::PrintSupportPrivate
|
||||
)
|
||||
|
||||
qt_extend_target(QCocoaIntegrationPlugin CONDITION QT_FEATURE_colordialog AND TARGET Qt::Widgets
|
||||
SOURCES
|
||||
qcocoacolordialoghelper.h qcocoacolordialoghelper.mm
|
||||
|
@ -89,7 +89,7 @@ qtConfig(sessionmanager) {
|
||||
|
||||
RESOURCES += qcocoaresources.qrc
|
||||
|
||||
LIBS += -framework AppKit -framework CoreServices -framework Carbon -framework IOKit -framework QuartzCore -framework CoreVideo -framework Metal -framework IOSurface -lcups
|
||||
LIBS += -framework AppKit -framework CoreServices -framework Carbon -framework IOKit -framework QuartzCore -framework CoreVideo -framework Metal -framework IOSurface
|
||||
|
||||
DEFINES += QT_NO_FOREACH
|
||||
|
||||
@ -100,21 +100,6 @@ CONFIG += no_app_extension_api_only
|
||||
qtHaveModule(widgets) {
|
||||
QT_FOR_CONFIG += widgets
|
||||
|
||||
SOURCES += qpaintengine_mac.mm
|
||||
HEADERS += qpaintengine_mac_p.h
|
||||
|
||||
qtHaveModule(printsupport) {
|
||||
QT += printsupport-private
|
||||
SOURCES += \
|
||||
qprintengine_mac.mm \
|
||||
qcocoaprintersupport.mm \
|
||||
qcocoaprintdevice.mm
|
||||
HEADERS += \
|
||||
qcocoaprintersupport.h \
|
||||
qcocoaprintdevice.h \
|
||||
qprintengine_mac_p.h
|
||||
}
|
||||
|
||||
qtConfig(colordialog) {
|
||||
SOURCES += qcocoacolordialoghelper.mm
|
||||
HEADERS += qcocoacolordialoghelper.h
|
||||
|
@ -45,13 +45,10 @@
|
||||
#include <qpa/qplatformnativeinterface.h>
|
||||
#include <QtGui/qpixmap.h>
|
||||
Q_MOC_INCLUDE(<QWindow>)
|
||||
Q_MOC_INCLUDE(<qpa/qplatformprintersupport.h>)
|
||||
Q_MOC_INCLUDE(<QPrintEngine>)
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QWidget;
|
||||
class QPlatformPrinterSupport;
|
||||
class QPrintEngine;
|
||||
class QPlatformMenu;
|
||||
class QPlatformMenuBar;
|
||||
@ -80,23 +77,6 @@ public Q_SLOTS:
|
||||
void onAppFocusWindowChanged(QWindow *window);
|
||||
|
||||
private:
|
||||
/*
|
||||
"Virtual" function to create the platform printer support
|
||||
implementation.
|
||||
|
||||
We use an invokable function instead of a virtual one, we do not want
|
||||
this in the QPlatform* API yet.
|
||||
|
||||
This was added here only because QPlatformNativeInterface is a QObject
|
||||
and allow us to use QMetaObject::indexOfMethod() from the printsupport
|
||||
plugin.
|
||||
*/
|
||||
Q_INVOKABLE QPlatformPrinterSupport *createPlatformPrinterSupport();
|
||||
/*
|
||||
Function to return the NSPrintInfo * from QMacPaintEnginePrivate.
|
||||
Needed by the native print dialog in the Qt Print Support module.
|
||||
*/
|
||||
Q_INVOKABLE void *NSPrintInfoForPrintEngine(QPrintEngine *printEngine);
|
||||
/*
|
||||
Function to return the default background pixmap.
|
||||
Needed by QWizard in the Qt widget module.
|
||||
|
@ -59,12 +59,6 @@
|
||||
#include <QtGui/qguiapplication.h>
|
||||
#include <qdebug.h>
|
||||
|
||||
#if !defined(QT_NO_WIDGETS) && defined(QT_PRINTSUPPORT_LIB)
|
||||
#include "qcocoaprintersupport.h"
|
||||
#include "qprintengine_mac_p.h"
|
||||
#include <qpa/qplatformprintersupport.h>
|
||||
#endif
|
||||
|
||||
#include <QtGui/private/qcoregraphics_p.h>
|
||||
|
||||
#include <QtPlatformHeaders/qcocoawindowfunctions.h>
|
||||
@ -147,30 +141,6 @@ QPlatformNativeInterface::NativeResourceForIntegrationFunction QCocoaNativeInter
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QPlatformPrinterSupport *QCocoaNativeInterface::createPlatformPrinterSupport()
|
||||
{
|
||||
#if !defined(QT_NO_WIDGETS) && !defined(QT_NO_PRINTER) && defined(QT_PRINTSUPPORT_LIB)
|
||||
return new QCocoaPrinterSupport();
|
||||
#else
|
||||
qFatal("Printing is not supported when Qt is configured with -no-widgets or -no-feature-printer");
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
void *QCocoaNativeInterface::NSPrintInfoForPrintEngine(QPrintEngine *printEngine)
|
||||
{
|
||||
#if !defined(QT_NO_WIDGETS) && !defined(QT_NO_PRINTER) && defined(QT_PRINTSUPPORT_LIB)
|
||||
QMacPrintEnginePrivate *macPrintEnginePriv = static_cast<QMacPrintEngine *>(printEngine)->d_func();
|
||||
if (macPrintEnginePriv->state == QPrinter::Idle && !macPrintEnginePriv->isPrintSessionInitialized())
|
||||
macPrintEnginePriv->initialize();
|
||||
return macPrintEnginePriv->printInfo;
|
||||
#else
|
||||
Q_UNUSED(printEngine);
|
||||
qFatal("Printing is not supported when Qt is configured with -no-widgets or -no-feature-printer");
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
QPixmap QCocoaNativeInterface::defaultBackgroundPixmapForQWizard()
|
||||
{
|
||||
// Note: starting with macOS 10.14, the KeyboardSetupAssistant app bundle no
|
||||
|
@ -42,6 +42,8 @@
|
||||
#include <qpa/qplatformnativeinterface.h>
|
||||
#include <qpa/qplatformprintplugin.h>
|
||||
|
||||
#include <QtPrintSupport/private/qcocoaprintersupport_p.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QCocoaPrinterSupportPlugin : public QPlatformPrinterSupportPlugin
|
||||
@ -57,18 +59,8 @@ QPlatformPrinterSupport *QCocoaPrinterSupportPlugin::create(const QString &key)
|
||||
{
|
||||
if (key.compare(key, QLatin1String("cocoaprintersupport"), Qt::CaseInsensitive) != 0)
|
||||
return 0;
|
||||
QGuiApplication *app = qobject_cast<QGuiApplication *>(QCoreApplication::instance());
|
||||
if (!app)
|
||||
return 0;
|
||||
QPlatformNativeInterface *platformNativeInterface = app->platformNativeInterface();
|
||||
int at = platformNativeInterface->metaObject()->indexOfMethod("createPlatformPrinterSupport()");
|
||||
if (at == -1)
|
||||
return 0;
|
||||
QMetaMethod createPlatformPrinterSupport = platformNativeInterface->metaObject()->method(at);
|
||||
QPlatformPrinterSupport *platformPrinterSupport = 0;
|
||||
if (!createPlatformPrinterSupport.invoke(platformNativeInterface, Q_RETURN_ARG(QPlatformPrinterSupport *, platformPrinterSupport)))
|
||||
return 0;
|
||||
return platformPrinterSupport;
|
||||
|
||||
return new QCocoaPrinterSupport();
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
@ -143,6 +143,17 @@ if(QT_FEATURE_printdialog)
|
||||
)
|
||||
endif()
|
||||
|
||||
qt_extend_target(PrintSupport CONDITION MACOS AND TARGET Qt::Widgets
|
||||
SOURCES
|
||||
platform/macos/qpaintengine_mac.mm platform/macos/qpaintengine_mac_p.h
|
||||
platform/macos/qcocoaprintdevice_p.h platform/macos/qcocoaprintdevice.mm
|
||||
platform/macos/qcocoaprintersupport_p.h platform/macos/qcocoaprintersupport.mm
|
||||
platform/macos/qprintengine_mac.mm platform/macos/qprintengine_mac_p.h
|
||||
PUBLIC_LIBRARIES
|
||||
Qt::WidgetsPrivate
|
||||
Cups::Cups
|
||||
)
|
||||
|
||||
qt_extend_target(PrintSupport CONDITION MACOS AND QT_FEATURE_printdialog
|
||||
SOURCES
|
||||
dialogs/qpagesetupdialog_mac.mm
|
||||
|
@ -47,6 +47,8 @@
|
||||
#include <qpa/qplatformnativeinterface.h>
|
||||
#include <QtPrintSupport/qprintengine.h>
|
||||
|
||||
#include <QtPrintSupport/private/qprintengine_mac_p.h>
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
@class QT_MANGLE_NAMESPACE(QCocoaPageLayoutDelegate);
|
||||
@ -114,13 +116,7 @@ void QMacPageSetupDialogPrivate::openCocoaPageLayout(Qt::WindowModality modality
|
||||
{
|
||||
Q_Q(QPageSetupDialog);
|
||||
|
||||
// get the NSPrintInfo from the print engine in the platform plugin
|
||||
void *voidp = 0;
|
||||
(void) QMetaObject::invokeMethod(qApp->platformNativeInterface(),
|
||||
"NSPrintInfoForPrintEngine",
|
||||
Q_RETURN_ARG(void *, voidp),
|
||||
Q_ARG(QPrintEngine *, printer->printEngine()));
|
||||
printInfo = static_cast<NSPrintInfo *>(voidp);
|
||||
printInfo = static_cast<QMacPrintEngine *>(printer->printEngine())->printInfo();
|
||||
[printInfo retain];
|
||||
|
||||
pageLayout = [NSPageLayout pageLayout];
|
||||
|
@ -49,6 +49,8 @@
|
||||
#include <QtPrintSupport/qprintengine.h>
|
||||
#include <qpa/qplatformprintdevice.h>
|
||||
|
||||
#include <QtPrintSupport/private/qprintengine_mac_p.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
extern qreal qt_pointMultiplier(QPageLayout::Unit unit);
|
||||
@ -216,13 +218,7 @@ void QPrintDialogPrivate::openCocoaPrintPanel(Qt::WindowModality modality)
|
||||
Q_Q(QPrintDialog);
|
||||
|
||||
if (printer->outputFormat() == QPrinter::NativeFormat) {
|
||||
// get the NSPrintInfo from the print engine in the platform plugin
|
||||
void *voidp = 0;
|
||||
(void) QMetaObject::invokeMethod(qApp->platformNativeInterface(),
|
||||
"NSPrintInfoForPrintEngine",
|
||||
Q_RETURN_ARG(void *, voidp),
|
||||
Q_ARG(QPrintEngine *, printer->printEngine()));
|
||||
printInfo = static_cast<NSPrintInfo *>(voidp);
|
||||
printInfo = static_cast<QMacPrintEngine *>(printer->printEngine())->printInfo();
|
||||
[printInfo retain];
|
||||
} else {
|
||||
printInfo = [NSPrintInfo.sharedPrintInfo retain];
|
||||
|
13
src/printsupport/platform/macos/macos.pri
Normal file
13
src/printsupport/platform/macos/macos.pri
Normal file
@ -0,0 +1,13 @@
|
||||
SOURCES += \
|
||||
$$PWD/qprintengine_mac.mm \
|
||||
$$PWD/qpaintengine_mac.mm \
|
||||
$$PWD/qcocoaprintersupport.mm \
|
||||
$$PWD/qcocoaprintdevice.mm
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/qcocoaprintersupport_p.h \
|
||||
$$PWD/qcocoaprintdevice_p.h \
|
||||
$$PWD/qprintengine_mac_p.h \
|
||||
$$PWD/qpaintengine_mac_p.h
|
||||
|
||||
LIBS += -framework ApplicationServices -lcups
|
@ -39,7 +39,7 @@
|
||||
|
||||
#include <ApplicationServices/ApplicationServices.h>
|
||||
|
||||
#include "qcocoaprintdevice.h"
|
||||
#include "qcocoaprintdevice_p.h"
|
||||
|
||||
#if QT_CONFIG(mimetype)
|
||||
#include <QtCore/qmimedatabase.h>
|
@ -55,6 +55,10 @@
|
||||
|
||||
#ifndef QT_NO_PRINTER
|
||||
|
||||
#include <ApplicationServices/ApplicationServices.h>
|
||||
|
||||
#include <QtPrintSupport/qtprintsupportglobal.h>
|
||||
|
||||
#include <cups/ppd.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
@ -37,7 +37,9 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qcocoaprintersupport.h"
|
||||
#include <AppKit/AppKit.h>
|
||||
|
||||
#include "qcocoaprintersupport_p.h"
|
||||
|
||||
#ifndef QT_NO_PRINTER
|
||||
|
||||
@ -45,7 +47,7 @@
|
||||
|
||||
#include <QtCore/private/qcore_mac_p.h>
|
||||
|
||||
#include "qcocoaprintdevice.h"
|
||||
#include "qcocoaprintdevice_p.h"
|
||||
#include "qprintengine_mac_p.h"
|
||||
|
||||
#include <private/qprinterinfo_p.h>
|
@ -40,12 +40,25 @@
|
||||
#ifndef QCOCOAPRINTERSUPPORT_H
|
||||
#define QCOCOAPRINTERSUPPORT_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 <qpa/qplatformprintersupport.h>
|
||||
#ifndef QT_NO_PRINTER
|
||||
|
||||
#include <QtPrintSupport/qtprintsupportglobal.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QCocoaPrinterSupport : public QPlatformPrinterSupport
|
||||
class Q_PRINTSUPPORT_EXPORT QCocoaPrinterSupport : public QPlatformPrinterSupport
|
||||
{
|
||||
public:
|
||||
QCocoaPrinterSupport();
|
@ -41,18 +41,14 @@
|
||||
#include <CoreGraphics/CoreGraphics.h>
|
||||
|
||||
#include "qpaintengine_mac_p.h"
|
||||
#if defined(QT_PRINTSUPPORT_LIB)
|
||||
#include "qprintengine_mac_p.h"
|
||||
#endif
|
||||
|
||||
#include <qbitmap.h>
|
||||
#include <qpaintdevice.h>
|
||||
#include <qpainterpath.h>
|
||||
#include <qpixmapcache.h>
|
||||
#include <private/qpaintengine_raster_p.h>
|
||||
#if defined(QT_PRINTSUPPORT_LIB)
|
||||
#include <qprinter.h>
|
||||
#endif
|
||||
#include <qstack.h>
|
||||
#include <qwidget.h>
|
||||
#include <qvarlengtharray.h>
|
||||
@ -71,8 +67,6 @@
|
||||
#include <private/qtextengine_p.h>
|
||||
#include <private/qcoregraphics_p.h>
|
||||
|
||||
#include "qcocoahelpers.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
@ -51,6 +51,8 @@
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include <QtPrintSupport/qtprintsupportglobal.h>
|
||||
|
||||
#include <QtGui/qpaintengine.h>
|
||||
#include <QtGui/private/qpaintengine_p.h>
|
||||
#include <QtGui/private/qpolygonclipper_p.h>
|
@ -41,7 +41,7 @@
|
||||
#include <ApplicationServices/ApplicationServices.h>
|
||||
|
||||
#include "qprintengine_mac_p.h"
|
||||
#include "qcocoaprintersupport.h"
|
||||
#include "qcocoaprintersupport_p.h"
|
||||
#include <quuid.h>
|
||||
#include <QtGui/qpagelayout.h>
|
||||
#include <QtCore/qcoreapplication.h>
|
||||
@ -792,6 +792,14 @@ QVariant QMacPrintEngine::property(PrintEnginePropertyKey key) const
|
||||
return ret;
|
||||
}
|
||||
|
||||
NSPrintInfo *QMacPrintEngine::printInfo()
|
||||
{
|
||||
Q_D(QMacPrintEngine);
|
||||
if (d->state == QPrinter::Idle && !d->isPrintSessionInitialized())
|
||||
d->initialize();
|
||||
return d->printInfo;
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT_NO_PRINTER
|
@ -51,7 +51,7 @@
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
#include <QtPrintSupport/qtprintsupportglobal.h>
|
||||
|
||||
#ifndef QT_NO_PRINTER
|
||||
|
||||
@ -60,7 +60,7 @@
|
||||
#include <QtGui/private/qpainter_p.h>
|
||||
#include <QtGui/qpagelayout.h>
|
||||
|
||||
#include "qcocoaprintdevice.h"
|
||||
#include "qcocoaprintdevice_p.h"
|
||||
|
||||
#include "qpaintengine_mac_p.h"
|
||||
|
||||
@ -93,6 +93,8 @@ public:
|
||||
bool abort();
|
||||
int metric(QPaintDevice::PaintDeviceMetric) const;
|
||||
|
||||
NSPrintInfo *printInfo();
|
||||
|
||||
//forwarded functions
|
||||
|
||||
void updateState(const QPaintEngineState &state);
|
@ -11,6 +11,8 @@ include(kernel/kernel.pri)
|
||||
include(widgets/widgets.pri)
|
||||
include(dialogs/dialogs.pri)
|
||||
|
||||
macos: include(platform/macos/macos.pri)
|
||||
|
||||
MODULE_PLUGIN_TYPES = \
|
||||
printsupport
|
||||
load(qt_module)
|
||||
|
Loading…
Reference in New Issue
Block a user