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>
This commit is contained in:
parent
f8c389bc3c
commit
3e8996df2a
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user