Add method to get NSPrintInfo* from QPrintEngine in Cocoa plugin
authorBradley T. Hughes <bradley.hughes@nokia.com>
Mon, 5 Mar 2012 13:42:53 +0000 (14:42 +0100)
committerQt by Nokia <qt-info@nokia.com>
Thu, 15 Mar 2012 08:50:18 +0000 (09:50 +0100)
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 <mabrand@mabrand.nl>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
src/plugins/platforms/cocoa/qcocoanativeinterface.h
src/plugins/platforms/cocoa/qcocoanativeinterface.mm
src/plugins/platforms/cocoa/qprintengine_mac_p.h

index 2665768..8856e90 100644 (file)
@@ -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
index 7767254..29c2e58 100644 (file)
@@ -52,6 +52,8 @@
 #include "qopenglcontext.h"
 #include <qdebug.h>
 
+#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<QMacPrintEngine *>(printEngine);
+    return macPrintEngine->d_func()->printInfo;
+}
index c690a57..2d37b43 100644 (file)
@@ -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