Reintroduce converter APIs for supporting native clipboard formats
In Qt 5, QWin(dows)Mime and QMacMime lived in the respective Extras modules, which were removed and partially folded into the relevant modules in Qt. QWindowsMime and QMacMime continued to provide the abstraction for implementing built-in support for native clipboard formats and UTIs within Qt, but only as private APIs. After the recent clean up of those APIs and respective infrastructure, we can now bring them back as public converter interfaces. Application developers can subclass those and instantiate an instance of their implementation to add support for platform or application specific data formats. These interfaces are not in the QNativeInterface namespace, as applications don't call into Windows or macOS using those interfaces. I.e. there is no class on which an application would call auto *converter= nativeInterface<QWindowsMimeConverter>(); Also, since applications override those converter types, we do want to guarantee binary and source compatibility. [ChangeLog][QtGui][QWindowsMimeConverter] Reintroduced to allow applications to add support for conversion from and to Windows-native clipboard formats to MIME-encoded data. [ChangeLog][QtGui][QUtiMimeConverter] Reintroduced to allow applications to add support for conversion from and to clipboard data on macOS and iOS to MIME-encoded data. Fixes: QTBUG-93632 Change-Id: Iebd909c3970015d203f59d5ab15e306b3d312f6e Reviewed-by: Yuhang Zhao <2546789017@qq.com> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
parent
427152c9b9
commit
649dccf57b
@ -280,9 +280,9 @@ QVariant QMimeDataPrivate::retrieveTypedData(const QString &format, QMetaType ty
|
||||
\snippet code/src_corelib_kernel_qmimedata.cpp 8
|
||||
|
||||
On Windows, the MIME format does not always map directly to the
|
||||
clipboard formats. Qt provides QWinMime to map clipboard
|
||||
clipboard formats. Qt provides QWindowsMimeConverter to map clipboard
|
||||
formats to open-standard MIME formats. Similarly, the
|
||||
QMacMime maps MIME to Mac flavors.
|
||||
QUtiMimeConverter maps MIME to Uniform Type Identifiers on macOS and iOS.
|
||||
|
||||
\sa QClipboard, QDragEnterEvent, QDragMoveEvent, QDropEvent, QDrag,
|
||||
{Drag and Drop}
|
||||
|
@ -390,7 +390,7 @@ qt_internal_extend_target(Gui CONDITION APPLE
|
||||
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/qutimimeconverter.mm platform/darwin/qutimimeconverter.h
|
||||
platform/darwin/qapplekeymapper.mm platform/darwin/qapplekeymapper_p.h
|
||||
text/coretext/qcoretextfontdatabase.mm text/coretext/qcoretextfontdatabase_p.h
|
||||
text/coretext/qfontengine_coretext.mm text/coretext/qfontengine_coretext_p.h
|
||||
@ -413,7 +413,7 @@ qt_internal_extend_target(Gui CONDITION WIN32
|
||||
image/qpixmap_win.cpp
|
||||
kernel/qwindowdefs_win.h
|
||||
platform/windows/qwindowsguieventdispatcher.cpp platform/windows/qwindowsguieventdispatcher_p.h
|
||||
platform/windows/qwindowsmime_p.h platform/windows/qwindowsmime.cpp
|
||||
platform/windows/qwindowsmimeconverter.h platform/windows/qwindowsmimeconverter.cpp
|
||||
platform/windows/qwindowsnativeinterface.cpp
|
||||
rhi/cs_tdr_p.h
|
||||
rhi/qrhid3d11.cpp rhi/qrhid3d11_p.h
|
||||
|
@ -16,4 +16,3 @@
|
||||
#include <QtGui/qpa/qplatformscreen_p.h>
|
||||
#include <QtGui/private/qguiapplication_p.h>
|
||||
#include <QtGui/private/qkeymapper_p.h>
|
||||
#include <QtGui/private/qwindowsmime_p.h>
|
||||
|
@ -379,7 +379,7 @@
|
||||
their clipboard formats.
|
||||
|
||||
Custom classes for translating proprietary clipboard formats can be
|
||||
registered by reimplementing QWinMime on Windows or
|
||||
QMacMime on \macos.
|
||||
registered by reimplementing QWindowsMimeConverter on Windows or
|
||||
QUtiMimeConverter on \macos.
|
||||
|
||||
*/
|
||||
|
@ -333,11 +333,12 @@ private:
|
||||
|
||||
// ----------------- QNativeInterface -----------------
|
||||
|
||||
class QWindowsMimeConverter;
|
||||
|
||||
namespace QNativeInterface::Private {
|
||||
|
||||
#if defined(Q_OS_WIN) || defined(Q_QDOC)
|
||||
|
||||
class QWindowsMime;
|
||||
|
||||
struct Q_GUI_EXPORT QWindowsApplication
|
||||
{
|
||||
@ -381,8 +382,8 @@ struct Q_GUI_EXPORT QWindowsApplication
|
||||
virtual DarkModeHandling darkModeHandling() const = 0;
|
||||
virtual void setDarkModeHandling(DarkModeHandling handling) = 0;
|
||||
|
||||
virtual void registerMime(QWindowsMime *mime) = 0;
|
||||
virtual void unregisterMime(QWindowsMime *mime) = 0;
|
||||
virtual void registerMime(QWindowsMimeConverter *mime) = 0;
|
||||
virtual void unregisterMime(QWindowsMimeConverter *mime) = 0;
|
||||
|
||||
virtual int registerMimeType(const QString &mime) = 0;
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
#include <QtCore/qmimedata.h>
|
||||
|
||||
#include "qmacmime_p.h"
|
||||
#include "qutimimeconverter.h"
|
||||
#include "qmacmimeregistry_p.h"
|
||||
#include "qguiapplication.h"
|
||||
#include "private/qcore_mac_p.h"
|
||||
@ -14,25 +14,25 @@ using namespace Qt::StringLiterals;
|
||||
|
||||
namespace QMacMimeRegistry {
|
||||
|
||||
typedef QList<QMacMime*> MimeList;
|
||||
typedef QList<QUtiMimeConverter*> MimeList;
|
||||
Q_GLOBAL_STATIC(MimeList, globalMimeList)
|
||||
Q_GLOBAL_STATIC(QStringList, globalDraggedTypesList)
|
||||
|
||||
// implemented in qmacmime.mm
|
||||
// implemented in qutimimeconverter.mm
|
||||
void registerBuiltInTypes();
|
||||
|
||||
/*!
|
||||
\fn void qRegisterDraggedTypes(const QStringList &types)
|
||||
\relates QMacMime
|
||||
\relates QUtiMimeConverter
|
||||
|
||||
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 QMacMime subclass implementation. By default
|
||||
in addition to a QUtiMimeConverter subclass implementation. By default
|
||||
drag and drop is enabled for all standard pasteboard types.
|
||||
|
||||
\sa QMacMime
|
||||
\sa QUtiMimeConverter
|
||||
*/
|
||||
|
||||
void registerDraggedTypes(const QStringList &types)
|
||||
@ -80,7 +80,7 @@ void destroyMimeTypes()
|
||||
/*
|
||||
Returns a MIME type of for scope \a scope for \a uti, or \nullptr if none exists.
|
||||
*/
|
||||
QString flavorToMime(QMacMime::HandlerScope scope, const QString &uti)
|
||||
QString flavorToMime(QUtiMimeConverter::HandlerScope scope, const QString &uti)
|
||||
{
|
||||
MimeList *mimes = globalMimeList();
|
||||
for (MimeList::const_iterator it = mimes->constBegin(); it != mimes->constEnd(); ++it) {
|
||||
@ -98,7 +98,7 @@ QString flavorToMime(QMacMime::HandlerScope scope, const QString &uti)
|
||||
return QString();
|
||||
}
|
||||
|
||||
void registerMimeConverter(QMacMime *macMime)
|
||||
void registerMimeConverter(QUtiMimeConverter *macMime)
|
||||
{
|
||||
// globalMimeList is in decreasing priority order. Recently added
|
||||
// converters take prioity over previously added converters: prepend
|
||||
@ -106,7 +106,7 @@ void registerMimeConverter(QMacMime *macMime)
|
||||
globalMimeList()->prepend(macMime);
|
||||
}
|
||||
|
||||
void unregisterMimeConverter(QMacMime *macMime)
|
||||
void unregisterMimeConverter(QUtiMimeConverter *macMime)
|
||||
{
|
||||
if (!QGuiApplication::closingDown())
|
||||
globalMimeList()->removeAll(macMime);
|
||||
@ -114,9 +114,9 @@ void unregisterMimeConverter(QMacMime *macMime)
|
||||
|
||||
|
||||
/*
|
||||
Returns a list of all currently defined QMacMime objects for scope \a scope.
|
||||
Returns a list of all currently defined QUtiMimeConverter objects for scope \a scope.
|
||||
*/
|
||||
QList<QMacMime *> all(QMacMime::HandlerScope scope)
|
||||
QList<QUtiMimeConverter *> all(QUtiMimeConverter::HandlerScope scope)
|
||||
{
|
||||
MimeList ret;
|
||||
MimeList *mimes = globalMimeList();
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
|
||||
#include <QtGui/private/qtguiglobal_p.h>
|
||||
#include <QtGui/private/qmacmime_p.h>
|
||||
#include <QtGui/qutimimeconverter.h>
|
||||
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
|
||||
@ -27,11 +27,11 @@ namespace QMacMimeRegistry {
|
||||
Q_GUI_EXPORT void initializeMimeTypes();
|
||||
Q_GUI_EXPORT void destroyMimeTypes();
|
||||
|
||||
Q_GUI_EXPORT void registerMimeConverter(QMacMime *);
|
||||
Q_GUI_EXPORT void unregisterMimeConverter(QMacMime *);
|
||||
Q_GUI_EXPORT void registerMimeConverter(QUtiMimeConverter *);
|
||||
Q_GUI_EXPORT void unregisterMimeConverter(QUtiMimeConverter *);
|
||||
|
||||
Q_GUI_EXPORT QList<QMacMime *> all(QMacMime::HandlerScope scope);
|
||||
Q_GUI_EXPORT QString flavorToMime(QMacMime::HandlerScope scope, const QString &flav);
|
||||
Q_GUI_EXPORT QList<QUtiMimeConverter *> all(QUtiMimeConverter::HandlerScope scope);
|
||||
Q_GUI_EXPORT QString flavorToMime(QUtiMimeConverter::HandlerScope scope, const QString &flav);
|
||||
|
||||
Q_GUI_EXPORT void registerDraggedTypes(const QStringList &types);
|
||||
Q_GUI_EXPORT const QStringList& enabledDraggedTypes();
|
||||
|
@ -1,28 +1,21 @@
|
||||
// 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
|
||||
|
||||
#ifndef QMACMIME_H
|
||||
#define QMACMIME_H
|
||||
#ifndef QUTIMIMECONVERTER_H
|
||||
#define QUTIMIMECONVERTER_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 <QtGui/qtguiglobal.h>
|
||||
|
||||
|
||||
#include <QtGui/private/qtguiglobal_p.h>
|
||||
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
#include <QtCore/qlist.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class Q_GUI_EXPORT QMacMime
|
||||
class QByteArray;
|
||||
class QString;
|
||||
class QVariant;
|
||||
class QMimeData;
|
||||
|
||||
class Q_GUI_EXPORT QUtiMimeConverter
|
||||
{
|
||||
public:
|
||||
enum class HandlerScope : uchar
|
||||
@ -35,9 +28,9 @@ public:
|
||||
AllCompatible = All|Qt_compatible
|
||||
};
|
||||
|
||||
QMacMime();
|
||||
explicit QMacMime(HandlerScope scope); // internal
|
||||
virtual ~QMacMime();
|
||||
QUtiMimeConverter();
|
||||
explicit QUtiMimeConverter(HandlerScope scope); // internal
|
||||
virtual ~QUtiMimeConverter();
|
||||
|
||||
HandlerScope scope() const { return m_scope; }
|
||||
bool canConvert(const QString &mime, const QString &uti) const { return mimeForUti(uti) == mime; }
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
||||
|
||||
#include <ImageIO/ImageIO.h>
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
|
||||
#include <QtCore/qsystemdetection.h>
|
||||
#include <QtCore/qurl.h>
|
||||
@ -19,7 +20,7 @@
|
||||
#import <UIKit/UIKit.h>
|
||||
#endif
|
||||
|
||||
#include "qmacmime_p.h"
|
||||
#include "qutimimeconverter.h"
|
||||
#include "qmacmimeregistry_p.h"
|
||||
#include "qguiapplication.h"
|
||||
#include "private/qcore_mac_p.h"
|
||||
@ -34,9 +35,9 @@ using namespace Qt::StringLiterals;
|
||||
//#define DEBUG_MIME_MAPS
|
||||
|
||||
/*!
|
||||
\class QMacMime
|
||||
\class QUtiMimeConverter
|
||||
\internal
|
||||
\brief The QMacMime class converts between a MIME type and a
|
||||
\brief The QUtiMimeConverter class converts between a MIME type and a
|
||||
\l{https://developer.apple.com/documentation/uniformtypeidentifiers}
|
||||
{Uniform Type Identifier (UTI)} format.
|
||||
\since 4.2
|
||||
@ -49,11 +50,11 @@ using namespace Qt::StringLiterals;
|
||||
Mac, although some applications use MIME to describe clipboard
|
||||
contents, it is more common to use Apple's UTI format.
|
||||
|
||||
QMacMime's role is to bridge the gap between MIME and UTI;
|
||||
QUtiMimeConverter's role is to bridge the gap between MIME and UTI;
|
||||
By subclasses this class, one can extend Qt's drag and drop
|
||||
and clipboard handling to convert to and from unsupported, or proprietary, UTI formats.
|
||||
|
||||
A subclass of QMacMime will automatically be registered, and active, upon instantiation.
|
||||
A subclass of QUtiMimeConverter will automatically be registered, and active, upon instantiation.
|
||||
|
||||
Qt has predefined support for the following UTIs:
|
||||
\list
|
||||
@ -69,14 +70,14 @@ using namespace Qt::StringLiterals;
|
||||
\li com.apple.pict - converts to "application/x-qt-image"
|
||||
\endlist
|
||||
|
||||
When working with MIME data, Qt will iterate through all instances of QMacMime to find
|
||||
When working with MIME data, Qt will iterate through all instances of QUtiMimeConverter to find
|
||||
find an instance that can convert to, or from, a specific MIME type. It will do this by calling
|
||||
mimeForUti() or utiForMime() on each instance, starting with (and choosing) the last created
|
||||
instance first. The actual conversions will be done by using convertToMime() and convertFromMime().
|
||||
*/
|
||||
|
||||
/*!
|
||||
\enum QMacMime::HandlerScope
|
||||
\enum QUtiMimeConverter::HandlerScope
|
||||
\internal
|
||||
*/
|
||||
|
||||
@ -84,7 +85,7 @@ using namespace Qt::StringLiterals;
|
||||
Constructs a new conversion object of type \a scope, adding it to the
|
||||
globally accessed list of available converters.
|
||||
*/
|
||||
QMacMime::QMacMime(HandlerScope scope)
|
||||
QUtiMimeConverter::QUtiMimeConverter(HandlerScope scope)
|
||||
: m_scope(scope)
|
||||
{
|
||||
QMacMimeRegistry::registerMimeConverter(this);
|
||||
@ -94,8 +95,8 @@ QMacMime::QMacMime(HandlerScope scope)
|
||||
Constructs a new conversion object and adds it to the
|
||||
globally accessed list of available converters.
|
||||
*/
|
||||
QMacMime::QMacMime()
|
||||
: QMacMime(HandlerScope::All)
|
||||
QUtiMimeConverter::QUtiMimeConverter()
|
||||
: QUtiMimeConverter(HandlerScope::All)
|
||||
{
|
||||
}
|
||||
|
||||
@ -103,7 +104,7 @@ QMacMime::QMacMime()
|
||||
Destroys a conversion object, removing it from the global
|
||||
list of available converters.
|
||||
*/
|
||||
QMacMime::~QMacMime()
|
||||
QUtiMimeConverter::~QUtiMimeConverter()
|
||||
{
|
||||
QMacMimeRegistry::unregisterMimeConverter(this);
|
||||
}
|
||||
@ -111,21 +112,21 @@ QMacMime::~QMacMime()
|
||||
/*!
|
||||
Returns the item count for the given \a mimeData
|
||||
*/
|
||||
int QMacMime::count(const QMimeData *mimeData) const
|
||||
int QUtiMimeConverter::count(const QMimeData *mimeData) const
|
||||
{
|
||||
Q_UNUSED(mimeData);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn bool QMacMime::canConvert(const QString &mime, const QString &uti) const
|
||||
\fn bool QUtiMimeConverter::canConvert(const QString &mime, const QString &uti) const
|
||||
|
||||
Returns \c true if the converter can convert (both ways) between
|
||||
\a mime and \a uti; otherwise returns \c false.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QString QMacMime::mimeForUti(QString uti)
|
||||
\fn QString QUtiMimeConverter::mimeForUti(QString uti)
|
||||
|
||||
Returns the MIME type used for Mac UTI \a uti, or an empty string if
|
||||
this converter does not support converting from \a uti.
|
||||
@ -134,7 +135,7 @@ int QMacMime::count(const QMimeData *mimeData) const
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QString QMacMime::utiForMime(const QString &mime)
|
||||
\fn QString QUtiMimeConverter::utiForMime(const QString &mime)
|
||||
|
||||
Returns the Mac UTI used for MIME type \a mime, or an empty string if
|
||||
this converter does not support converting from \a mime.
|
||||
@ -143,7 +144,7 @@ int QMacMime::count(const QMimeData *mimeData) const
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QVariant QMacMime::convertToMime(const QString &mime,
|
||||
\fn QVariant QUtiMimeConverter::convertToMime(const QString &mime,
|
||||
const QList<QByteArray> &data, const QString &uti)
|
||||
|
||||
Returns \a data converted from Mac UTI \a uti to MIME type \a mime.
|
||||
@ -155,7 +156,7 @@ int QMacMime::count(const QMimeData *mimeData) const
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QList<QByteArray> QMacMime::convertFromMime(const QString &mime,
|
||||
\fn QList<QByteArray> QUtiMimeConverter::convertFromMime(const QString &mime,
|
||||
const QVariant &data, const QString & uti)
|
||||
|
||||
Returns \a data converted from MIME type \a mime to Mac UTI \a uti.
|
||||
@ -167,9 +168,9 @@ int QMacMime::count(const QMimeData *mimeData) const
|
||||
*/
|
||||
|
||||
|
||||
class QMacMimeAny : public QMacMime {
|
||||
class QMacMimeAny : public QUtiMimeConverter {
|
||||
public:
|
||||
QMacMimeAny() : QMacMime(HandlerScope::AllCompatible) {}
|
||||
QMacMimeAny() : QUtiMimeConverter(HandlerScope::AllCompatible) {}
|
||||
|
||||
QString utiForMime(const QString &mime) const override;
|
||||
QString mimeForUti(const QString &uti) const override;
|
||||
@ -220,11 +221,11 @@ QList<QByteArray> QMacMimeAny::convertFromMime(const QString &mime, const QVaria
|
||||
return ret;
|
||||
}
|
||||
|
||||
class QMacMimeTypeName : public QMacMime {
|
||||
class QMacMimeTypeName : public QUtiMimeConverter {
|
||||
private:
|
||||
|
||||
public:
|
||||
QMacMimeTypeName(): QMacMime(HandlerScope::AllCompatible) {}
|
||||
QMacMimeTypeName(): QUtiMimeConverter(HandlerScope::AllCompatible) {}
|
||||
|
||||
QString utiForMime(const QString &mime) const override;
|
||||
QString mimeForUti(const QString &uti) const override;
|
||||
@ -257,7 +258,7 @@ QList<QByteArray> QMacMimeTypeName::convertFromMime(const QString &, const QVari
|
||||
return ret;
|
||||
}
|
||||
|
||||
class QMacMimePlainTextFallback : public QMacMime
|
||||
class QMacMimePlainTextFallback : public QUtiMimeConverter
|
||||
{
|
||||
public:
|
||||
QString utiForMime(const QString &mime) const override;
|
||||
@ -313,7 +314,7 @@ QMacMimePlainTextFallback::convertFromMime(const QString &, const QVariant &data
|
||||
return ret;
|
||||
}
|
||||
|
||||
class QMacMimeUnicodeText : public QMacMime
|
||||
class QMacMimeUnicodeText : public QUtiMimeConverter
|
||||
{
|
||||
public:
|
||||
QString utiForMime(const QString &mime) const override;
|
||||
@ -396,7 +397,7 @@ QMacMimeUnicodeText::convertFromMime(const QString &, const QVariant &data,
|
||||
return ret;
|
||||
}
|
||||
|
||||
class QMacMimeHTMLText : public QMacMime
|
||||
class QMacMimeHTMLText : public QUtiMimeConverter
|
||||
{
|
||||
public:
|
||||
QString utiForMime(const QString &mime) const override;
|
||||
@ -443,7 +444,7 @@ QMacMimeHTMLText::convertFromMime(const QString &mime,
|
||||
return ret;
|
||||
}
|
||||
|
||||
class QMacMimeRtfText : public QMacMime
|
||||
class QMacMimeRtfText : public QUtiMimeConverter
|
||||
{
|
||||
public:
|
||||
QString utiForMime(const QString &mime) const override;
|
||||
@ -511,7 +512,7 @@ QMacMimeRtfText::convertFromMime(const QString &mime,
|
||||
return ret;
|
||||
}
|
||||
|
||||
class QMacMimeFileUri : public QMacMime
|
||||
class QMacMimeFileUri : public QUtiMimeConverter
|
||||
{
|
||||
public:
|
||||
QString utiForMime(const QString &mime) const override;
|
||||
@ -594,7 +595,7 @@ int QMacMimeFileUri::count(const QMimeData *mimeData) const
|
||||
return mimeData->urls().count();
|
||||
}
|
||||
|
||||
class QMacMimeUrl : public QMacMime
|
||||
class QMacMimeUrl : public QUtiMimeConverter
|
||||
{
|
||||
public:
|
||||
QString utiForMime(const QString &mime) const override;
|
||||
@ -658,7 +659,7 @@ QList<QByteArray> QMacMimeUrl::convertFromMime(const QString &mime,
|
||||
return ret;
|
||||
}
|
||||
|
||||
class QMacMimeVCard : public QMacMime
|
||||
class QMacMimeVCard : public QUtiMimeConverter
|
||||
{
|
||||
public:
|
||||
QString utiForMime(const QString &mime) const override;
|
||||
@ -711,7 +712,7 @@ QList<QByteArray> QMacMimeVCard::convertFromMime(const QString &mime,
|
||||
extern QImage qt_mac_toQImage(CGImageRef image);
|
||||
extern CGImageRef qt_mac_toCGImage(const QImage &qImage);
|
||||
|
||||
class QMacMimeTiff : public QMacMime
|
||||
class QMacMimeTiff : public QUtiMimeConverter
|
||||
{
|
||||
public:
|
||||
QString utiForMime(const QString &mime) const override;
|
@ -1,19 +1,19 @@
|
||||
// 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
|
||||
|
||||
#include "qwindowsmime_p.h"
|
||||
#include "qwindowsmimeconverter.h"
|
||||
|
||||
#include <QtCore/qt_windows.h>
|
||||
|
||||
#include <QtGui/private/qguiapplication_p.h>
|
||||
#include <QtGui/qpa/qplatformintegration.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
using namespace QNativeInterface::Private;
|
||||
|
||||
/*!
|
||||
\class QWindowsMime
|
||||
\brief The QWindowsMime class maps open-standard MIME to Window Clipboard formats.
|
||||
\internal
|
||||
\class QWindowsMimeConverter
|
||||
\brief The QWindowsMimeConverter class maps open-standard MIME to Window Clipboard formats.
|
||||
\inmodule QtGui
|
||||
|
||||
Qt's drag-and-drop and clipboard facilities use the MIME standard.
|
||||
On X11, this maps trivially to the Xdnd protocol, but on Windows
|
||||
@ -21,8 +21,8 @@ using namespace QNativeInterface::Private;
|
||||
formats, others use arbitrary non-standardized naming conventions,
|
||||
or unnamed built-in formats of Windows.
|
||||
|
||||
By instantiating subclasses of QWindowsMime that provide conversions
|
||||
between Windows Clipboard and MIME formats, you can convert
|
||||
By instantiating subclasses of QWindowsMimeConverter that provide
|
||||
conversions between Windows Clipboard and MIME formats, you can convert
|
||||
proprietary clipboard formats to MIME formats.
|
||||
|
||||
Qt has predefined support for the following Windows Clipboard formats:
|
||||
@ -46,14 +46,11 @@ using namespace QNativeInterface::Private;
|
||||
|
||||
You can check if a MIME type is convertible using canConvertFromMime() and
|
||||
can perform conversions with convertToMime() and convertFromMime().
|
||||
|
||||
\sa QWindowsMimeRegistry
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
\fn bool QWindowsMime::canConvertFromMime(const FORMATETC &formatetc, const QMimeData *mimeData) const
|
||||
\internal
|
||||
\fn bool QWindowsMimeConverter::canConvertFromMime(const FORMATETC &formatetc, const QMimeData *mimeData) const
|
||||
|
||||
Returns \c true if the converter can convert from the \a mimeData to
|
||||
the format specified in \a formatetc.
|
||||
@ -62,8 +59,7 @@ using namespace QNativeInterface::Private;
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn bool QWindowsMime::canConvertToMime(const QString &mimeType, IDataObject *pDataObj) const
|
||||
\internal
|
||||
\fn bool QWindowsMimeConverter::canConvertToMime(const QString &mimeType, IDataObject *pDataObj) const
|
||||
|
||||
Returns \c true if the converter can convert to the \a mimeType from
|
||||
the available formats in \a pDataObj.
|
||||
@ -72,8 +68,7 @@ using namespace QNativeInterface::Private;
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QString QWindowsMime::mimeForFormat(const FORMATETC &formatetc) const
|
||||
\internal
|
||||
\fn QString QWindowsMimeConverter::mimeForFormat(const FORMATETC &formatetc) const
|
||||
|
||||
Returns the mime type that will be created form the format specified
|
||||
in \a formatetc, or an empty string if this converter does not support
|
||||
@ -83,8 +78,7 @@ using namespace QNativeInterface::Private;
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QList<FORMATETC> QWindowsMime::formatsForMime(const QString &mimeType, const QMimeData *mimeData) const
|
||||
\internal
|
||||
\fn QList<FORMATETC> QWindowsMimeConverter::formatsForMime(const QString &mimeType, const QMimeData *mimeData) const
|
||||
|
||||
Returns a QList of FORMATETC structures representing the different windows clipboard
|
||||
formats that can be provided for the \a mimeType from the \a mimeData.
|
||||
@ -93,9 +87,8 @@ using namespace QNativeInterface::Private;
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QVariant QWindowsMime::convertToMime(const QString &mimeType, IDataObject *pDataObj,
|
||||
\fn QVariant QWindowsMimeConverter::convertToMime(const QString &mimeType, IDataObject *pDataObj,
|
||||
QMetaType preferredType) const
|
||||
\internal
|
||||
|
||||
Returns a QVariant containing the converted data for \a mimeType from \a pDataObj.
|
||||
If possible the QVariant should be of the \a preferredType to avoid needless conversions.
|
||||
@ -104,8 +97,7 @@ using namespace QNativeInterface::Private;
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn bool QWindowsMime::convertFromMime(const FORMATETC &formatetc, const QMimeData *mimeData, STGMEDIUM * pmedium) const
|
||||
\internal
|
||||
\fn bool QWindowsMimeConverter::convertFromMime(const FORMATETC &formatetc, const QMimeData *mimeData, STGMEDIUM * pmedium) const
|
||||
|
||||
Convert the \a mimeData to the format specified in \a formatetc.
|
||||
The converted data should then be placed in \a pmedium structure.
|
||||
@ -116,39 +108,42 @@ using namespace QNativeInterface::Private;
|
||||
*/
|
||||
|
||||
/*!
|
||||
Constructs a QWindowsMime instance.
|
||||
Constructs a QWindowsMimeConverter instance.
|
||||
|
||||
The instance is automatically registered, and will be called to convert data during
|
||||
clipboard or drag'n'drop operations.
|
||||
*/
|
||||
QWindowsMime::QWindowsMime()
|
||||
QWindowsMimeConverter::QWindowsMimeConverter()
|
||||
{
|
||||
using QWindowsApplication = QNativeInterface::Private::QWindowsApplication;
|
||||
auto nativeWindowsApp = dynamic_cast<QWindowsApplication *>(QGuiApplicationPrivate::platformIntegration());
|
||||
Q_ASSERT(nativeWindowsApp);
|
||||
nativeWindowsApp->registerMime(this);
|
||||
}
|
||||
|
||||
/*!
|
||||
Constructs a QWindowsMime instance.
|
||||
Constructs a QWindowsMimeConverter instance.
|
||||
|
||||
The instance is automatically unregistered.
|
||||
*/
|
||||
QWindowsMime::~QWindowsMime()
|
||||
QWindowsMimeConverter::~QWindowsMimeConverter()
|
||||
{
|
||||
using QWindowsApplication = QNativeInterface::Private::QWindowsApplication;
|
||||
auto nativeWindowsApp = dynamic_cast<QWindowsApplication *>(QGuiApplicationPrivate::platformIntegration());
|
||||
Q_ASSERT(nativeWindowsApp);
|
||||
nativeWindowsApp->unregisterMime(this);
|
||||
}
|
||||
|
||||
/*!
|
||||
Registers the MIME type \a mime, and returns an ID number
|
||||
Registers the MIME type \a mimeType, and returns an ID number
|
||||
identifying the format on Windows.
|
||||
|
||||
A mime type \c {application/x-qt-windows-mime;value="WindowsType"} will be
|
||||
registered as the clipboard format for \c WindowsType.
|
||||
*/
|
||||
int QWindowsMime::registerMimeType(const QString &mimeType)
|
||||
int QWindowsMimeConverter::registerMimeType(const QString &mimeType)
|
||||
{
|
||||
using QWindowsApplication = QNativeInterface::Private::QWindowsApplication;
|
||||
auto nativeWindowsApp = dynamic_cast<QWindowsApplication *>(QGuiApplicationPrivate::platformIntegration());
|
||||
Q_ASSERT(nativeWindowsApp);
|
||||
return nativeWindowsApp->registerMimeType(mimeType);
|
@ -1,37 +1,27 @@
|
||||
// Copyright (C) 2020 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 QWINDOWSMIME_P_H
|
||||
#define QWINDOWSMIME_P_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 <QtCore/qt_windows.h>
|
||||
#include <QtCore/qvariant.h>
|
||||
#ifndef QWINDOWSMIMECONVERTER_P_H
|
||||
#define QWINDOWSMIMECONVERTER_P_H
|
||||
|
||||
#include <QtGui/qtguiglobal.h>
|
||||
#include <QtCore/private/qglobal_p.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QMetaType;
|
||||
class QMimeData;
|
||||
class QVariant;
|
||||
struct tagFORMATETC;
|
||||
using FORMATETC = tagFORMATETC;
|
||||
struct tagSTGMEDIUM;
|
||||
using STGMEDIUM = tagSTGMEDIUM;
|
||||
struct IDataObject;
|
||||
|
||||
namespace QNativeInterface::Private {
|
||||
|
||||
class Q_GUI_EXPORT QWindowsMime
|
||||
class Q_GUI_EXPORT QWindowsMimeConverter
|
||||
{
|
||||
public:
|
||||
QWindowsMime();
|
||||
virtual ~QWindowsMime();
|
||||
QWindowsMimeConverter();
|
||||
virtual ~QWindowsMimeConverter();
|
||||
|
||||
static int registerMimeType(const QString &mimeType);
|
||||
|
||||
@ -46,8 +36,6 @@ public:
|
||||
virtual QString mimeForFormat(const FORMATETC &formatetc) const = 0;
|
||||
};
|
||||
|
||||
} // QNativeInterface::Private
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QWINDOWSMIME_P_H
|
||||
#endif // QWINDOWSMIMECONVERTER_H
|
@ -3,7 +3,6 @@
|
||||
|
||||
#include <QtGui/qopenglcontext.h>
|
||||
#include <QtGui/private/qguiapplication_p.h>
|
||||
#include <QtGui/private/qwindowsmime_p.h>
|
||||
#include <qpa/qplatformopenglcontext.h>
|
||||
#include <qpa/qplatformintegration.h>
|
||||
#include <qpa/qplatformwindow.h>
|
||||
@ -218,21 +217,21 @@ QT_DEFINE_PRIVATE_NATIVE_INTERFACE(QWindowsScreen);
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn bool QNativeInterface::Private::QWindowsApplication::registerMime(QWindowsMime *mime)
|
||||
\fn bool QNativeInterface::Private::QWindowsApplication::registerMime(QWindowsMimeConverter *mime)
|
||||
\internal
|
||||
|
||||
Registers the converter \a mime to the system.
|
||||
|
||||
\sa QNativeInterface::Private::QWindowsMime, unregisterMime()
|
||||
\sa QWindowsMimeConverter, unregisterMime()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QNativeInterface::Private::QWindowsApplication::unregisterMime(QWindowsMime *mime)
|
||||
\fn void QNativeInterface::Private::QWindowsApplication::unregisterMime(QWindowsMimeConverter *mime)
|
||||
\internal
|
||||
|
||||
Unregisters the converter \a mime from the system.
|
||||
|
||||
\sa QNativeInterface::Private::QWindowsMime, registerMime()
|
||||
\sa QWindowsMimeConverter, registerMime()
|
||||
*/
|
||||
|
||||
/*!
|
||||
|
@ -3,15 +3,15 @@
|
||||
|
||||
#include "qcocoaclipboard.h"
|
||||
|
||||
#include <QtGui/private/qmacmime_p.h>
|
||||
#include <QtGui/qutimimeconverter.h>
|
||||
|
||||
#ifndef QT_NO_CLIPBOARD
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QCocoaClipboard::QCocoaClipboard()
|
||||
:m_clipboard(new QMacPasteboard(kPasteboardClipboard, QMacMime::HandlerScope::Clipboard))
|
||||
,m_find(new QMacPasteboard(kPasteboardFind, QMacMime::HandlerScope::Clipboard))
|
||||
:m_clipboard(new QMacPasteboard(kPasteboardClipboard, QUtiMimeConverter::HandlerScope::Clipboard))
|
||||
,m_find(new QMacPasteboard(kPasteboardFind, QUtiMimeConverter::HandlerScope::Clipboard))
|
||||
{
|
||||
connect(qGuiApp, &QGuiApplication::applicationStateChanged, this, &QCocoaClipboard::handleApplicationStateChanged);
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include "qmacclipboard.h"
|
||||
#include "qcocoahelpers.h"
|
||||
#include <QtGui/private/qcoregraphics_p.h>
|
||||
#include <QtGui/private/qmacmime_p.h>
|
||||
#include <QtGui/qutimimeconverter.h>
|
||||
#include <QtCore/qsysinfo.h>
|
||||
#include <QtCore/private/qcore_mac_p.h>
|
||||
|
||||
@ -98,7 +98,7 @@ Qt::DropAction QCocoaDrag::drag(QDrag *o)
|
||||
m_drag = o;
|
||||
m_executed_drop_action = Qt::IgnoreAction;
|
||||
|
||||
QMacPasteboard dragBoard(CFStringRef(NSPasteboardNameDrag), QMacMime::HandlerScope::DnD);
|
||||
QMacPasteboard dragBoard(CFStringRef(NSPasteboardNameDrag), QUtiMimeConverter::HandlerScope::DnD);
|
||||
m_drag->mimeData()->setData("application/x-qt-mime-type-name"_L1, QByteArray("dummy"));
|
||||
dragBoard.setMimeData(m_drag->mimeData(), QMacPasteboard::LazyRequest);
|
||||
|
||||
@ -305,7 +305,7 @@ QStringList QCocoaDropData::formats_sys() const
|
||||
qDebug("DnD: Cannot get PasteBoard!");
|
||||
return formats;
|
||||
}
|
||||
formats = QMacPasteboard(board, QMacMime::HandlerScope::DnD).formats();
|
||||
formats = QMacPasteboard(board, QUtiMimeConverter::HandlerScope::DnD).formats();
|
||||
return formats;
|
||||
}
|
||||
|
||||
@ -317,7 +317,7 @@ QVariant QCocoaDropData::retrieveData_sys(const QString &mimeType, QMetaType) co
|
||||
qDebug("DnD: Cannot get PasteBoard!");
|
||||
return data;
|
||||
}
|
||||
data = QMacPasteboard(board, QMacMime::HandlerScope::DnD).retrieveData(mimeType);
|
||||
data = QMacPasteboard(board, QUtiMimeConverter::HandlerScope::DnD).retrieveData(mimeType);
|
||||
CFRelease(board);
|
||||
return data;
|
||||
}
|
||||
@ -330,7 +330,7 @@ bool QCocoaDropData::hasFormat_sys(const QString &mimeType) const
|
||||
qDebug("DnD: Cannot get PasteBoard!");
|
||||
return has;
|
||||
}
|
||||
has = QMacPasteboard(board, QMacMime::HandlerScope::DnD).hasFormat(mimeType);
|
||||
has = QMacPasteboard(board, QUtiMimeConverter::HandlerScope::DnD).hasFormat(mimeType);
|
||||
CFRelease(board);
|
||||
return has;
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include <AppKit/AppKit.h>
|
||||
|
||||
#include "qcocoamimetypes.h"
|
||||
#include <QtGui/private/qmacmime_p.h>
|
||||
#include <QtGui/qutimimeconverter.h>
|
||||
#include "qcocoahelpers.h"
|
||||
#include <QtGui/private/qcoregraphics_p.h>
|
||||
|
||||
@ -12,7 +12,7 @@ QT_BEGIN_NAMESPACE
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
class QMacMimeTraditionalMacPlainText : public QMacMime {
|
||||
class QMacMimeTraditionalMacPlainText : public QUtiMimeConverter {
|
||||
public:
|
||||
QString utiForMime(const QString &mime) const override;
|
||||
QString mimeForUti(const QString &uti) const override;
|
||||
|
@ -5,13 +5,13 @@
|
||||
#define QMACCLIPBOARD_H
|
||||
|
||||
#include <QtGui>
|
||||
#include <QtGui/private/qmacmime_p.h>
|
||||
#include <QtGui/qutimimeconverter.h>
|
||||
|
||||
#include <ApplicationServices/ApplicationServices.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QMacMime;
|
||||
class QUtiMimeConverter;
|
||||
|
||||
class QMacPasteboard
|
||||
{
|
||||
@ -21,12 +21,12 @@ private:
|
||||
struct Promise {
|
||||
Promise() : itemId(0), converter(nullptr) { }
|
||||
|
||||
static Promise eagerPromise(int itemId, const QMacMime *c, const QString &m, QMimeData *d, int o = 0);
|
||||
static Promise lazyPromise(int itemId, const QMacMime *c, const QString &m, QMimeData *d, int o = 0);
|
||||
Promise(int itemId, const QMacMime *c, const QString &m, QMimeData *md, int o, DataRequestType drt);
|
||||
static Promise eagerPromise(int itemId, const QUtiMimeConverter *c, const QString &m, QMimeData *d, int o = 0);
|
||||
static Promise lazyPromise(int itemId, const QUtiMimeConverter *c, const QString &m, QMimeData *d, int o = 0);
|
||||
Promise(int itemId, const QUtiMimeConverter *c, const QString &m, QMimeData *md, int o, DataRequestType drt);
|
||||
|
||||
int itemId, offset;
|
||||
const QMacMime *converter;
|
||||
const QUtiMimeConverter *converter;
|
||||
QString mime;
|
||||
QPointer<QMimeData> mimeData;
|
||||
QVariant variantData;
|
||||
@ -41,16 +41,16 @@ private:
|
||||
QList<Promise> promises;
|
||||
|
||||
PasteboardRef paste;
|
||||
const QMacMime::HandlerScope scope;
|
||||
const QUtiMimeConverter::HandlerScope scope;
|
||||
mutable QPointer<QMimeData> mime;
|
||||
mutable bool mac_mime_source;
|
||||
bool resolvingBeforeDestruction;
|
||||
static OSStatus promiseKeeper(PasteboardRef, PasteboardItemID, CFStringRef, void *);
|
||||
void clear_helper();
|
||||
public:
|
||||
QMacPasteboard(PasteboardRef p, QMacMime::HandlerScope scope = QMacMime::HandlerScope::All);
|
||||
QMacPasteboard(QMacMime::HandlerScope scope);
|
||||
QMacPasteboard(CFStringRef name=nullptr, QMacMime::HandlerScope scope = QMacMime::HandlerScope::All);
|
||||
QMacPasteboard(PasteboardRef p, QUtiMimeConverter::HandlerScope scope = QUtiMimeConverter::HandlerScope::All);
|
||||
QMacPasteboard(QUtiMimeConverter::HandlerScope scope);
|
||||
QMacPasteboard(CFStringRef name=nullptr, QUtiMimeConverter::HandlerScope scope = QUtiMimeConverter::HandlerScope::All);
|
||||
~QMacPasteboard();
|
||||
|
||||
bool hasUti(const QString &uti) const;
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
#include "qmacclipboard.h"
|
||||
#include <QtGui/private/qmacmimeregistry_p.h>
|
||||
#include <QtGui/private/qmacmime_p.h>
|
||||
#include <QtGui/qutimimeconverter.h>
|
||||
#include <QtGui/qclipboard.h>
|
||||
#include <QtGui/qguiapplication.h>
|
||||
#include <QtGui/qbitmap.h>
|
||||
@ -54,7 +54,7 @@ private:
|
||||
QMacMimeData();
|
||||
};
|
||||
|
||||
QMacPasteboard::Promise::Promise(int itemId, const QMacMime *c, const QString &m, QMimeData *md, int o, DataRequestType drt)
|
||||
QMacPasteboard::Promise::Promise(int itemId, const QUtiMimeConverter *c, const QString &m, QMimeData *md, int o, DataRequestType drt)
|
||||
: itemId(itemId), offset(o), converter(c), mime(m), dataRequestType(drt)
|
||||
{
|
||||
// Request the data from the application immediately for eager requests.
|
||||
@ -69,7 +69,7 @@ QMacPasteboard::Promise::Promise(int itemId, const QMacMime *c, const QString &m
|
||||
}
|
||||
}
|
||||
|
||||
QMacPasteboard::QMacPasteboard(PasteboardRef p, QMacMime::HandlerScope scope)
|
||||
QMacPasteboard::QMacPasteboard(PasteboardRef p, QUtiMimeConverter::HandlerScope scope)
|
||||
: scope(scope)
|
||||
{
|
||||
mac_mime_source = false;
|
||||
@ -78,7 +78,7 @@ QMacPasteboard::QMacPasteboard(PasteboardRef p, QMacMime::HandlerScope scope)
|
||||
resolvingBeforeDestruction = false;
|
||||
}
|
||||
|
||||
QMacPasteboard::QMacPasteboard(QMacMime::HandlerScope scope)
|
||||
QMacPasteboard::QMacPasteboard(QUtiMimeConverter::HandlerScope scope)
|
||||
: scope(scope)
|
||||
{
|
||||
mac_mime_source = false;
|
||||
@ -91,7 +91,7 @@ QMacPasteboard::QMacPasteboard(QMacMime::HandlerScope scope)
|
||||
resolvingBeforeDestruction = false;
|
||||
}
|
||||
|
||||
QMacPasteboard::QMacPasteboard(CFStringRef name, QMacMime::HandlerScope scope)
|
||||
QMacPasteboard::QMacPasteboard(CFStringRef name, QUtiMimeConverter::HandlerScope scope)
|
||||
: scope(scope)
|
||||
{
|
||||
mac_mime_source = false;
|
||||
@ -111,7 +111,7 @@ QMacPasteboard::~QMacPasteboard()
|
||||
Commit all promises for paste when shutting down,
|
||||
unless we are the stack-allocated clipboard used by QCocoaDrag.
|
||||
*/
|
||||
if (scope == QMacMime::HandlerScope::DnD)
|
||||
if (scope == QUtiMimeConverter::HandlerScope::DnD)
|
||||
resolvingBeforeDestruction = true;
|
||||
PasteboardResolvePromises(paste);
|
||||
if (paste)
|
||||
@ -130,16 +130,16 @@ OSStatus QMacPasteboard::promiseKeeper(PasteboardRef paste, PasteboardItemID id,
|
||||
const long promise_id = (long)id;
|
||||
|
||||
// Find the kept promise
|
||||
const QList<QMacMime*> availableConverters = QMacMimeRegistry::all(QMacMime::HandlerScope::All);
|
||||
const QList<QUtiMimeConverter*> availableConverters = QMacMimeRegistry::all(QUtiMimeConverter::HandlerScope::All);
|
||||
const QString utiAsQString = QString::fromCFString(uti);
|
||||
QMacPasteboard::Promise promise;
|
||||
for (int i = 0; i < qpaste->promises.size(); i++){
|
||||
const QMacPasteboard::Promise tmp = qpaste->promises[i];
|
||||
if (!availableConverters.contains(tmp.converter)) {
|
||||
// promise.converter is a pointer initialized by the value found
|
||||
// in QMacMime's global list of QMacMimes.
|
||||
// We add pointers to this list in QMacMime's ctor;
|
||||
// we remove these pointers in QMacMime's dtor.
|
||||
// in QUtiMimeConverter's global list of QMacMimes.
|
||||
// We add pointers to this list in QUtiMimeConverter's ctor;
|
||||
// we remove these pointers in QUtiMimeConverter's dtor.
|
||||
// If tmp.converter was not found in this list, we probably have a
|
||||
// dangling pointer so let's skip it.
|
||||
continue;
|
||||
@ -258,7 +258,7 @@ void QMacPasteboard::setMimeData(QMimeData *mime_src, DataRequestType dataReques
|
||||
delete mime;
|
||||
mime = mime_src;
|
||||
|
||||
const QList<QMacMime*> availableConverters = QMacMimeRegistry::all(scope);
|
||||
const QList<QUtiMimeConverter*> availableConverters = QMacMimeRegistry::all(scope);
|
||||
if (mime != nullptr) {
|
||||
clear_helper();
|
||||
QStringList formats = mime_src->formats();
|
||||
@ -386,7 +386,7 @@ QVariant QMacPasteboard::retrieveData(const QString &format) const
|
||||
return QByteArray();
|
||||
|
||||
qCDebug(lcQpaClipboard, "Pasteboard: retrieveData [%s]", qPrintable(format));
|
||||
const QList<QMacMime *> availableConverters = QMacMimeRegistry::all(scope);
|
||||
const QList<QUtiMimeConverter *> availableConverters = QMacMimeRegistry::all(scope);
|
||||
for (const auto *c : availableConverters) {
|
||||
const QString c_uti = c->utiForMime(format);
|
||||
if (!c_uti.isEmpty()) {
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
#include <QtCore/qurl.h>
|
||||
#include <QtGui/private/qmacmimeregistry_p.h>
|
||||
#include <QtGui/private/qmacmime_p.h>
|
||||
#include <QtGui/qutimimeconverter.h>
|
||||
#include <QtCore/QMimeData>
|
||||
#include <QtGui/QGuiApplication>
|
||||
|
||||
@ -117,7 +117,7 @@ QStringList QIOSMimeData::formats() const
|
||||
|
||||
for (NSUInteger i = 0; i < [pasteboardTypes count]; ++i) {
|
||||
const QString uti = QString::fromNSString([pasteboardTypes objectAtIndex:i]);
|
||||
const QString mimeType = QMacMimeRegistry::flavorToMime(QMacMime::HandlerScope::All, uti);
|
||||
const QString mimeType = QMacMimeRegistry::flavorToMime(QUtiMimeConverter::HandlerScope::All, uti);
|
||||
if (!mimeType.isEmpty() && !foundMimeTypes.contains(mimeType))
|
||||
foundMimeTypes << mimeType;
|
||||
}
|
||||
@ -130,8 +130,8 @@ QVariant QIOSMimeData::retrieveData(const QString &mimeType, QMetaType) const
|
||||
UIPasteboard *pb = [UIPasteboard pasteboardWithQClipboardMode:m_mode];
|
||||
NSArray<NSString *> *pasteboardTypes = [pb pasteboardTypes];
|
||||
|
||||
const auto converters = QMacMimeRegistry::all(QMacMime::HandlerScope::All);
|
||||
for (QMacMime *converter : converters) {
|
||||
const auto converters = QMacMimeRegistry::all(QUtiMimeConverter::HandlerScope::All);
|
||||
for (QUtiMimeConverter *converter : converters) {
|
||||
for (NSUInteger i = 0; i < [pasteboardTypes count]; ++i) {
|
||||
NSString *availableUtiNSString = [pasteboardTypes objectAtIndex:i];
|
||||
const QString availableUti = QString::fromNSString(availableUtiNSString);
|
||||
@ -183,8 +183,8 @@ void QIOSClipboard::setMimeData(QMimeData *mimeData, QClipboard::Mode mode)
|
||||
|
||||
const auto formats = mimeData->formats();
|
||||
for (const QString &mimeType : formats) {
|
||||
const auto converters = QMacMimeRegistry::all(QMacMime::HandlerScope::All);
|
||||
for (const QMacMime *converter : converters) {
|
||||
const auto converters = QMacMimeRegistry::all(QUtiMimeConverter::HandlerScope::All);
|
||||
for (const QUtiMimeConverter *converter : converters) {
|
||||
const QString uti = converter->utiForMime(mimeType);
|
||||
if (uti.isEmpty())
|
||||
continue;
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
#include <QtGui/private/qcoretextfontdatabase_p.h>
|
||||
#include <QtGui/private/qmacmimeregistry_p.h>
|
||||
#include <QtGui/private/qmacmime_p.h>
|
||||
#include <QtGui/qutimimeconverter.h>
|
||||
#include <QDir>
|
||||
#include <QOperatingSystemVersion>
|
||||
|
||||
|
@ -82,13 +82,13 @@ void QWindowsApplication::setDarkModeHandling(QWindowsApplication::DarkModeHandl
|
||||
m_darkModeHandling = handling;
|
||||
}
|
||||
|
||||
void QWindowsApplication::registerMime(QNativeInterface::Private::QWindowsMime *mime)
|
||||
void QWindowsApplication::registerMime(QWindowsMimeConverter *mime)
|
||||
{
|
||||
if (auto ctx = QWindowsContext::instance())
|
||||
ctx->mimeConverter().registerMime(mime);
|
||||
}
|
||||
|
||||
void QWindowsApplication::unregisterMime(QNativeInterface::Private::QWindowsMime *mime)
|
||||
void QWindowsApplication::unregisterMime(QWindowsMimeConverter *mime)
|
||||
{
|
||||
if (auto ctx = QWindowsContext::instance())
|
||||
ctx->mimeConverter().unregisterMime(mime);
|
||||
|
@ -28,8 +28,8 @@ public:
|
||||
DarkModeHandling darkModeHandling() const override;
|
||||
void setDarkModeHandling(DarkModeHandling handling) override;
|
||||
|
||||
void registerMime(QNativeInterface::Private::QWindowsMime *mime) override;
|
||||
void unregisterMime(QNativeInterface::Private::QWindowsMime *mime) override;
|
||||
void registerMime(QWindowsMimeConverter *mime) override;
|
||||
void unregisterMime(QWindowsMimeConverter *mime) override;
|
||||
|
||||
int registerMimeType(const QString &mime) override;
|
||||
|
||||
|
@ -22,9 +22,9 @@
|
||||
|
||||
The base class introduces new virtuals to obtain and release
|
||||
the instances IDataObject from the clipboard or Drag and Drop and
|
||||
does conversion using QWindowsMime classes.
|
||||
does conversion using QWindowsMimeConverter classes.
|
||||
|
||||
\sa QInternalMimeData, QWindowsMime, QWindowsMimeRegistry
|
||||
\sa QInternalMimeData, QWindowsMimeConverter, QWindowsMimeRegistry
|
||||
\internal
|
||||
*/
|
||||
|
||||
|
@ -333,7 +333,7 @@ QDebug operator<<(QDebug d, IDataObject *dataObj)
|
||||
}
|
||||
#endif // !QT_NO_DEBUG_STREAM
|
||||
|
||||
class QWindowsMimeText : public QNativeInterface::Private::QWindowsMime
|
||||
class QWindowsMimeText : public QWindowsMimeConverter
|
||||
{
|
||||
public:
|
||||
bool canConvertToMime(const QString &mimeType, IDataObject *pDataObj) const override;
|
||||
@ -489,7 +489,7 @@ QVariant QWindowsMimeText::convertToMime(const QString &mime, LPDATAOBJECT pData
|
||||
return ret;
|
||||
}
|
||||
|
||||
class QWindowsMimeURI : public QNativeInterface::Private::QWindowsMime
|
||||
class QWindowsMimeURI : public QWindowsMimeConverter
|
||||
{
|
||||
public:
|
||||
QWindowsMimeURI();
|
||||
@ -655,7 +655,7 @@ QVariant QWindowsMimeURI::convertToMime(const QString &mimeType, LPDATAOBJECT pD
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
class QWindowsMimeHtml : public QNativeInterface::Private::QWindowsMime
|
||||
class QWindowsMimeHtml : public QWindowsMimeConverter
|
||||
{
|
||||
public:
|
||||
QWindowsMimeHtml();
|
||||
@ -793,7 +793,7 @@ bool QWindowsMimeHtml::convertFromMime(const FORMATETC &formatetc, const QMimeDa
|
||||
|
||||
|
||||
#ifndef QT_NO_IMAGEFORMAT_BMP
|
||||
class QWindowsMimeImage : public QNativeInterface::Private::QWindowsMime
|
||||
class QWindowsMimeImage : public QWindowsMimeConverter
|
||||
{
|
||||
public:
|
||||
QWindowsMimeImage();
|
||||
@ -953,7 +953,7 @@ QVariant QWindowsMimeImage::convertToMime(const QString &mimeType, IDataObject *
|
||||
}
|
||||
#endif
|
||||
|
||||
class QBuiltInMimes : public QNativeInterface::Private::QWindowsMime
|
||||
class QBuiltInMimes : public QWindowsMimeConverter
|
||||
{
|
||||
public:
|
||||
QBuiltInMimes();
|
||||
@ -974,7 +974,7 @@ private:
|
||||
};
|
||||
|
||||
QBuiltInMimes::QBuiltInMimes()
|
||||
: QWindowsMime()
|
||||
: QWindowsMimeConverter()
|
||||
{
|
||||
outFormats.insert(registerMimeType(u"application/x-color"_s), u"application/x-color"_s);
|
||||
inFormats.insert(registerMimeType(u"application/x-color"_s), u"application/x-color"_s);
|
||||
@ -1074,7 +1074,7 @@ QString QBuiltInMimes::mimeForFormat(const FORMATETC &formatetc) const
|
||||
}
|
||||
|
||||
|
||||
class QLastResortMimes : public QNativeInterface::Private::QWindowsMime
|
||||
class QLastResortMimes : public QWindowsMimeConverter
|
||||
{
|
||||
public:
|
||||
|
||||
@ -1265,9 +1265,9 @@ QString QLastResortMimes::mimeForFormat(const FORMATETC &formatetc) const
|
||||
|
||||
/*!
|
||||
\class QWindowsMimeRegistry
|
||||
\brief Manages the list of QWindowsMime instances.
|
||||
\brief Manages the list of QWindowsMimeConverter instances.
|
||||
\internal
|
||||
\sa QWindowsMime
|
||||
\sa QWindowsMimeConverter
|
||||
*/
|
||||
|
||||
QWindowsMimeRegistry::QWindowsMimeRegistry() = default;
|
||||
@ -1277,7 +1277,7 @@ QWindowsMimeRegistry::~QWindowsMimeRegistry()
|
||||
qDeleteAll(m_mimes.begin(), m_mimes.begin() + m_internalMimeCount);
|
||||
}
|
||||
|
||||
QWindowsMimeRegistry::QWindowsMime *QWindowsMimeRegistry::converterToMime(const QString &mimeType, IDataObject *pDataObj) const
|
||||
QWindowsMimeRegistry::QWindowsMimeConverter *QWindowsMimeRegistry::converterToMime(const QString &mimeType, IDataObject *pDataObj) const
|
||||
{
|
||||
ensureInitialized();
|
||||
for (int i = m_mimes.size()-1; i >= 0; --i) {
|
||||
@ -1289,7 +1289,7 @@ QWindowsMimeRegistry::QWindowsMime *QWindowsMimeRegistry::converterToMime(const
|
||||
|
||||
QStringList QWindowsMimeRegistry::allMimesForFormats(IDataObject *pDataObj) const
|
||||
{
|
||||
qCDebug(lcQpaMime) << "QWindowsMime::allMimesForFormats()";
|
||||
qCDebug(lcQpaMime) << "QWindowsMimeConverter::allMimesForFormats()";
|
||||
ensureInitialized();
|
||||
QStringList formats;
|
||||
LPENUMFORMATETC FAR fmtenum;
|
||||
@ -1316,7 +1316,7 @@ QStringList QWindowsMimeRegistry::allMimesForFormats(IDataObject *pDataObj) cons
|
||||
return formats;
|
||||
}
|
||||
|
||||
QWindowsMimeRegistry::QWindowsMime *QWindowsMimeRegistry::converterFromMime(const FORMATETC &formatetc, const QMimeData *mimeData) const
|
||||
QWindowsMimeRegistry::QWindowsMimeConverter *QWindowsMimeRegistry::converterFromMime(const FORMATETC &formatetc, const QMimeData *mimeData) const
|
||||
{
|
||||
ensureInitialized();
|
||||
qCDebug(lcQpaMime) << __FUNCTION__ << formatetc;
|
||||
@ -1374,7 +1374,7 @@ QVariant QWindowsMimeRegistry::convertToMime(const QStringList &mimeTypes,
|
||||
QString *formatIn /* = 0 */) const
|
||||
{
|
||||
for (const QString &format : mimeTypes) {
|
||||
if (const QWindowsMime *converter = converterToMime(format, pDataObj)) {
|
||||
if (const QWindowsMimeConverter *converter = converterToMime(format, pDataObj)) {
|
||||
if (converter->canConvertToMime(format, pDataObj)) {
|
||||
const QVariant dataV = converter->convertToMime(format, pDataObj, preferredType);
|
||||
if (dataV.isValid()) {
|
||||
@ -1391,7 +1391,7 @@ QVariant QWindowsMimeRegistry::convertToMime(const QStringList &mimeTypes,
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
void QWindowsMimeRegistry::registerMime(QWindowsMime *mime)
|
||||
void QWindowsMimeRegistry::registerMime(QWindowsMimeConverter *mime)
|
||||
{
|
||||
ensureInitialized();
|
||||
m_mimes.append(mime);
|
||||
|
@ -4,10 +4,10 @@
|
||||
#ifndef QWINDOWSMIMEREGISTRY_H
|
||||
#define QWINDOWSMIMEREGISTRY_H
|
||||
|
||||
#include <QtGui/private/qwindowsmime_p.h>
|
||||
|
||||
#include <QtCore/qt_windows.h>
|
||||
|
||||
#include <QtGui/qwindowsmimeconverter.h>
|
||||
#include <QtCore/qlist.h>
|
||||
#include <QtCore/qvariant.h>
|
||||
|
||||
@ -20,22 +20,22 @@ class QWindowsMimeRegistry
|
||||
{
|
||||
Q_DISABLE_COPY_MOVE(QWindowsMimeRegistry)
|
||||
public:
|
||||
using QWindowsMime = QNativeInterface::Private::QWindowsMime;
|
||||
using QWindowsMimeConverter = QWindowsMimeConverter;
|
||||
|
||||
QWindowsMimeRegistry();
|
||||
~QWindowsMimeRegistry();
|
||||
|
||||
QWindowsMime *converterToMime(const QString &mimeType, IDataObject *pDataObj) const;
|
||||
QWindowsMimeConverter *converterToMime(const QString &mimeType, IDataObject *pDataObj) const;
|
||||
QStringList allMimesForFormats(IDataObject *pDataObj) const;
|
||||
QWindowsMime *converterFromMime(const FORMATETC &formatetc, const QMimeData *mimeData) const;
|
||||
QWindowsMimeConverter *converterFromMime(const FORMATETC &formatetc, const QMimeData *mimeData) const;
|
||||
QList<FORMATETC> allFormatsForMime(const QMimeData *mimeData) const;
|
||||
|
||||
// Convenience.
|
||||
QVariant convertToMime(const QStringList &mimeTypes, IDataObject *pDataObj, QMetaType preferredType,
|
||||
QString *format = nullptr) const;
|
||||
|
||||
void registerMime(QWindowsMime *mime);
|
||||
void unregisterMime(QWindowsMime *mime) { m_mimes.removeOne(mime); }
|
||||
void registerMime(QWindowsMimeConverter *mime);
|
||||
void unregisterMime(QWindowsMimeConverter *mime) { m_mimes.removeOne(mime); }
|
||||
|
||||
static int registerMimeType(const QString &mime);
|
||||
|
||||
@ -44,7 +44,7 @@ public:
|
||||
private:
|
||||
void ensureInitialized() const;
|
||||
|
||||
mutable QList<QWindowsMime *> m_mimes;
|
||||
mutable QList<QWindowsMimeConverter *> m_mimes;
|
||||
mutable int m_internalMimeCount = 0;
|
||||
};
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
# include <QtGui/private/qguiapplication_p.h>
|
||||
# include <QtGui/private/qwindowsmime_p.h>
|
||||
# include <QtGui/qwindowsmimeconverter.h>
|
||||
# include <QtGui/qpa/qplatformintegration.h>
|
||||
#endif
|
||||
|
||||
@ -426,10 +426,10 @@ void tst_QClipboard::clearBeforeSetText()
|
||||
|
||||
# ifdef Q_OS_WIN
|
||||
|
||||
using QWindowsMime = QNativeInterface::Private::QWindowsMime;
|
||||
using QWindowsMimeConverter = QWindowsMimeConverter;
|
||||
using QWindowsApplication = QNativeInterface::Private::QWindowsApplication;
|
||||
|
||||
class TestMime : public QWindowsMime
|
||||
class TestMime : public QWindowsMimeConverter
|
||||
{
|
||||
public:
|
||||
bool canConvertFromMime(const FORMATETC &, const QMimeData *) const override
|
||||
|
Loading…
x
Reference in New Issue
Block a user