diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 1dd7bb3c30..85c14f39ab 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -389,6 +389,7 @@ qt_internal_extend_target(Gui CONDITION APPLE painting/qcoregraphics.mm painting/qcoregraphics_p.h painting/qrasterbackingstore.cpp painting/qrasterbackingstore_p.h painting/qrhibackingstore.cpp painting/qrhibackingstore_p.h + platform/darwin/qmacmimeregistry.mm platform/darwin/qmacmimeregistry_p.h platform/darwin/qmacmime.mm platform/darwin/qmacmime_p.h platform/darwin/qapplekeymapper.mm platform/darwin/qapplekeymapper_p.h text/coretext/qcoretextfontdatabase.mm text/coretext/qcoretextfontdatabase_p.h diff --git a/src/gui/platform/darwin/qmacmime.mm b/src/gui/platform/darwin/qmacmime.mm index 6cb60bec53..f5b571af1d 100644 --- a/src/gui/platform/darwin/qmacmime.mm +++ b/src/gui/platform/darwin/qmacmime.mm @@ -20,6 +20,7 @@ #endif #include "qmacmime_p.h" +#include "qmacmimeregistry_p.h" #include "qguiapplication.h" #include "private/qcore_mac_p.h" @@ -27,47 +28,6 @@ QT_BEGIN_NAMESPACE using namespace Qt::StringLiterals; -typedef QList MimeList; -Q_GLOBAL_STATIC(MimeList, globalMimeList) -Q_GLOBAL_STATIC(QStringList, globalDraggedTypesList) - -void qt_mac_addToGlobalMimeList(QMacInternalPasteboardMime *macMime) -{ - // globalMimeList is in decreasing priority order. Recently added - // converters take prioity over previously added converters: prepend - // to the list. - globalMimeList()->prepend(macMime); -} - -void qt_mac_removeFromGlobalMimeList(QMacInternalPasteboardMime *macMime) -{ - if (!QGuiApplication::closingDown()) - globalMimeList()->removeAll(macMime); -} - -/*! - \fn void qRegisterDraggedTypes(const QStringList &types) - \relates QMacPasteboardMime - - Registers the given \a types as custom pasteboard types. - - This function should be called to enable the Drag and Drop events - for custom pasteboard types on Cocoa implementations. This is required - in addition to a QMacPasteboardMime subclass implementation. By default - drag and drop is enabled for all standard pasteboard types. - - \sa QMacPasteboardMime -*/ -void qt_mac_registerDraggedTypes(const QStringList &types) -{ - (*globalDraggedTypesList()) += types; -} - -const QStringList& qt_mac_enabledDraggedTypes() -{ - return (*globalDraggedTypesList()); -} - /***************************************************************************** QDnD debug facilities *****************************************************************************/ @@ -127,9 +87,10 @@ const QStringList& qt_mac_enabledDraggedTypes() Constructs a new conversion object of type \a t, adding it to the globally accessed list of available converters. */ -QMacInternalPasteboardMime::QMacInternalPasteboardMime(char t) : type(t) +QMacInternalPasteboardMime::QMacInternalPasteboardMime(QMacPasteboardMimeType t) + : m_type(t) { - qt_mac_addToGlobalMimeList(this); + QMacMimeRegistry::registerMimeConverter(this); } /* @@ -138,7 +99,7 @@ QMacInternalPasteboardMime::QMacInternalPasteboardMime(char t) : type(t) */ QMacInternalPasteboardMime::~QMacInternalPasteboardMime() { - qt_mac_removeFromGlobalMimeList(this); + QMacMimeRegistry::unregisterMimeConverter(this); } /* @@ -151,13 +112,9 @@ int QMacInternalPasteboardMime::count(QMimeData *mimeData) } class QMacPasteboardMimeAny : public QMacInternalPasteboardMime { -private: - public: - QMacPasteboardMimeAny() : QMacInternalPasteboardMime(MIME_QT_CONVERTOR|MIME_ALL) { - } - ~QMacPasteboardMimeAny() { - } + QMacPasteboardMimeAny() : QMacInternalPasteboardMime(MIME_ALL_COMPATIBLE) {} + QString convertorName(); QString flavorFor(const QString &mime); @@ -220,10 +177,8 @@ class QMacPasteboardMimeTypeName : public QMacInternalPasteboardMime { private: public: - QMacPasteboardMimeTypeName() : QMacInternalPasteboardMime(MIME_QT_CONVERTOR|MIME_ALL) { - } - ~QMacPasteboardMimeTypeName() { - } + QMacPasteboardMimeTypeName(): QMacInternalPasteboardMime(MIME_ALL_COMPATIBLE) {} + QString convertorName(); QString flavorFor(const QString &mime); @@ -270,7 +225,7 @@ QList QMacPasteboardMimeTypeName::convertFromMime(const QString &, Q class QMacPasteboardMimePlainTextFallback : public QMacInternalPasteboardMime { public: - QMacPasteboardMimePlainTextFallback() : QMacInternalPasteboardMime(MIME_ALL) { } + QMacPasteboardMimePlainTextFallback() : QMacInternalPasteboardMime(MIME_ALL) {} QString convertorName(); QString flavorFor(const QString &mime); @@ -333,7 +288,7 @@ QList QMacPasteboardMimePlainTextFallback::convertFromMime(const QSt class QMacPasteboardMimeUnicodeText : public QMacInternalPasteboardMime { public: - QMacPasteboardMimeUnicodeText() : QMacInternalPasteboardMime(MIME_ALL) { } + QMacPasteboardMimeUnicodeText() : QMacInternalPasteboardMime(MIME_ALL) {} QString convertorName(); QString flavorFor(const QString &mime); @@ -425,7 +380,7 @@ QList QMacPasteboardMimeUnicodeText::convertFromMime(const QString & class QMacPasteboardMimeHTMLText : public QMacInternalPasteboardMime { public: - QMacPasteboardMimeHTMLText() : QMacInternalPasteboardMime(MIME_ALL) { } + QMacPasteboardMimeHTMLText() : QMacInternalPasteboardMime(MIME_ALL) {} QString convertorName(); QString flavorFor(const QString &mime); @@ -479,7 +434,7 @@ QList QMacPasteboardMimeHTMLText::convertFromMime(const QString &mim class QMacPasteboardMimeRtfText : public QMacInternalPasteboardMime { public: - QMacPasteboardMimeRtfText() : QMacInternalPasteboardMime(MIME_ALL) { } + QMacPasteboardMimeRtfText() : QMacInternalPasteboardMime(MIME_ALL) {} QString convertorName(); QString flavorFor(const QString &mime); @@ -554,7 +509,7 @@ QList QMacPasteboardMimeRtfText::convertFromMime(const QString &mime class QMacPasteboardMimeFileUri : public QMacInternalPasteboardMime { public: - QMacPasteboardMimeFileUri() : QMacInternalPasteboardMime(MIME_ALL) { } + QMacPasteboardMimeFileUri() : QMacInternalPasteboardMime(MIME_ALL) {} QString convertorName(); QString flavorFor(const QString &mime); @@ -644,7 +599,7 @@ int QMacPasteboardMimeFileUri::count(QMimeData *mimeData) class QMacPasteboardMimeUrl : public QMacInternalPasteboardMime { public: - QMacPasteboardMimeUrl() : QMacInternalPasteboardMime(MIME_ALL) { } + QMacPasteboardMimeUrl() : QMacInternalPasteboardMime(MIME_ALL) {} QString convertorName(); QString flavorFor(const QString &mime); @@ -719,7 +674,7 @@ QList QMacPasteboardMimeUrl::convertFromMime(const QString &mime, QV class QMacPasteboardMimeVCard : public QMacInternalPasteboardMime { public: - QMacPasteboardMimeVCard() : QMacInternalPasteboardMime(MIME_ALL){ } + QMacPasteboardMimeVCard() : QMacInternalPasteboardMime(MIME_ALL) {} QString convertorName(); QString flavorFor(const QString &mime); @@ -776,7 +731,7 @@ extern CGImageRef qt_mac_toCGImage(const QImage &qImage); class QMacPasteboardMimeTiff : public QMacInternalPasteboardMime { public: - QMacPasteboardMimeTiff() : QMacInternalPasteboardMime(MIME_ALL) { } + QMacPasteboardMimeTiff() : QMacInternalPasteboardMime(MIME_ALL) {} QString convertorName(); QString flavorFor(const QString &mime); @@ -850,107 +805,28 @@ QList QMacPasteboardMimeTiff::convertFromMime(const QString &mime, Q return QList() << QByteArray::fromCFData(data); } -/*! - \internal +namespace QMacMimeRegistry { - This is an internal function. -*/ -void QMacInternalPasteboardMime::initializeMimeTypes() +void registerBuiltInTypes() { - if (globalMimeList()->isEmpty()) { - // Create QMacPasteboardMimeAny first to put it at the end of globalMimeList - // with lowest priority. (the constructor prepends to the list) - new QMacPasteboardMimeAny; + // Create QMacPasteboardMimeAny first to put it at the end of globalMimeList + // with lowest priority. (the constructor prepends to the list) + new QMacPasteboardMimeAny; - //standard types that we wrap - new QMacPasteboardMimeTiff; - new QMacPasteboardMimePlainTextFallback; - new QMacPasteboardMimeUnicodeText; - new QMacPasteboardMimeRtfText; - new QMacPasteboardMimeHTMLText; - new QMacPasteboardMimeFileUri; - new QMacPasteboardMimeUrl; - new QMacPasteboardMimeTypeName; - new QMacPasteboardMimeVCard; - } + //standard types that we wrap + new QMacPasteboardMimeTiff; + new QMacPasteboardMimePlainTextFallback; + new QMacPasteboardMimeUnicodeText; + new QMacPasteboardMimeRtfText; + new QMacPasteboardMimeHTMLText; + new QMacPasteboardMimeFileUri; + new QMacPasteboardMimeUrl; + new QMacPasteboardMimeTypeName; + new QMacPasteboardMimeVCard; } -/*! - \internal -*/ -void QMacInternalPasteboardMime::destroyMimeTypes() -{ - MimeList *mimes = globalMimeList(); - while (!mimes->isEmpty()) - delete mimes->takeFirst(); } -/* - Returns the most-recently created QMacPasteboardMime of type \a t that can convert - between the \a mime and \a flav formats. Returns 0 if no such convertor - exists. -*/ -QMacInternalPasteboardMime* -QMacInternalPasteboardMime::convertor(uchar t, const QString &mime, QString flav) -{ - MimeList *mimes = globalMimeList(); - for (MimeList::const_iterator it = mimes->constBegin(); it != mimes->constEnd(); ++it) { -#ifdef DEBUG_MIME_MAPS - qDebug("QMacPasteboardMime::convertor: seeing if %s (%d) can convert %s to %d[%c%c%c%c] [%d]", - (*it)->convertorName().toLatin1().constData(), - (*it)->type & t, mime.toLatin1().constData(), - flav, (flav >> 24) & 0xFF, (flav >> 16) & 0xFF, (flav >> 8) & 0xFF, (flav) & 0xFF, - (*it)->canConvert(mime,flav)); - for (int i = 0; i < (*it)->countFlavors(); ++i) { - int f = (*it)->flavor(i); - qDebug(" %d) %d[%c%c%c%c] [%s]", i, f, - (f >> 24) & 0xFF, (f >> 16) & 0xFF, (f >> 8) & 0xFF, (f) & 0xFF, - (*it)->convertorName().toLatin1().constData()); - } -#endif - if (((*it)->type & t) && (*it)->canConvert(mime, flav)) - return (*it); - } - return 0; -} -/* - Returns a MIME type of type \a t for \a flav, or 0 if none exists. -*/ -QString QMacInternalPasteboardMime::flavorToMime(uchar t, QString flav) -{ - MimeList *mimes = globalMimeList(); - for (MimeList::const_iterator it = mimes->constBegin(); it != mimes->constEnd(); ++it) { -#ifdef DEBUG_MIME_MAPS - qDebug("QMacMIme::flavorToMime: attempting %s (%d) for flavor %d[%c%c%c%c] [%s]", - (*it)->convertorName().toLatin1().constData(), - (*it)->type & t, flav, (flav >> 24) & 0xFF, (flav >> 16) & 0xFF, (flav >> 8) & 0xFF, (flav) & 0xFF, - (*it)->mimeFor(flav).toLatin1().constData()); - -#endif - if ((*it)->type & t) { - QString mimeType = (*it)->mimeFor(flav); - if (!mimeType.isNull()) - return mimeType; - } - } - return QString(); -} - -/* - Returns a list of all currently defined QMacPasteboardMime objects of type \a t. -*/ -QList QMacInternalPasteboardMime::all(uchar t) -{ - MimeList ret; - MimeList *mimes = globalMimeList(); - for (MimeList::const_iterator it = mimes->constBegin(); it != mimes->constEnd(); ++it) { - if ((*it)->type & t) - ret.append((*it)); - } - return ret; -} - - /* \fn QString QMacPasteboardMime::convertorName() diff --git a/src/gui/platform/darwin/qmacmime_p.h b/src/gui/platform/darwin/qmacmime_p.h index bd926f59fe..0f90ec379f 100644 --- a/src/gui/platform/darwin/qmacmime_p.h +++ b/src/gui/platform/darwin/qmacmime_p.h @@ -22,25 +22,23 @@ QT_BEGIN_NAMESPACE -// Duplicate of QMacPasteboardMime in QtMacExtras. Keep in sync! -class Q_GUI_EXPORT QMacInternalPasteboardMime { - char type; +class Q_GUI_EXPORT QMacInternalPasteboardMime +{ public: - enum QMacPasteboardMimeType { MIME_DND=0x01, - MIME_CLIP=0x02, - MIME_QT_CONVERTOR=0x04, - MIME_QT3_CONVERTOR=0x08, - MIME_ALL=MIME_DND|MIME_CLIP + enum QMacPasteboardMimeType + { + MIME_DND = 0x01, + MIME_CLIP = 0x02, + MIME_QT_CONVERTOR = 0x04, + MIME_QT3_CONVERTOR = 0x08, + MIME_ALL = MIME_DND|MIME_CLIP, + MIME_ALL_COMPATIBLE = MIME_ALL|MIME_QT_CONVERTOR }; - explicit QMacInternalPasteboardMime(char); + + explicit QMacInternalPasteboardMime(QMacPasteboardMimeType); virtual ~QMacInternalPasteboardMime(); - static void initializeMimeTypes(); - static void destroyMimeTypes(); - - static QList all(uchar); - static QMacInternalPasteboardMime *convertor(uchar, const QString &mime, QString flav); - static QString flavorToMime(uchar, QString flav); + char type() const { return m_type; } virtual QString convertorName() = 0; @@ -50,12 +48,10 @@ public: virtual QVariant convertToMime(const QString &mime, QList data, QString flav) = 0; virtual QList convertFromMime(const QString &mime, QVariant data, QString flav) = 0; virtual int count(QMimeData *mimeData); -}; -Q_GUI_EXPORT void qt_mac_addToGlobalMimeList(QMacInternalPasteboardMime *macMime); -Q_GUI_EXPORT void qt_mac_removeFromGlobalMimeList(QMacInternalPasteboardMime *macMime); -Q_GUI_EXPORT void qt_mac_registerDraggedTypes(const QStringList &types); -Q_GUI_EXPORT const QStringList& qt_mac_enabledDraggedTypes(); +private: + const QMacPasteboardMimeType m_type; +}; QT_END_NAMESPACE diff --git a/src/gui/platform/darwin/qmacmimeregistry.mm b/src/gui/platform/darwin/qmacmimeregistry.mm new file mode 100644 index 0000000000..20628535cc --- /dev/null +++ b/src/gui/platform/darwin/qmacmimeregistry.mm @@ -0,0 +1,151 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#include + +#include "qmacmime_p.h" +#include "qmacmimeregistry_p.h" +#include "qguiapplication.h" +#include "private/qcore_mac_p.h" + +QT_BEGIN_NAMESPACE + +using namespace Qt::StringLiterals; + +namespace QMacMimeRegistry { + +typedef QList MimeList; +Q_GLOBAL_STATIC(MimeList, globalMimeList) +Q_GLOBAL_STATIC(QStringList, globalDraggedTypesList) + +// implemented in qmacmime.mm +void registerBuiltInTypes(); + +/*! + \fn void qRegisterDraggedTypes(const QStringList &types) + \relates QMacPasteboardMime + + Registers the given \a types as custom pasteboard types. + + This function should be called to enable the Drag and Drop events + for custom pasteboard types on Cocoa implementations. This is required + in addition to a QMacPasteboardMime subclass implementation. By default + drag and drop is enabled for all standard pasteboard types. + + \sa QMacPasteboardMime +*/ + +void registerDraggedTypes(const QStringList &types) +{ + (*globalDraggedTypesList()) += types; +} + +const QStringList& enabledDraggedTypes() +{ + return (*globalDraggedTypesList()); +} + +/***************************************************************************** + QDnD debug facilities + *****************************************************************************/ +//#define DEBUG_MIME_MAPS + +/*! + \class QMacMimeRegistry + \internal + \ingroup draganddrop +*/ + +/*! + \internal + + This is an internal function. +*/ +void initializeMimeTypes() +{ + if (globalMimeList()->isEmpty()) + registerBuiltInTypes(); +} + +/*! + \internal +*/ +void destroyMimeTypes() +{ + MimeList *mimes = globalMimeList(); + while (!mimes->isEmpty()) + delete mimes->takeFirst(); +} + +/* + Returns the most-recently created QMacPasteboardMime of type \a t that can convert + between the \a mime and \a flav formats. Returns 0 if no such convertor + exists. +*/ +QMacInternalPasteboardMime *convertor(uchar t, const QString &mime, QString flav) +{ + MimeList *mimes = globalMimeList(); + for (MimeList::const_iterator it = mimes->constBegin(); it != mimes->constEnd(); ++it) { +#ifdef DEBUG_MIME_MAPS + qDebug("QMacMimeRegistry::convertor: seeing if %s (%d) can convert %s to %s [%d]", + qPrintable((*it)->convertorName()), (*it)->type() & t, qPrintable(mime), + qPrintable(flav), (*it)->canConvert(mime,flav)); +#endif + if (((*it)->type() & t) && (*it)->canConvert(mime, flav)) + return (*it); + } + return 0; +} +/* + Returns a MIME type of type \a t for \a flav, or 0 if none exists. +*/ +QString flavorToMime(uchar t, QString flav) +{ + MimeList *mimes = globalMimeList(); + for (MimeList::const_iterator it = mimes->constBegin(); it != mimes->constEnd(); ++it) { +#ifdef DEBUG_MIME_MAPS + qDebug("QMacMimeRegistry::flavorToMime: attempting %s (%d) for flavor %s [%s]", + qPrintable((*it)->convertorName()), (*it)->type() & t, qPrintable(flav), + qPrintable((*it)->mimeFor(flav))); +#endif + if ((*it)->type() & t) { + QString mimeType = (*it)->mimeFor(flav); + if (!mimeType.isNull()) + return mimeType; + } + } + return QString(); +} + +void registerMimeConverter(QMacInternalPasteboardMime *macMime) +{ + // globalMimeList is in decreasing priority order. Recently added + // converters take prioity over previously added converters: prepend + // to the list. + globalMimeList()->prepend(macMime); +} + +void unregisterMimeConverter(QMacInternalPasteboardMime *macMime) +{ + if (!QGuiApplication::closingDown()) + globalMimeList()->removeAll(macMime); +} + + +/* + Returns a list of all currently defined QMacPasteboardMime objects of type \a t. +*/ +QList all(uchar t) +{ + MimeList ret; + MimeList *mimes = globalMimeList(); + for (MimeList::const_iterator it = mimes->constBegin(); it != mimes->constEnd(); ++it) { + if ((*it)->type() & t) + ret.append((*it)); + } + return ret; +} + +} // namespace QMacMimeRegistry + +QT_END_NAMESPACE diff --git a/src/gui/platform/darwin/qmacmimeregistry_p.h b/src/gui/platform/darwin/qmacmimeregistry_p.h new file mode 100644 index 0000000000..8e2a3f7d7a --- /dev/null +++ b/src/gui/platform/darwin/qmacmimeregistry_p.h @@ -0,0 +1,44 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QMACMIMEREGISTRY_H +#define QMACMIMEREGISTRY_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + + +#include + +#include + +QT_BEGIN_NAMESPACE + +class QMacInternalPasteboardMime; + +namespace QMacMimeRegistry { + Q_GUI_EXPORT void initializeMimeTypes(); + Q_GUI_EXPORT void destroyMimeTypes(); + + Q_GUI_EXPORT void registerMimeConverter(QMacInternalPasteboardMime *); + Q_GUI_EXPORT void unregisterMimeConverter(QMacInternalPasteboardMime *); + + Q_GUI_EXPORT QList all(uchar); + Q_GUI_EXPORT QMacInternalPasteboardMime *convertor(uchar, const QString &mime, QString flav); + Q_GUI_EXPORT QString flavorToMime(uchar, QString flav); + + Q_GUI_EXPORT void registerDraggedTypes(const QStringList &types); + Q_GUI_EXPORT const QStringList& enabledDraggedTypes(); +}; + +QT_END_NAMESPACE + +#endif // QMACMIMEREGISTRY_H diff --git a/src/plugins/platforms/cocoa/qcocoaclipboard.mm b/src/plugins/platforms/cocoa/qcocoaclipboard.mm index 7363b011bf..8c48f282c9 100644 --- a/src/plugins/platforms/cocoa/qcocoaclipboard.mm +++ b/src/plugins/platforms/cocoa/qcocoaclipboard.mm @@ -3,6 +3,8 @@ #include "qcocoaclipboard.h" +#include + #ifndef QT_NO_CLIPBOARD QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoadrag.mm b/src/plugins/platforms/cocoa/qcocoadrag.mm index 7a73344480..dc1f68bd23 100644 --- a/src/plugins/platforms/cocoa/qcocoadrag.mm +++ b/src/plugins/platforms/cocoa/qcocoadrag.mm @@ -7,6 +7,7 @@ #include "qmacclipboard.h" #include "qcocoahelpers.h" #include +#include #include #include diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm index 2d2a7890d0..b17ab38b10 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -32,6 +32,7 @@ #include #include +#include #include #include #include @@ -164,7 +165,7 @@ QCocoaIntegration::QCocoaIntegration(const QStringList ¶mList) QCocoaScreen::initializeScreens(); - QMacInternalPasteboardMime::initializeMimeTypes(); + QMacMimeRegistry::initializeMimeTypes(); QCocoaMimeTypes::initializeMimeTypes(); QWindowSystemInterfacePrivate::TabletEvent::setPlatformSynthesizesMouse(false); QWindowSystemInterface::registerInputDevice(new QInputDevice(QString("keyboard"), 0, @@ -194,7 +195,7 @@ QCocoaIntegration::~QCocoaIntegration() // Deleting the clipboard integration flushes promised pastes using // the mime converters - the ordering here is important. delete mCocoaClipboard; - QMacInternalPasteboardMime::destroyMimeTypes(); + QMacMimeRegistry::destroyMimeTypes(); #endif QCocoaScreen::cleanupScreens(); diff --git a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm index 38a6060256..fd7e1c07b7 100644 --- a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm +++ b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm @@ -26,6 +26,7 @@ #include #include +#include #include #if QT_CONFIG(vulkan) @@ -120,7 +121,7 @@ void QCocoaNativeInterface::onAppFocusWindowChanged(QWindow *window) void QCocoaNativeInterface::registerDraggedTypes(const QStringList &types) { - qt_mac_registerDraggedTypes(types); + QMacMimeRegistry::registerDraggedTypes(types); } void QCocoaNativeInterface::setEmbeddedInForeignView(QPlatformWindow *window, bool embedded) diff --git a/src/plugins/platforms/cocoa/qmacclipboard.h b/src/plugins/platforms/cocoa/qmacclipboard.h index 925e816831..3cd33f9591 100644 --- a/src/plugins/platforms/cocoa/qmacclipboard.h +++ b/src/plugins/platforms/cocoa/qmacclipboard.h @@ -5,13 +5,14 @@ #define QMACCLIPBOARD_H #include -#include #include QT_BEGIN_NAMESPACE class QMacMimeData; +class QMacInternalPasteboardMime; + class QMacPasteboard { public: diff --git a/src/plugins/platforms/cocoa/qmacclipboard.mm b/src/plugins/platforms/cocoa/qmacclipboard.mm index b298a47bef..5287638d80 100644 --- a/src/plugins/platforms/cocoa/qmacclipboard.mm +++ b/src/plugins/platforms/cocoa/qmacclipboard.mm @@ -4,6 +4,8 @@ #include #include "qmacclipboard.h" +#include +#include #include #include #include @@ -130,7 +132,7 @@ OSStatus QMacPasteboard::promiseKeeper(PasteboardRef paste, PasteboardItemID id, // Find the kept promise QList availableConverters - = QMacInternalPasteboardMime::all(QMacInternalPasteboardMime::MIME_ALL); + = QMacMimeRegistry::all(QMacInternalPasteboardMime::MIME_ALL); const QString flavorAsQString = QString::fromCFString(flavor); QMacPasteboard::Promise promise; for (int i = 0; i < qpaste->promises.size(); i++){ @@ -297,7 +299,7 @@ QMacPasteboard::setMimeData(QMimeData *mime_src, DataRequestType dataRequestType delete mime; mime = mime_src; - QList availableConverters = QMacInternalPasteboardMime::all(mime_type); + QList availableConverters = QMacMimeRegistry::all(mime_type); if (mime != nullptr) { clear_helper(); QStringList formats = mime_src->formats(); @@ -372,7 +374,7 @@ QMacPasteboard::formats() const for (int i = 0; i < type_count; ++i) { const QString flavor = QString::fromCFString((CFStringRef)CFArrayGetValueAtIndex(types, i)); qCDebug(lcQpaClipboard, " -%s", qPrintable(QString(flavor))); - QString mimeType = QMacInternalPasteboardMime::flavorToMime(mime_type, flavor); + QString mimeType = QMacMimeRegistry::flavorToMime(mime_type, flavor); if (!mimeType.isEmpty() && !ret.contains(mimeType)) { qCDebug(lcQpaClipboard, " -<%lld> %s [%s]", ret.size(), qPrintable(mimeType), qPrintable(QString(flavor))); ret << mimeType; @@ -409,7 +411,7 @@ QMacPasteboard::hasFormat(const QString &format) const for (int i = 0; i < type_count; ++i) { const QString flavor = QString::fromCFString((CFStringRef)CFArrayGetValueAtIndex(types, i)); qCDebug(lcQpaClipboard, " -%s [0x%x]", qPrintable(QString(flavor)), mime_type); - QString mimeType = QMacInternalPasteboardMime::flavorToMime(mime_type, flavor); + QString mimeType = QMacMimeRegistry::flavorToMime(mime_type, flavor); if (!mimeType.isEmpty()) qCDebug(lcQpaClipboard, " - %s", qPrintable(mimeType)); if (mimeType == format) @@ -432,7 +434,7 @@ QMacPasteboard::retrieveData(const QString &format, QMetaType) const return QByteArray(); qCDebug(lcQpaClipboard, "Pasteboard: retrieveData [%s]", qPrintable(format)); - const QList mimes = QMacInternalPasteboardMime::all(mime_type); + const QList mimes = QMacMimeRegistry::all(mime_type); for (int mime = 0; mime < mimes.size(); ++mime) { QMacInternalPasteboardMime *c = mimes.at(mime); QString c_flavor = c->flavorFor(format); diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index b73d186612..eb4405ccd0 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -34,6 +34,7 @@ #include "qcocoaglcontext.h" #endif #include "qcocoaintegration.h" +#include // Private interface @interface QNSView () diff --git a/src/plugins/platforms/cocoa/qnsview_dragging.mm b/src/plugins/platforms/cocoa/qnsview_dragging.mm index c88e5d502f..06b917945a 100644 --- a/src/plugins/platforms/cocoa/qnsview_dragging.mm +++ b/src/plugins/platforms/cocoa/qnsview_dragging.mm @@ -21,7 +21,7 @@ NSPasteboardTypeMultipleTextSelection, mimeTypeGeneric]]; // Add custom types supported by the application - for (const QString &customType : qt_mac_enabledDraggedTypes()) + for (const QString &customType : QMacMimeRegistry::enabledDraggedTypes()) [supportedTypes addObject:customType.toNSString()]; [self registerForDraggedTypes:supportedTypes]; diff --git a/src/plugins/platforms/ios/qiosclipboard.mm b/src/plugins/platforms/ios/qiosclipboard.mm index 554c3ca118..62a9061086 100644 --- a/src/plugins/platforms/ios/qiosclipboard.mm +++ b/src/plugins/platforms/ios/qiosclipboard.mm @@ -6,6 +6,7 @@ #ifndef QT_NO_CLIPBOARD #include +#include #include #include #include @@ -116,7 +117,7 @@ QStringList QIOSMimeData::formats() const for (NSUInteger i = 0; i < [pasteboardTypes count]; ++i) { QString uti = QString::fromNSString([pasteboardTypes objectAtIndex:i]); - QString mimeType = QMacInternalPasteboardMime::flavorToMime(QMacInternalPasteboardMime::MIME_ALL, uti); + QString mimeType = QMacMimeRegistry::flavorToMime(QMacInternalPasteboardMime::MIME_ALL, uti); if (!mimeType.isEmpty() && !foundMimeTypes.contains(mimeType)) foundMimeTypes << mimeType; } @@ -130,7 +131,7 @@ QVariant QIOSMimeData::retrieveData(const QString &mimeType, QMetaType) const NSArray *pasteboardTypes = [pb pasteboardTypes]; foreach (QMacInternalPasteboardMime *converter, - QMacInternalPasteboardMime::all(QMacInternalPasteboardMime::MIME_ALL)) { + QMacMimeRegistry::all(QMacInternalPasteboardMime::MIME_ALL)) { if (!converter->canConvert(mimeType, converter->flavorFor(mimeType))) continue; @@ -185,7 +186,7 @@ void QIOSClipboard::setMimeData(QMimeData *mimeData, QClipboard::Mode mode) foreach (const QString &mimeType, mimeData->formats()) { foreach (QMacInternalPasteboardMime *converter, - QMacInternalPasteboardMime::all(QMacInternalPasteboardMime::MIME_ALL)) { + QMacMimeRegistry::all(QMacInternalPasteboardMime::MIME_ALL)) { QString uti = converter->flavorFor(mimeType); if (uti.isEmpty() || !converter->canConvert(mimeType, uti)) continue; diff --git a/src/plugins/platforms/ios/qiosintegration.mm b/src/plugins/platforms/ios/qiosintegration.mm index 84caccc267..244b182f65 100644 --- a/src/plugins/platforms/ios/qiosintegration.mm +++ b/src/plugins/platforms/ios/qiosintegration.mm @@ -24,6 +24,7 @@ #include #include +#include #include #include #include @@ -89,7 +90,7 @@ void QIOSIntegration::initialize() #if QT_CONFIG(tabletevent) QWindowSystemInterfacePrivate::TabletEvent::setPlatformSynthesizesMouse(false); #endif - QMacInternalPasteboardMime::initializeMimeTypes(); + QMacMimeRegistry::initializeMimeTypes(); qsizetype size = QList(m_optionalPlugins->metaData()).size(); for (qsizetype i = 0; i < size; ++i) @@ -105,7 +106,7 @@ QIOSIntegration::~QIOSIntegration() delete m_clipboard; m_clipboard = 0; #endif - QMacInternalPasteboardMime::destroyMimeTypes(); + QMacMimeRegistry::destroyMimeTypes(); delete m_inputContext; m_inputContext = 0;