summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@digia.com>2013-01-02 14:04:29 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-01-21 09:29:32 +0100
commit3e8996df2a2016fd0f80cbe44e72f556964654ce (patch)
tree92e2218a1f4b10d8a65280bcf5b67b5a7846f572 /src/plugins/platforms/cocoa
parentf8c389bc3c8dc0a99d16bf566643744e9bfa2e91 (diff)
Export functions to add custom mime converters.
For use with public API in QtMacExtras. This goes into Qt stable: Fix for new functionality, and close a feature regression against Qt 4. Change-Id: I555fdff3ddb39336ccd72f9711d465f1c18c6b45 Reviewed-by: James Turner <james.turner@kdab.com> Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
Diffstat (limited to 'src/plugins/platforms/cocoa')
-rw-r--r--src/plugins/platforms/cocoa/qcocoanativeinterface.h9
-rw-r--r--src/plugins/platforms/cocoa/qcocoanativeinterface.mm28
-rw-r--r--src/plugins/platforms/cocoa/qmacmime.h8
-rw-r--r--src/plugins/platforms/cocoa/qmacmime.mm21
-rw-r--r--src/plugins/platforms/cocoa/qnsview.mm4
5 files changed, 61 insertions, 9 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoanativeinterface.h b/src/plugins/platforms/cocoa/qcocoanativeinterface.h
index 2fa9d7ebe4..825f88a269 100644
--- a/src/plugins/platforms/cocoa/qcocoanativeinterface.h
+++ b/src/plugins/platforms/cocoa/qcocoanativeinterface.h
@@ -59,6 +59,8 @@ public:
void *nativeResourceForContext(const QByteArray &resourceString, QOpenGLContext *context);
void *nativeResourceForWindow(const QByteArray &resourceString, QWindow *window);
+ NativeResourceForIntegrationFunction nativeResourceFunctionForIntegration(const QByteArray &resource) Q_DECL_OVERRIDE;
+
static void *cglContextForContext(QOpenGLContext *context);
static void *nsOpenGLContextForContext(QOpenGLContext* context);
@@ -83,6 +85,13 @@ private:
Needed by the native print dialog in the QtPrintSupport library.
*/
Q_INVOKABLE void *NSPrintInfoForPrintEngine(QPrintEngine *printEngine);
+
+ // QMacPastebardMime support. The mac pasteboard void pointers are
+ // QMacPastebardMime instances from the cocoa plugin or qtmacextras
+ // These two classes are kept in sync and can be casted between.
+ static void addToMimeList(void *macPasteboardMime);
+ static void removeFromMimeList(void *macPasteboardMime);
+ static void registerDraggedTypes(const QStringList &types);
};
#endif // QCOCOANATIVEINTERFACE_H
diff --git a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm
index d2fc287e31..08084b5200 100644
--- a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm
+++ b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm
@@ -43,6 +43,7 @@
#include "qcocoaglcontext.h"
#include "qcocoawindow.h"
#include "qcocoamenubar.h"
+#include "qmacmime.h"
#include <qbytearray.h>
#include <qwindow.h>
@@ -94,6 +95,18 @@ void *QCocoaNativeInterface::nativeResourceForWindow(const QByteArray &resourceS
return 0;
}
+QPlatformNativeInterface::NativeResourceForIntegrationFunction QCocoaNativeInterface::nativeResourceFunctionForIntegration(const QByteArray &resource)
+{
+ if (resource.toLower() == "addtomimelist")
+ return NativeResourceForIntegrationFunction(QCocoaNativeInterface::addToMimeList);
+ if (resource.toLower() == "removefrommimelist")
+ return NativeResourceForIntegrationFunction(QCocoaNativeInterface::removeFromMimeList);
+ if (resource.toLower() == "registerdraggedtypes")
+ return NativeResourceForIntegrationFunction(QCocoaNativeInterface::registerDraggedTypes);
+
+ return 0;
+}
+
QPlatformPrinterSupport *QCocoaNativeInterface::createPlatformPrinterSupport()
{
#ifndef QT_NO_WIDGETS
@@ -142,4 +155,19 @@ void *QCocoaNativeInterface::nsOpenGLContextForContext(QOpenGLContext* context)
return 0;
}
+void QCocoaNativeInterface::addToMimeList(void *macPasteboardMime)
+{
+ qt_mac_addToGlobalMimeList(reinterpret_cast<QMacPasteboardMime *>(macPasteboardMime));
+}
+
+void QCocoaNativeInterface::removeFromMimeList(void *macPasteboardMime)
+{
+ qt_mac_removeFromGlobalMimeList(reinterpret_cast<QMacPasteboardMime *>(macPasteboardMime));
+}
+
+void QCocoaNativeInterface::registerDraggedTypes(const QStringList &types)
+{
+ qt_mac_registerDraggedTypes(types);
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/cocoa/qmacmime.h b/src/plugins/platforms/cocoa/qmacmime.h
index 394b8fbe43..d9ef63ae48 100644
--- a/src/plugins/platforms/cocoa/qmacmime.h
+++ b/src/plugins/platforms/cocoa/qmacmime.h
@@ -48,7 +48,8 @@
QT_BEGIN_NAMESPACE
-class Q_GUI_EXPORT QMacPasteboardMime {
+// Duplicate of QMacPasteboardMime in QtMacExtras. Keep in sync!
+class QMacPasteboardMime {
char type;
public:
enum QMacPasteboardMimeType { MIME_DND=0x01,
@@ -77,6 +78,11 @@ public:
virtual int count(QMimeData *mimeData);
};
+void qt_mac_addToGlobalMimeList(QMacPasteboardMime *macMime);
+void qt_mac_removeFromGlobalMimeList(QMacPasteboardMime *macMime);
+void qt_mac_registerDraggedTypes(const QStringList &types);
+const QStringList& qt_mac_enabledDraggedTypes();
+
QT_END_NAMESPACE
#endif
diff --git a/src/plugins/platforms/cocoa/qmacmime.mm b/src/plugins/platforms/cocoa/qmacmime.mm
index ad898e1a3d..339559b6a6 100644
--- a/src/plugins/platforms/cocoa/qmacmime.mm
+++ b/src/plugins/platforms/cocoa/qmacmime.mm
@@ -66,6 +66,17 @@ typedef QList<QMacPasteboardMime*> MimeList;
Q_GLOBAL_STATIC(MimeList, globalMimeList)
Q_GLOBAL_STATIC(QStringList, globalDraggedTypesList)
+void qt_mac_addToGlobalMimeList(QMacPasteboardMime *macMime)
+{
+ globalMimeList()->append(macMime);
+}
+
+void qt_mac_removeFromGlobalMimeList(QMacPasteboardMime *macMime)
+{
+ if (!QGuiApplication::closingDown())
+ globalMimeList()->removeAll(macMime);
+}
+
/*!
\fn void qRegisterDraggedTypes(const QStringList &types)
\relates QMacPasteboardMime
@@ -79,17 +90,16 @@ Q_GLOBAL_STATIC(QStringList, globalDraggedTypesList)
\sa QMacPasteboardMime
*/
-Q_WIDGETS_EXPORT void qRegisterDraggedTypes(const QStringList &types)
+void qt_mac_registerDraggedTypes(const QStringList &types)
{
(*globalDraggedTypesList()) += types;
}
-const QStringList& qEnabledDraggedTypes()
+const QStringList& qt_mac_enabledDraggedTypes()
{
return (*globalDraggedTypesList());
}
-
/*****************************************************************************
QDnD debug facilities
*****************************************************************************/
@@ -155,7 +165,7 @@ CFStringRef qt_mac_mime_typeUTI = CFSTR("com.pasteboard.trolltech.marker");
*/
QMacPasteboardMime::QMacPasteboardMime(char t) : type(t)
{
- globalMimeList()->append(this);
+ qt_mac_addToGlobalMimeList(this);
}
/*!
@@ -164,8 +174,7 @@ QMacPasteboardMime::QMacPasteboardMime(char t) : type(t)
*/
QMacPasteboardMime::~QMacPasteboardMime()
{
- if (!QGuiApplication::closingDown())
- globalMimeList()->removeAll(this);
+ qt_mac_removeFromGlobalMimeList(this);
}
/*!
diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm
index 91cbf2a88e..715b0c367f 100644
--- a/src/plugins/platforms/cocoa/qnsview.mm
+++ b/src/plugins/platforms/cocoa/qnsview.mm
@@ -49,6 +49,7 @@
#include "qcocoaautoreleasepool.h"
#include "qmultitouch_mac_p.h"
#include "qcocoadrag.h"
+#include "qmacmime.h"
#include <qpa/qplatformintegration.h>
#include <qpa/qwindowsysteminterface.h>
@@ -1106,8 +1107,7 @@ static QTouchDevice *touchDevice = 0;
-(void)registerDragTypes
{
QCocoaAutoReleasePool pool;
- // ### Custom types disabled.
- QStringList customTypes; // = qEnabledDraggedTypes();
+ QStringList customTypes = qt_mac_enabledDraggedTypes();
if (currentCustomDragTypes == 0 || *currentCustomDragTypes != customTypes) {
if (currentCustomDragTypes == 0)
currentCustomDragTypes = new QStringList();