From: Enrico Forestieri Date: Fri, 28 Apr 2023 21:34:01 +0000 (+0200) Subject: Re-enable QWindowsMimeMetafile with Qt6 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=17b24cf4;p=features.git Re-enable QWindowsMimeMetafile with Qt6 Qt 6.5.0 has dropped support for the QWindowsMime class in favor of a new QWindowsMimeConverter class. They say: "If you have implementations of QWindowsMime or QMacMime in Qt 5, then those will almost directly translate to the new APIs but require less boiler-plate code to register the converters with Qt." This may be true, but in practice they break binary compatibility with previous versions. If you used the QWindowsMime class until Qt 6.4 by using boiler-plate code to register the converters with Qt, you now need to modify the sources and recompile. Fantastic! --- diff --git a/src/frontends/qt/GuiApplication.cpp b/src/frontends/qt/GuiApplication.cpp index 0fd63a37c8..1b29eec412 100644 --- a/src/frontends/qt/GuiApplication.cpp +++ b/src/frontends/qt/GuiApplication.cpp @@ -130,6 +130,11 @@ #if (QT_VERSION >= 0x050400) #if defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN) #if (QT_VERSION >= 0x060000) +#if (QT_VERSION >= 0x060500) +#include +#define QWINDOWSMIME QWindowsMimeConverter +#define QVARIANTTYPE QMetaType +#else #include #include #include @@ -137,6 +142,7 @@ #define QVARIANTTYPE QMetaType using QWindowsMime = QNativeInterface::Private::QWindowsMime; using QWindowsApplication = QNativeInterface::Private::QWindowsApplication; +#endif #else #include #define QWINDOWSMIME QWinMime @@ -1031,7 +1037,7 @@ struct GuiApplication::Private #if defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN) /// WMF Mime handler for Windows clipboard. wmf_mime_ = new QWindowsMimeMetafile; - #if (QT_VERSION >= 0x060000) + #if (QT_VERSION >= 0x060000 && QT_VERSION < 0x060500) win_app_ = dynamic_cast (QGuiApplicationPrivate::platformIntegration()); win_app_->registerMime(wmf_mime_); @@ -1041,7 +1047,7 @@ struct GuiApplication::Private initKeySequences(&theTopLevelKeymap()); } - #if (QT_VERSION >= 0x060000) + #if (QT_VERSION >= 0x060000 && QT_VERSION < 0x060500) #if defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN) ~Private() { @@ -1120,7 +1126,7 @@ struct GuiApplication::Private #if defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN) /// WMF Mime handler for Windows clipboard. QWindowsMimeMetafile * wmf_mime_; -#if (QT_VERSION >= 0x060000) +#if (QT_VERSION >= 0x060000 && QT_VERSION < 0x060500) QWindowsApplication * win_app_; #endif #endif