commit 9126a99e97a23f5045da11dd6b13aa997b23bb44
Author: Enrico Forestieri <for...@lyx.org>
Date:   Fri Dec 26 16:53:31 2014 +0100

    Fix bug #9217: [Qt5] QWindowsMime class not available
    
    The support for QWindowsMime has been reintroduced in Qt 5.4.0.
    The class name has been changed to QWinMime but the interface
    is exactly the same.

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 978e63c..5409746 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -556,6 +556,7 @@ if(LYX_USE_QT MATCHES "QT5")
                        find_package(Qt5MacExtras REQUIRED)
                endif()
                find_package(Qt5X11Extras QUIET)
+               find_package(Qt5WinExtras QUIET)
                set(QTVERSION ${Qt5Core_VERSION})
                macro (qt_use_modules)
                        qt5_use_modules(${ARGN})
diff --git a/config/qt4.m4 b/config/qt4.m4
index bb909f9..10d9546 100644
--- a/config/qt4.m4
+++ b/config/qt4.m4
@@ -201,6 +201,11 @@ AC_DEFUN([QT_DO_PKG_CONFIG],
        if test "x$USE_QT5" != "xno" ; then
                qt_corelibs="Qt5Core"
                qt_guilibs="Qt5Core Qt5Concurrent Qt5Gui Qt5Widgets"
+               lyx_use_winextras=false
+               PKG_CHECK_EXISTS(Qt5WinExtras, [lyx_use_winextras=true], [])
+               if $lyx_use_winextras; then
+                       qt_guilibs="$qt_guilibs Qt5WinExtras"
+               fi
        fi
        PKG_CHECK_MODULES(QT_CORE, $qt_corelibs,,[:])
        if test "$pkg_failed" = "no" ; then
diff --git a/development/cmake/ConfigureChecks.cmake 
b/development/cmake/ConfigureChecks.cmake
index 0290c4d..0d07311 100644
--- a/development/cmake/ConfigureChecks.cmake
+++ b/development/cmake/ConfigureChecks.cmake
@@ -175,6 +175,13 @@ if(LYX_USE_QT MATCHES "QT5")
             "
     QT_USES_X11)
   endif()
+  if (Qt5WinExtras_FOUND)
+    get_target_property(_winextra_prop Qt5::WinExtras IMPORTED_CONFIGURATIONS)
+    get_target_property(_winextra_link_libraries Qt5::WinExtras 
IMPORTED_LOCATION_${_winextra_prop})
+    set(CMAKE_REQUIRED_LIBRARIES ${_winextra_link_libraries})
+    set(CMAKE_REQUIRED_INCLUDES ${Qt5WinExtras_INCLUDE_DIRS})
+    set(CMAKE_REQUIRED_FLAGS ${Qt5WinExtras_EXECUTABLE_COMPILE_FLAGS})
+  endif()
 elseif(LYX_USE_QT MATCHES "QT4")
   set(CMAKE_REQUIRED_LIBRARIES ${QT_QTGUI_LIBRARY})
   set(CMAKE_REQUIRED_INCLUDES ${QT_INCLUDES})
diff --git a/src/frontends/qt4/CMakeLists.txt b/src/frontends/qt4/CMakeLists.txt
index 7203ec7..3af2e86 100644
--- a/src/frontends/qt4/CMakeLists.txt
+++ b/src/frontends/qt4/CMakeLists.txt
@@ -58,7 +58,11 @@ set_target_properties(frontend_qt PROPERTIES FOLDER 
"applications/LyX")
 if(Qt5Core_FOUND AND APPLE)
        qt_use_modules(frontend_qt Core Gui Widgets Concurrent MacExtras)
 else()
-       qt_use_modules(frontend_qt Core Gui Widgets Concurrent)
+       if (Qt5WinExtras_FOUND)
+           qt_use_modules(frontend_qt Core Gui Widgets Concurrent WinExtras)
+       else()
+           qt_use_modules(frontend_qt Core Gui Widgets Concurrent)
+       endif()
 endif()
 target_link_libraries(frontend_qt
        frontends
diff --git a/src/frontends/qt4/GuiApplication.cpp 
b/src/frontends/qt4/GuiApplication.cpp
index 0fbba74..5cf11b7 100644
--- a/src/frontends/qt4/GuiApplication.cpp
+++ b/src/frontends/qt4/GuiApplication.cpp
@@ -124,13 +124,21 @@
 #undef None
 #endif
 
-#ifdef Q_WS_WIN
+#if (QT_VERSION < 0x050000) || (QT_VERSION >= 0x050400)
+#if defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN)
+#if (QT_VERSION < 0x050000)
 #include <QWindowsMime>
+#define QWINDOWSMIME QWindowsMime
+#else
+#include <QWinMime>
+#define QWINDOWSMIME QWinMime
+#endif
 #ifdef Q_CC_GNU
 #include <wtypes.h>
 #endif
 #include <objidl.h>
-#endif // Q_WS_WIN
+#endif
+#endif
 
 #ifdef Q_OS_MAC
 #include <QMacPasteboardMime>
@@ -716,7 +724,8 @@ public:
 ////////////////////////////////////////////////////////////////////////
 // Windows specific stuff goes here...
 
-#ifdef Q_WS_WIN
+#if (QT_VERSION < 0x050000) || (QT_VERSION >= 0x050400)
+#if defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN)
 // QWindowsMimeMetafile can only be compiled on Windows.
 
 static FORMATETC cfFromMime(QString const & mimetype)
@@ -736,7 +745,7 @@ static FORMATETC cfFromMime(QString const & mimetype)
 }
 
 
-class QWindowsMimeMetafile : public QWindowsMime {
+class QWindowsMimeMetafile : public QWINDOWSMIME {
 public:
        QWindowsMimeMetafile() {}
 
@@ -813,7 +822,8 @@ public:
        }
 };
 
-#endif // Q_WS_WIN
+#endif
+#endif
 
 
 /// Allows to check whether ESC was pressed during a long operation
@@ -877,10 +887,12 @@ struct GuiApplication::Private
        Private(): language_model_(0), meta_fake_bit(NoModifier),
                global_menubar_(0)
        {
-       #ifdef Q_WS_WIN
+       #if (QT_VERSION < 0x050000) || (QT_VERSION >= 0x050400)
+       #if defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN)
                /// WMF Mime handler for Windows clipboard.
                wmf_mime_ = new QWindowsMimeMetafile;
        #endif
+       #endif
                initKeySequences(&theTopLevelKeymap());
        }
 
@@ -941,10 +953,12 @@ struct GuiApplication::Private
        QMacPasteboardMimeGraphics mac_pasteboard_mime_;
 #endif
 
-#ifdef Q_WS_WIN
+#if (QT_VERSION < 0x050000) || (QT_VERSION >= 0x050400)
+#if defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN)
        /// WMF Mime handler for Windows clipboard.
        QWindowsMimeMetafile * wmf_mime_;
 #endif
+#endif
 
        /// Allows to check whether ESC was pressed during a long operation
        KeyChecker key_checker_;

Reply via email to