From 86fc4aa2b661101d392ff8ff832e3cb0e4ce8d91 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Mon, 5 Mar 2012 14:42:53 +0100 Subject: [PATCH] Add method to get NSPrintInfo* from QPrintEngine in Cocoa plugin MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Add an invokable method that takes the QPrintEngine (which will always be a QMacPrintEngine) and return the NSPrintInfo* from the QMacPrintEnginePrivate. This will be used by the native dialogs in QtPrintSupport to get/set printer settings. Change-Id: If1e49027e8f0d505656db51be1f40a23f60e8e57 Reviewed-by: Mark Brand Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoanativeinterface.h | 5 +++++ src/plugins/platforms/cocoa/qcocoanativeinterface.mm | 8 ++++++++ src/plugins/platforms/cocoa/qprintengine_mac_p.h | 3 +++ 3 files changed, 16 insertions(+) diff --git a/src/plugins/platforms/cocoa/qcocoanativeinterface.h b/src/plugins/platforms/cocoa/qcocoanativeinterface.h index 2665768..8856e90 100644 --- a/src/plugins/platforms/cocoa/qcocoanativeinterface.h +++ b/src/plugins/platforms/cocoa/qcocoanativeinterface.h @@ -66,6 +66,11 @@ private: plugin. */ Q_INVOKABLE QPlatformPrinterSupport *createPlatformPrinterSupport(); + /* + Function to return the NSPrintInfo * from QMacPaintEnginePrivate. + Needed by the native print dialog in the QtPrintSupport library. + */ + Q_INVOKABLE void *NSPrintInfoForPrintEngine(QPrintEngine *printEngine); }; #endif // QCOCOANATIVEINTERFACE_H diff --git a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm index 7767254..29c2e58 100644 --- a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm +++ b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm @@ -52,6 +52,8 @@ #include "qopenglcontext.h" #include +#include "qprintengine_mac_p.h" + void *QCocoaNativeInterface::nativeResourceForWindow(const QByteArray &resourceString, QWindow *window) { if (!window->handle()) { @@ -73,3 +75,9 @@ QPlatformPrinterSupport *QCocoaNativeInterface::createPlatformPrinterSupport() { return new QCocoaPrinterSupport(); } + +void *QCocoaNativeInterface::NSPrintInfoForPrintEngine(QPrintEngine *printEngine) +{ + QMacPrintEngine *macPrintEngine = static_cast(printEngine); + return macPrintEngine->d_func()->printInfo; +} diff --git a/src/plugins/platforms/cocoa/qprintengine_mac_p.h b/src/plugins/platforms/cocoa/qprintengine_mac_p.h index c690a57..2d37b43 100644 --- a/src/plugins/platforms/cocoa/qprintengine_mac_p.h +++ b/src/plugins/platforms/cocoa/qprintengine_mac_p.h @@ -108,6 +108,9 @@ public: virtual void drawTextItem(const QPointF &p, const QTextItem &ti); virtual void drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s); virtual void drawPath(const QPainterPath &); + +private: + friend class QCocoaNativeInterface; }; class QMacPrintEnginePrivate : public QPaintEnginePrivate -- 2.7.4