macOS: Remove QtWidget dependency from platform plugin

The dialog helpers don't depend on widgets themselves, and should be
built regardless of whether the widget dialogs are enabled, as these
helpers can (and should) be used by other layers, such as Qt Quick.

Change-Id: I1c66b474ab2f29748f1256aea90229c51c12a16f
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
Tor Arne Vestbø 2020-03-31 19:23:18 +02:00
parent 9dd8e655cd
commit 1cee9cc587
8 changed files with 11 additions and 79 deletions

View File

@ -43,6 +43,9 @@ qt_internal_add_plugin(QCocoaIntegrationPlugin
qnsview.h qnsview.mm qnsview.h qnsview.mm
qnswindow.h qnswindow.mm qnswindow.h qnswindow.mm
qnswindowdelegate.h qnswindowdelegate.mm qnswindowdelegate.h qnswindowdelegate.mm
qcocoacolordialoghelper.h qcocoacolordialoghelper.mm
qcocoafiledialoghelper.h qcocoafiledialoghelper.mm
qcocoafontdialoghelper.h qcocoafontdialoghelper.mm
DEFINES DEFINES
QT_NO_FOREACH QT_NO_FOREACH
PUBLIC_LIBRARIES PUBLIC_LIBRARIES
@ -110,21 +113,5 @@ qt_extend_target(QCocoaIntegrationPlugin CONDITION QT_FEATURE_sessionmanager
#### Keys ignored in scope 7:.:.:cocoa.pro:TARGET Qt::Widgets: #### Keys ignored in scope 7:.:.:cocoa.pro:TARGET Qt::Widgets:
# QT_FOR_CONFIG = "widgets" # QT_FOR_CONFIG = "widgets"
qt_extend_target(QCocoaIntegrationPlugin CONDITION QT_FEATURE_colordialog AND TARGET Qt::Widgets
SOURCES
qcocoacolordialoghelper.h qcocoacolordialoghelper.mm
)
qt_extend_target(QCocoaIntegrationPlugin CONDITION QT_FEATURE_filedialog AND TARGET Qt::Widgets
SOURCES
qcocoafiledialoghelper.h qcocoafiledialoghelper.mm
)
qt_extend_target(QCocoaIntegrationPlugin CONDITION QT_FEATURE_fontdialog AND TARGET Qt::Widgets
SOURCES
qcocoafontdialoghelper.h qcocoafontdialoghelper.mm
)
#### Keys ignored in scope 12:.:.:cocoa.pro:NOT TARGET___equals____ss_QT_DEFAULT_QPA_PLUGIN: #### Keys ignored in scope 12:.:.:cocoa.pro:NOT TARGET___equals____ss_QT_DEFAULT_QPA_PLUGIN:
# PLUGIN_EXTENDS = "-" # PLUGIN_EXTENDS = "-"

View File

@ -31,7 +31,10 @@ SOURCES += main.mm \
qcocoaintrospection.mm \ qcocoaintrospection.mm \
qcocoakeymapper.mm \ qcocoakeymapper.mm \
qcocoamimetypes.mm \ qcocoamimetypes.mm \
qiosurfacegraphicsbuffer.mm qiosurfacegraphicsbuffer.mm \
qcocoacolordialoghelper.mm \
qcocoafiledialoghelper.mm \
qcocoafontdialoghelper.mm
HEADERS += qcocoaintegration.h \ HEADERS += qcocoaintegration.h \
qcocoascreen.h \ qcocoascreen.h \
@ -63,7 +66,10 @@ HEADERS += qcocoaintegration.h \
qcocoaintrospection.h \ qcocoaintrospection.h \
qcocoakeymapper.h \ qcocoakeymapper.h \
qiosurfacegraphicsbuffer.h \ qiosurfacegraphicsbuffer.h \
qcocoamimetypes.h qcocoamimetypes.h \
qcocoacolordialoghelper.h \
qcocoafiledialoghelper.h \
qcocoafontdialoghelper.h
qtConfig(opengl.*) { qtConfig(opengl.*) {
SOURCES += qcocoaglcontext.mm SOURCES += qcocoaglcontext.mm
@ -97,27 +103,6 @@ QT += core-private gui-private
CONFIG += no_app_extension_api_only CONFIG += no_app_extension_api_only
qtHaveModule(widgets) {
QT_FOR_CONFIG += widgets
qtConfig(colordialog) {
SOURCES += qcocoacolordialoghelper.mm
HEADERS += qcocoacolordialoghelper.h
}
qtConfig(filedialog) {
SOURCES += qcocoafiledialoghelper.mm
HEADERS += qcocoafiledialoghelper.h
}
qtConfig(fontdialog) {
SOURCES += qcocoafontdialoghelper.mm
HEADERS += qcocoafontdialoghelper.h
}
QT += widgets-private
}
OTHER_FILES += cocoa.json OTHER_FILES += cocoa.json
PLUGIN_TYPE = platforms PLUGIN_TYPE = platforms

View File

@ -40,13 +40,9 @@
#ifndef QCOCOACOLORDIALOGHELPER_H #ifndef QCOCOACOLORDIALOGHELPER_H
#define QCOCOACOLORDIALOGHELPER_H #define QCOCOACOLORDIALOGHELPER_H
#include <QtWidgets/qtwidgetsglobal.h>
#include <QObject> #include <QObject>
#include <qpa/qplatformdialoghelper.h> #include <qpa/qplatformdialoghelper.h>
QT_REQUIRE_CONFIG(colordialog);
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QCocoaColorDialogHelper : public QPlatformColorDialogHelper class QCocoaColorDialogHelper : public QPlatformColorDialogHelper

View File

@ -41,14 +41,11 @@
#define QCOCOAFILEDIALOGHELPER_H #define QCOCOAFILEDIALOGHELPER_H
#include <QObject> #include <QObject>
#include <QtWidgets/qtwidgetsglobal.h>
#include <qpa/qplatformdialoghelper.h> #include <qpa/qplatformdialoghelper.h>
#include <QtCore/private/qcore_mac_p.h> #include <QtCore/private/qcore_mac_p.h>
#import <AppKit/NSSavePanel.h> #import <AppKit/NSSavePanel.h>
QT_REQUIRE_CONFIG(filedialog);
@interface QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) : NSObject<NSOpenSavePanelDelegate> @interface QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) : NSObject<NSOpenSavePanelDelegate>
@end @end

View File

@ -41,11 +41,8 @@
#define QCOCOAFONTDIALOGHELPER_H #define QCOCOAFONTDIALOGHELPER_H
#include <QObject> #include <QObject>
#include <QtWidgets/qtwidgetsglobal.h>
#include <qpa/qplatformdialoghelper.h> #include <qpa/qplatformdialoghelper.h>
QT_REQUIRE_CONFIG(fontdialog);
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QCocoaFontDialogHelper : public QPlatformFontDialogHelper class QCocoaFontDialogHelper : public QPlatformFontDialogHelper

View File

@ -49,10 +49,6 @@
#include <private/qwindow_p.h> #include <private/qwindow_p.h>
#include <QtGui/private/qcoregraphics_p.h> #include <QtGui/private/qcoregraphics_p.h>
#ifndef QT_NO_WIDGETS
#include <QtWidgets/QWidget>
#endif
#include <algorithm> #include <algorithm>
#include <mach-o/dyld.h> #include <mach-o/dyld.h>

View File

@ -68,13 +68,6 @@
#include <QtGui/private/qfontengine_coretext_p.h> #include <QtGui/private/qfontengine_coretext_p.h>
#ifdef QT_WIDGETS_LIB
#include <QtWidgets/qtwidgetsglobal.h>
#if QT_CONFIG(filedialog)
#include "qcocoafiledialoghelper.h"
#endif
#endif
#include <IOKit/graphics/IOGraphicsLib.h> #include <IOKit/graphics/IOGraphicsLib.h>
static void initResources() static void initResources()

View File

@ -63,18 +63,9 @@
#include <qpa/qplatformintegration.h> #include <qpa/qplatformintegration.h>
#include <qpa/qplatformnativeinterface.h> #include <qpa/qplatformnativeinterface.h>
#ifdef QT_WIDGETS_LIB
#include <QtWidgets/qtwidgetsglobal.h>
#if QT_CONFIG(colordialog)
#include "qcocoacolordialoghelper.h" #include "qcocoacolordialoghelper.h"
#endif
#if QT_CONFIG(filedialog)
#include "qcocoafiledialoghelper.h" #include "qcocoafiledialoghelper.h"
#endif
#if QT_CONFIG(fontdialog)
#include "qcocoafontdialoghelper.h" #include "qcocoafontdialoghelper.h"
#endif
#endif
#include <CoreServices/CoreServices.h> #include <CoreServices/CoreServices.h>
@ -329,32 +320,22 @@ bool QCocoaTheme::usePlatformNativeDialog(DialogType dialogType) const
{ {
if (dialogType == QPlatformTheme::FileDialog) if (dialogType == QPlatformTheme::FileDialog)
return true; return true;
#if defined(QT_WIDGETS_LIB) && QT_CONFIG(colordialog)
if (dialogType == QPlatformTheme::ColorDialog) if (dialogType == QPlatformTheme::ColorDialog)
return true; return true;
#endif
#if defined(QT_WIDGETS_LIB) && QT_CONFIG(fontdialog)
if (dialogType == QPlatformTheme::FontDialog) if (dialogType == QPlatformTheme::FontDialog)
return true; return true;
#endif
return false; return false;
} }
QPlatformDialogHelper *QCocoaTheme::createPlatformDialogHelper(DialogType dialogType) const QPlatformDialogHelper *QCocoaTheme::createPlatformDialogHelper(DialogType dialogType) const
{ {
switch (dialogType) { switch (dialogType) {
#if defined(QT_WIDGETS_LIB) && QT_CONFIG(filedialog)
case QPlatformTheme::FileDialog: case QPlatformTheme::FileDialog:
return new QCocoaFileDialogHelper(); return new QCocoaFileDialogHelper();
#endif
#if defined(QT_WIDGETS_LIB) && QT_CONFIG(colordialog)
case QPlatformTheme::ColorDialog: case QPlatformTheme::ColorDialog:
return new QCocoaColorDialogHelper(); return new QCocoaColorDialogHelper();
#endif
#if defined(QT_WIDGETS_LIB) && QT_CONFIG(fontdialog)
case QPlatformTheme::FontDialog: case QPlatformTheme::FontDialog:
return new QCocoaFontDialogHelper(); return new QCocoaFontDialogHelper();
#endif
default: default:
return nullptr; return nullptr;
} }