mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-21 17:51:03 +00:00
Enable QWindowsMimeMetafile with Qt6
The QWinMime class has been removed in Qt6 but the functionality is still present. However, one has to allow inclusion of private headers and register the mime handling to the QWindowsApplication native interface.
This commit is contained in:
parent
21366155e4
commit
771f30e946
@ -442,6 +442,7 @@ qtHaveModule(gui): QT += gui
|
|||||||
qtHaveModule(svg): QT += svg
|
qtHaveModule(svg): QT += svg
|
||||||
qtHaveModule(svgwidgets): QT += svgwidgets
|
qtHaveModule(svgwidgets): QT += svgwidgets
|
||||||
qtHaveModule(widgets): QT += widgets
|
qtHaveModule(widgets): QT += widgets
|
||||||
|
QT += gui-private
|
||||||
percent.target = %
|
percent.target = %
|
||||||
percent.commands = @echo -n "\$(\$(@))\ "
|
percent.commands = @echo -n "\$(\$(@))\ "
|
||||||
QMAKE_EXTRA_TARGETS += percent
|
QMAKE_EXTRA_TARGETS += percent
|
||||||
|
@ -137,14 +137,22 @@
|
|||||||
|
|
||||||
#if (QT_VERSION < 0x050000) || (QT_VERSION >= 0x050400)
|
#if (QT_VERSION < 0x050000) || (QT_VERSION >= 0x050400)
|
||||||
#if defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN)
|
#if defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN)
|
||||||
#if (QT_VERSION < 0x060000)
|
|
||||||
#if (QT_VERSION < 0x050000)
|
#if (QT_VERSION < 0x050000)
|
||||||
#include <QWindowsMime>
|
#include <QWindowsMime>
|
||||||
#define QWINDOWSMIME QWindowsMime
|
#define QWINDOWSMIME QWindowsMime
|
||||||
|
#define QVARIANTTYPE QVariant::Type
|
||||||
|
#elif (QT_VERSION >= 0x060000)
|
||||||
|
#include <QtGui/private/qguiapplication_p.h>
|
||||||
|
#include <QtGui/private/qwindowsmime_p.h>
|
||||||
|
#include <QtGui/qpa/qplatformintegration.h>
|
||||||
|
#define QWINDOWSMIME QWindowsMime
|
||||||
|
#define QVARIANTTYPE QMetaType
|
||||||
|
using QWindowsMime = QNativeInterface::Private::QWindowsMime;
|
||||||
|
using QWindowsApplication = QNativeInterface::Private::QWindowsApplication;
|
||||||
#else
|
#else
|
||||||
#include <QWinMime>
|
#include <QWinMime>
|
||||||
#define QWINDOWSMIME QWinMime
|
#define QWINDOWSMIME QWinMime
|
||||||
#endif
|
#define QVARIANTTYPE QVariant::Type
|
||||||
#endif
|
#endif
|
||||||
#ifdef Q_CC_GNU
|
#ifdef Q_CC_GNU
|
||||||
#include <wtypes.h>
|
#include <wtypes.h>
|
||||||
@ -812,7 +820,7 @@ public:
|
|||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// Windows specific stuff goes here...
|
// Windows specific stuff goes here...
|
||||||
|
|
||||||
#if (QT_VERSION < 0x050000) || (QT_VERSION >= 0x050400 && QT_VERSION < 0x060000)
|
#if (QT_VERSION < 0x050000) || (QT_VERSION >= 0x050400)
|
||||||
#if defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN)
|
#if defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN)
|
||||||
// QWindowsMimeMetafile can only be compiled on Windows.
|
// QWindowsMimeMetafile can only be compiled on Windows.
|
||||||
|
|
||||||
@ -859,7 +867,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
QVariant convertToMime(QString const & mimetype, IDataObject * pDataObj,
|
QVariant convertToMime(QString const & mimetype, IDataObject * pDataObj,
|
||||||
QVariant::Type /*preferredType*/) const override
|
QVARIANTTYPE /*preferredType*/) const override
|
||||||
{
|
{
|
||||||
QByteArray data;
|
QByteArray data;
|
||||||
if (!canConvertToMime(mimetype, pDataObj))
|
if (!canConvertToMime(mimetype, pDataObj))
|
||||||
@ -978,15 +986,29 @@ struct GuiApplication::Private
|
|||||||
, last_state_(Qt::ApplicationInactive)
|
, last_state_(Qt::ApplicationInactive)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#if (QT_VERSION < 0x050000) || (QT_VERSION >= 0x050400 && QT_VERSION < 0x060000)
|
#if (QT_VERSION < 0x050000) || (QT_VERSION >= 0x050400)
|
||||||
#if defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN)
|
#if defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN)
|
||||||
/// WMF Mime handler for Windows clipboard.
|
/// WMF Mime handler for Windows clipboard.
|
||||||
wmf_mime_ = new QWindowsMimeMetafile;
|
wmf_mime_ = new QWindowsMimeMetafile;
|
||||||
|
#if (QT_VERSION >= 0x060000)
|
||||||
|
win_app_ = dynamic_cast<QWindowsApplication *>
|
||||||
|
(QGuiApplicationPrivate::platformIntegration());
|
||||||
|
win_app_->registerMime(wmf_mime_);
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
initKeySequences(&theTopLevelKeymap());
|
initKeySequences(&theTopLevelKeymap());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if (QT_VERSION >= 0x060000)
|
||||||
|
#if defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN)
|
||||||
|
~Private()
|
||||||
|
{
|
||||||
|
win_app_->unregisterMime(wmf_mime_);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
void initKeySequences(KeyMap * kb)
|
void initKeySequences(KeyMap * kb)
|
||||||
{
|
{
|
||||||
keyseq = KeySequence(kb, kb);
|
keyseq = KeySequence(kb, kb);
|
||||||
@ -1053,10 +1075,13 @@ struct GuiApplication::Private
|
|||||||
QMacPasteboardMimeGraphics mac_pasteboard_mime_;
|
QMacPasteboardMimeGraphics mac_pasteboard_mime_;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (QT_VERSION < 0x050000) || (QT_VERSION >= 0x050400 && QT_VERSION < 0x060000)
|
#if (QT_VERSION < 0x050000) || (QT_VERSION >= 0x050400)
|
||||||
#if defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN)
|
#if defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN)
|
||||||
/// WMF Mime handler for Windows clipboard.
|
/// WMF Mime handler for Windows clipboard.
|
||||||
QWindowsMimeMetafile * wmf_mime_;
|
QWindowsMimeMetafile * wmf_mime_;
|
||||||
|
#if (QT_VERSION >= 0x060000)
|
||||||
|
QWindowsApplication * win_app_;
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user