Cocoa: Compile when configured with -no-widgets
authorMorten Johan Sorvig <morten.sorvig@nokia.com>
Fri, 8 Jun 2012 11:12:59 +0000 (13:12 +0200)
committerQt by Nokia <qt-info@nokia.com>
Tue, 12 Jun 2012 02:29:53 +0000 (04:29 +0200)
Build printing only if Qt is configured with
widget support.

This is mostly useful for testing -no-widgets builds.

Change-Id: I2d47b420e311869e85508db1f7372fe326617dec
Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
src/plugins/platforms/cocoa/cocoa.pro
src/plugins/platforms/cocoa/qcocoanativeinterface.h
src/plugins/platforms/cocoa/qcocoanativeinterface.mm

index 3d15c75..bfe7570 100644 (file)
@@ -34,9 +34,6 @@ OBJECTIVE_SOURCES += main.mm \
     qmacmime.mm \
     qcocoasystemsettings.mm \
     qcocoainputcontext.mm \
-    qpaintengine_mac.mm \
-    qprintengine_mac.mm \
-    qcocoaprintersupport.mm \
     qcocoaservices.mm \
 
 HEADERS += qcocoaintegration.h \
@@ -69,16 +66,27 @@ HEADERS += qcocoaintegration.h \
     qmacmime.h \
     qcocoasystemsettings.h \
     qcocoainputcontext.h \
-    qpaintengine_mac_p.h \
-    qprintengine_mac_p.h \
-    qcocoaprintersupport.h \
     qcocoaservices.h \
 
 RESOURCES += qcocoaresources.qrc
 
 LIBS += -framework Cocoa -framework IOKit
 
-QT += core-private gui-private widgets-private platformsupport-private printsupport-private
+QT += core-private gui-private platformsupport-private
+
+!contains(QT_CONFIG, no-widgets) {
+    OBJECTIVE_SOURCES += \
+        qpaintengine_mac.mm \
+        qprintengine_mac.mm \
+        qcocoaprintersupport.mm \
+
+    HEADERS += \
+        qpaintengine_mac_p.h \
+        qprintengine_mac_p.h \
+        qcocoaprintersupport.h \
+
+    QT += widgets-private printsupport-private
+}
 
 OTHER_FILES += cocoa.json
 target.path += $$[QT_INSTALL_PLUGINS]/platforms
index fd0b103..beb54e4 100644 (file)
 #define QCOCOANATIVEINTERFACE_H
 
 #include <qpa/qplatformnativeinterface.h>
-#include <qpa/qplatformprintersupport.h>
 
 QT_BEGIN_NAMESPACE
 
 class QWidget;
+class QPlatformPrinterSupport;
+class QPrintEngine;
 
 class QCocoaNativeInterface : public QPlatformNativeInterface
 {
index 91461f2..dc2cab5 100644 (file)
@@ -42,7 +42,6 @@
 #include "qcocoanativeinterface.h"
 #include "qcocoaglcontext.h"
 #include "qcocoawindow.h"
-#include "qcocoaprintersupport.h"
 #include "qcocoamenubar.h"
 
 #include <qbytearray.h>
 #include "qguiapplication.h"
 #include <qdebug.h>
 
+#ifndef QT_NO_WIDGETS
+#include "qcocoaprintersupport.h"
 #include "qprintengine_mac_p.h"
+#include <qpa/qplatformprintersupport.h>
+#endif
 
 QT_BEGIN_NAMESPACE
 
@@ -81,13 +84,23 @@ void *QCocoaNativeInterface::nativeResourceForWindow(const QByteArray &resourceS
 
 QPlatformPrinterSupport *QCocoaNativeInterface::createPlatformPrinterSupport()
 {
+#ifndef QT_NO_WIDGETS
     return new QCocoaPrinterSupport();
+#else
+    qFatal("Printing is not supported when Qt is configured with -no-widgets");
+    return 0;
+#endif
 }
 
 void *QCocoaNativeInterface::NSPrintInfoForPrintEngine(QPrintEngine *printEngine)
 {
+#ifndef QT_NO_WIDGETS
     QMacPrintEngine *macPrintEngine = static_cast<QMacPrintEngine *>(printEngine);
     return macPrintEngine->d_func()->printInfo;
+#else
+    qFatal("Printing is not supported when Qt is configured with -no-widgets");
+    return 0;
+#endif
 }
 
 void QCocoaNativeInterface::onAppFocusWindowChanged(QWindow *window)