diff --git a/CMakeLists.txt b/CMakeLists.txt index 5e9c7c860b..067b30cf3a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -219,7 +219,7 @@ else() endif() LYX_COMBO(DEBUG_SANITIZE "Use sanitize check" NONE ADDRESS UNSPECIFIED) #LYX_COMBO(USE_FILEDIALOG "Use native or QT file dialog" QT NATIVE) -LYX_COMBO(USE_QT "Use Qt version as frontend" AUTO QT4 QT5 QT6) +LYX_COMBO(USE_QT "Use Qt version as frontend" AUTO QT5 QT6) LYX_COMBO(USE_IPO "Interprocedural optimization" OFF AUTO ON) #LYX_OPTION(3RDPARTY_BUILD "Build 3rdparty libs" OFF ALL) LYX_OPTION(DISABLE_CALLSTACK_PRINTING "do not print a callstack when crashing" OFF ALL) @@ -764,13 +764,10 @@ if(LYX_USE_QT MATCHES "AUTO") set(LYX_USE_QT "QT5" CACHE STRING "Valid qt version" FORCE) message(STATUS "Qt5Core_VERSION = ${Qt5Core_VERSION}") if(Qt5Core_VERSION VERSION_LESS ${min_qt5_version}) - find_package(Qt4 "4.5.0" QUIET) - if(QT4_FOUND) - set(LYX_USE_QT "QT4" CACHE STRING "Valid qt version" FORCE) - endif() + message(FATAL_ERROR "No appropriate QT-version found") endif() else() - set(LYX_USE_QT "QT4" CACHE STRING "Valid qt version" FORCE) + message(FATAL_ERROR "No appropriate QT-version found") endif() endif() endif() @@ -811,8 +808,8 @@ if(LYX_USE_QT MATCHES "QT6|QT5") set(QTVERSION ${${QtVal}Core_VERSION}) if (QTVERSION VERSION_LESS ${min_qt5_version}) message(STATUS "QTVERSION = \"${QTVERSION}\"") - message(STATUS "This version is not recommended, try either option -DLYX_USE_QT=QT4 or") - message(STATUS "install QT-Version >= \"${min_qt5_version}\"") + message(STATUS "This version is not recommended,") + message(STATUS "please install QT-Version >= \"${min_qt5_version}\"") # see thread in lyx-devel list # From: Jean-Pierre Chrétien # Date 11.03.2017 @@ -837,24 +834,6 @@ if(LYX_USE_QT MATCHES "QT6|QT5") set(QtCore5CompatModule Core5Compat) endif() endif() -elseif(LYX_USE_QT MATCHES "QT4") - if(LYX_XMINGW) - set(QT_MINGW_DIR ${LYX_QT4} CACHE PATH "Qt for Mingw" FORCE) - list(APPEND CMAKE_FIND_ROOT_PATH ${QT_MINGW_DIR} ${GNUWIN32_DIR}) - endif() - find_package(Qt4 "4.5.0" REQUIRED) - macro (qt_use_modules) - endmacro() - macro (qt_add_resources) - qt4_add_resources(${ARGN}) - endmacro() - macro (qt_wrap_uifiles) - qt4_wrap_ui(${ARGN}) - endmacro() - set(LYX_QTMAIN_LIBRARY ${QT_QTSVG_LIBRARY}) - if(WIN32) - list(APPEND LYX_QTMAIN_LIBRARY ${QT_QTMAIN_LIBRARIES}) - endif() else() message(FATAL_ERROR "Unhandled value for LYX_USE_QT (${LYX_USE_QT})") endif() @@ -1194,7 +1173,7 @@ unset(opts) unset(tmp_vi) if(QTVERSION MATCHES "^([0-9]+)\\.([0-9]+)\\.([0-9]+).*") - MATH(EXPR QT4_VERSION "(${CMAKE_MATCH_1}<<16)|(${CMAKE_MATCH_2}<<8)|${CMAKE_MATCH_3}") + MATH(EXPR QTx_VERSION "(${CMAKE_MATCH_1}<<16)|(${CMAKE_MATCH_2}<<8)|${CMAKE_MATCH_3}") endif() diff --git a/INSTALL b/INSTALL index f26fba6aa9..330e7e11ea 100644 --- a/INSTALL +++ b/INSTALL @@ -52,18 +52,17 @@ You will also probably need GNU m4 (perhaps installed as gm4). Requirements ------------ -First of all, you will need a C++11 standard conforming compiler, like gcc (at -least 4.9) or clang. +First of all, you will need a C++11 standard conforming compiler, like g++ (at +least 4.9, to have proper srd::regex) or clang++. LyX makes great use of the C++ Standard Template Library (STL). This means that gcc users will have to install the relevant libstdc++ library to be able to compile this version of LyX. For full LyX usability we suggest to use Qt 5.6 and higher, or at the -very least Qt 5.4. For compilation you need to compile against at least -Qt 4.8 which has been widely tested, and for Windows we advise at least -Qt 4.8.4. The only special point to make is that you must ensure that -both LyX and the Qt libraries are compiled with the same C++ compiler. +very least Qt 5.4. It is also possible to compile against Qt 6.The +only special point to make is that you must ensure that both LyX and +the Qt libraries are compiled with the same C++ compiler. To build LyX with spell checking capabilities included you have to install at least one of the development packages of the spell checker @@ -124,8 +123,8 @@ flags: The `gprof' build type compiles and links with -pg option with gcc. - o --disable-qt5 that forces configuration with Qt 4.x when Qt 5.x is - also available. By default Qt5 is tried first, and then Qt4. + o --enable-qt6 that checks configuration with Qt 6.x, and then Qt + 5.x. By default, only Qt5 is tried. o --with-extra-lib=DIRECTORY that specifies the path where LyX will find extra libraries (like Qt) it needs. Defaults to NONE diff --git a/INSTALL.cmake b/INSTALL.cmake index e0e7afde4c..4d889e0fc4 100644 --- a/INSTALL.cmake +++ b/INSTALL.cmake @@ -162,7 +162,7 @@ Build options -- LYX_ENABLE_KEYTESTS = ON : Enable for keytests -- LYX_ASAN = OFF : Use address sanitizer -- LYX_USE_FILEDIALOG = NATI : Use native or QT file dialog (QT NATIVE) - -- LYX_USE_QT = QT5 : Use Qt version as frontend (AUTO QT4 QT5) + -- LYX_USE_QT = QT6 : Use Qt version as frontend (AUTO QT5 QT6) -- LYX_DISABLE_CALLSTACK_PRI= OFF : do not print a callstack when crashing -- LYX_EXTERNAL_Z = ON : OFF := Build 3rdparty lib zlib -- LYX_EXTERNAL_ICONV = ON : OFF := Build 3rdparty lib iconvlib @@ -262,7 +262,7 @@ Ubuntu/Kubuntu You need additionally these packages: * g++ * cmake - * qt4-dev-tools + qt4-qmake or qttools5-dev-tools + qt5-qmake + * qttools5-dev-tools + qt5-qmake or qt6-base-dev-tools + qt6-tools-dev diff --git a/README b/README index a0a44dc75b..b6b7a2ffb3 100644 --- a/README +++ b/README @@ -91,8 +91,7 @@ What do I need to compile LyX from the source distribution? need at least gcc 4.9. * The Qt library, at least version 5.2 (5.6 recommended). It is - still possible to compile with Qt 4.8, but this is not - recommended. + also possible to compile with Qt 6.x. Read the file "INSTALL" for more information on compiling. diff --git a/TODO.killqt4 b/TODO.killqt4 new file mode 100644 index 0000000000..89e027ff76 --- /dev/null +++ b/TODO.killqt4 @@ -0,0 +1,12 @@ +Killing Qt4 +=========== + +Things left to do before release, obtained using: + git grep -il 'qt *4' + +* macOS (Stephan): + - update INSTALL.cmake + - update INSTALL.MacOSX + +* Windows (Eugene?) + - update development/cmake/modules/LyXPaths.cmake diff --git a/config/lyxinclude.m4 b/config/lyxinclude.m4 index e6cab08e3b..f7489eb454 100644 --- a/config/lyxinclude.m4 +++ b/config/lyxinclude.m4 @@ -63,7 +63,7 @@ AC_MSG_RESULT([$withval]) ]) -dnl Check whether to configure for Qt4, Qt5, or Qt6. Default is Qt5. +dnl Check whether to configure for Qt5, or Qt6. Default is Qt5. dnl AC_DEFUN([LYX_CHECK_QT6],[ AC_MSG_CHECKING([whether Qt6 is requested]) @@ -74,18 +74,6 @@ AC_MSG_RESULT([$USE_QT6]) AC_SUBST([USE_QT6]) ]) dnl -AC_DEFUN([LYX_CHECK_QT5],[ -AC_MSG_CHECKING([whether Qt5 is disabled]) -AC_ARG_ENABLE([qt5], - [AS_HELP_STRING([--disable-qt5],[do not use Qt5 for building])], - USE_QT5=$enableval, USE_QT5=yes) -if test x$USE_QT5 != xno ; then - AC_MSG_RESULT([no]) -else - AC_MSG_RESULT([yes]) -fi -AC_SUBST([USE_QT5]) -]) dnl Usage: LYX_WARNING(message) Displays the warning "message" and sets the @@ -381,9 +369,8 @@ if test x$GXX = xyes; then AM_CXXFLAGS="$AM_CXXFLAGS -fno-omit-frame-pointer" fi - if test x$USE_QT5 = xyes -o x$USE_QT6 = xyes; then - AS_CASE([$host], [*mingw*|*cygwin*], [], [AM_CXXFLAGS="-fPIC $AM_CXXFLAGS"]) - fi + AS_CASE([$host], [*mingw*|*cygwin*], [], [AM_CXXFLAGS="-fPIC $AM_CXXFLAGS"]) + dnl Warnings are for preprocessor too if test x$enable_warnings = xyes ; then AM_CPPFLAGS="$AM_CPPFLAGS -Wall -Wextra" @@ -417,10 +404,6 @@ if test x$GXX = xyes; then clang-3.0*|clang-3.1*|clang-3.2*|clang-3.3*) dnl boost contains pragmas that are annoying on older clang versions AM_CPPFLAGS="-Wno-unknown-pragmas $AM_CPPFLAGS";; - clang*) - dnl the more recent versions support the deprecated-register warning, - dnl which is very annoying with Qt4.x right now. - AM_CXXFLAGS="$AM_CXXFLAGS -Wno-deprecated-register";; esac fi ]) diff --git a/config/qt.m4 b/config/qt.m4 index 2cd4263f06..814d94d9a6 100644 --- a/config/qt.m4 +++ b/config/qt.m4 @@ -29,7 +29,7 @@ AC_DEFUN([QT_CHECK_COMPILE], if test $USE_QT6 = "yes" ; then qt_corelibs="-lQt6Core -lQt6Core5Compat" qt_guilibs="-lQt6Core -lQt6Core5Compat -lQt6Concurrent -lQt6Gui -lQt6Svg -lQt6Widgets" - elif test $USE_QT5 = "yes" ; then + else qt_corelibs="-lQt5Core" qt_guilibs="-lQt5Core -lQt5Concurrent -lQt5Gui -lQt5Svg -lQt5Widgets" fi @@ -58,8 +58,6 @@ AC_DEFUN([QT_CHECK_COMPILE], if test -z "$qt_cv_libname"; then if test x$USE_QT6 = xyes ; then AC_MSG_RESULT([failed, retrying with Qt5]) - elif test x$USE_QT5 = xyes ; then - AC_MSG_RESULT([failed, retrying with Qt4]) else AC_MSG_RESULT([failed]) AC_MSG_ERROR([cannot compile a simple Qt executable. Check you have the right \$QTDIR.]) @@ -73,11 +71,9 @@ AC_DEFUN([QT_CHECK_COMPILE], AC_DEFUN([QT_FIND_TOOL], [ $1= - qt_major=4 + qt_major=5 if test "x$USE_QT6" != "xno" ; then qt_major=6 - elif test "x$USE_QT5" != "xno" ; then - qt_major=5 fi qt_ext="qt$qt_major" @@ -132,7 +128,7 @@ dnl start here AC_DEFUN([QT_DO_IT_ALL], [ dnl this variable is precious - AC_ARG_VAR(QTDIR, [the place where the Qt files are, e.g. /usr/lib/qt4]) + AC_ARG_VAR(QTDIR, [the place where the Qt files are, e.g. /usr/lib/qt5]) AC_ARG_WITH(qt-dir, [AS_HELP_STRING([--with-qt-dir], [where the root of Qt is installed])], [ qt_cv_dir=`eval echo "$withval"/` ]) @@ -188,26 +184,10 @@ AC_DEFUN([QT_DO_IT_ALL], fi if test -z "$QT_LIB"; then - dnl Try again with Qt5 and then Qt4 if configuring for Qt6/5 fails + dnl Try again with Qt5 and if configuring for Qt6/5 fails if test x$USE_QT6 = xyes ; then USE_QT6=no - USE_QT5=yes AC_SUBST([USE_QT6]) - AC_SUBST([USE_QT5]) - if test -n "$PKG_CONFIG" ; then - QT_DO_PKG_CONFIG - fi - if test "$pkg_failed" != "no" ; then - QT_DO_MANUAL_CONFIG - fi - if test -z "$QT_LIB"; then - AC_MSG_ERROR([cannot find qt libraries.]) - fi - elif test x$USE_QT5 = xyes ; then - USE_QT6=no - USE_QT5=no - AC_SUBST([USE_QT6]) - AC_SUBST([USE_QT5]) if test -n "$PKG_CONFIG" ; then QT_DO_PKG_CONFIG fi @@ -246,25 +226,13 @@ AC_DEFUN([QT_DO_IT_ALL], [AC_MSG_RESULT(yes) AC_DEFINE(QPA_XCB, 1, [Define if Qt uses the X Window System])], [AC_MSG_RESULT(no)]) - elif test x$USE_QT5 = xyes ; then + else AC_EGREP_CPP(xcb, [#include <$lyx_qt5_config> QT_QPA_DEFAULT_PLATFORM_NAME], [AC_MSG_RESULT(yes) AC_DEFINE(QPA_XCB, 1, [Define if Qt uses the X Window System])], [AC_MSG_RESULT(no)]) - else - AC_PREPROC_IFELSE([AC_LANG_SOURCE([ - [#include ], - [#ifndef Q_WS_X11], - [#error Fail], - [#endif]])], - qt_use_x11=yes, - qt_use_x11=no) - AC_MSG_RESULT($qt_use_x11) - if test "x$qt_use_x11" = "xyes"; then - QT_LIB="$QT_LIB -lX11" - fi fi CPPFLAGS=$save_CPPFLAGS @@ -287,28 +255,24 @@ AC_DEFUN([QT_DO_PKG_CONFIG], PKG_CONFIG_PATH=$qt_cv_dir/lib:$qt_cv_dir/lib/pkgconfig:$PKG_CONFIG_PATH export PKG_CONFIG_PATH fi - qt_corelibs="QtCore" - qt_guilibs="QtCore QtGui QtSvg" - if test "x$USE_QT5" != "xno" ; then - qt_corelibs="Qt5Core" - qt_guilibs="Qt5Core Qt5Concurrent Qt5Gui Qt5Svg Qt5Widgets" - lyx_use_x11extras=false - PKG_CHECK_EXISTS(Qt5X11Extras, [lyx_use_x11extras=true], []) - if $lyx_use_x11extras; then - qt_guilibs="$qt_guilibs Qt5X11Extras xcb" - AC_DEFINE(HAVE_QT5_X11_EXTRAS, 1, - [Define if you have the Qt5X11Extras module]) - fi - lyx_use_winextras=false - PKG_CHECK_EXISTS(Qt5WinExtras, [lyx_use_winextras=true], []) - if $lyx_use_winextras; then - qt_guilibs="$qt_guilibs Qt5WinExtras" - fi - lyx_use_macextras=false - PKG_CHECK_EXISTS(Qt5MacExtras, [lyx_use_macextras=true], []) - if $lyx_use_macextras; then - qt_guilibs="$qt_guilibs Qt5MacExtras" - fi + qt_corelibs="Qt5Core" + qt_guilibs="Qt5Core Qt5Concurrent Qt5Gui Qt5Svg Qt5Widgets" + lyx_use_x11extras=false + PKG_CHECK_EXISTS(Qt5X11Extras, [lyx_use_x11extras=true], []) + if $lyx_use_x11extras; then + qt_guilibs="$qt_guilibs Qt5X11Extras xcb" + AC_DEFINE(HAVE_QT5_X11_EXTRAS, 1, + [Define if you have the Qt5X11Extras module]) + fi + lyx_use_winextras=false + PKG_CHECK_EXISTS(Qt5WinExtras, [lyx_use_winextras=true], []) + if $lyx_use_winextras; then + qt_guilibs="$qt_guilibs Qt5WinExtras" + fi + lyx_use_macextras=false + PKG_CHECK_EXISTS(Qt5MacExtras, [lyx_use_macextras=true], []) + if $lyx_use_macextras; then + qt_guilibs="$qt_guilibs Qt5MacExtras" fi PKG_CHECK_MODULES(QT_CORE, $qt_corelibs,,[:]) if test "$pkg_failed" = "no" ; then diff --git a/configure.ac b/configure.ac index eabbcf86cf..8c0ad6caf0 100644 --- a/configure.ac +++ b/configure.ac @@ -14,9 +14,6 @@ AC_CONFIG_AUX_DIR(config) LYX_CHECK_VERSION LYX_VERSION_SUFFIX LYX_CHECK_QT6 -if test x$USE_QT6 = xno ; then -LYX_CHECK_QT5 -fi # Check how the files should be packaged AC_CANONICAL_TARGET LYX_USE_PACKAGING diff --git a/development/LyX-Mac-binary-release.sh b/development/LyX-Mac-binary-release.sh index 8bad69d612..d2503ec341 100644 --- a/development/LyX-Mac-binary-release.sh +++ b/development/LyX-Mac-binary-release.sh @@ -299,7 +299,7 @@ while [ $# -gt 0 ]; do done if [ "${configure_qt_frameworks}" != "yes" ]; then - QtInstallDir=${QTDIR:-"/opt/qt4"} + QtInstallDir=${QTDIR} fi ARCH_LIST=${ARCH_LIST:-"ppc i386"} diff --git a/development/Makefile.am b/development/Makefile.am index 53a67b83ca..4b82b4de0f 100644 --- a/development/Makefile.am +++ b/development/Makefile.am @@ -176,7 +176,6 @@ cmake/modules/FindLyXGettext.cmake \ cmake/modules/FindMagic.cmake \ cmake/modules/FindMYTHESLIB.cmake \ cmake/modules/FindOpenSSL.cmake \ -cmake/modules/FindQt4.cmake \ cmake/modules/FindZLIB.cmake \ cmake/modules/LyXDestinations.cmake \ cmake/modules/LyXMacros.cmake \ diff --git a/development/autotests/keytest.py b/development/autotests/keytest.py index 58acd4085b..ce3b245653 100755 --- a/development/autotests/keytest.py +++ b/development/autotests/keytest.py @@ -611,7 +611,7 @@ if xvkbd_exe is None: qt_frontend = os.environ.get('QT_FRONTEND') if qt_frontend is None: - qt_frontend = 'QT4' + qt_frontend = 'QT5' if qt_frontend == 'QT5': # Some tests sometimes failed with value 0.01 on Qt5.8 controlkey_delay = 0.4 diff --git a/development/cmake/ConfigureChecks.cmake b/development/cmake/ConfigureChecks.cmake index 16cc4ff03a..9062372c38 100644 --- a/development/cmake/ConfigureChecks.cmake +++ b/development/cmake/ConfigureChecks.cmake @@ -348,19 +348,6 @@ if (LYX_USE_QT MATCHES "QT5|QT6") set(CMAKE_REQUIRED_INCLUDES ${${QtVal}WinExtras_INCLUDE_DIRS}) set(CMAKE_REQUIRED_FLAGS ${${QtVal}WinExtras_EXECUTABLE_COMPILE_FLAGS}) endif() -elseif(LYX_USE_QT MATCHES "QT4") - set(CMAKE_REQUIRED_LIBRARIES ${QT_QTGUI_LIBRARY}) - set(CMAKE_REQUIRED_INCLUDES ${QT_INCLUDES}) - check_cxx_source_compiles( - " - #include - int main() - { - QX11Info *qxi = new QX11Info; - qxi->~QX11Info(); - } - " - QT_USES_X11) else() message(FATAL_ERROR "Check for QT_USES_X11: Not handled LYX_USE_QT (= ${LYX_USE_QT})") endif() diff --git a/development/cmake/modules/FindQt4.cmake b/development/cmake/modules/FindQt4.cmake deleted file mode 100644 index 066124a321..0000000000 --- a/development/cmake/modules/FindQt4.cmake +++ /dev/null @@ -1,1046 +0,0 @@ -# - Find QT 4 -# This module can be used to find Qt4. -# The most important issue is that the Qt4 qmake is available via the system path. -# This qmake is then used to detect basically everything else. -# This module defines a number of key variables and macros. First is -# QT_USE_FILE which is the path to a CMake file that can be included to compile -# Qt 4 applications and libraries. By default, the QtCore and QtGui -# libraries are loaded. This behavior can be changed by setting one or more -# of the following variables to true: -# QT_DONT_USE_QTCORE -# QT_DONT_USE_QTGUI -# QT_USE_QT3SUPPORT -# QT_USE_QTASSISTANT -# QT_USE_QTDESIGNER -# QT_USE_QTMOTIF -# QT_USE_QTMAIN -# QT_USE_QTNETWORK -# QT_USE_QTNSPLUGIN -# QT_USE_QTOPENGL -# QT_USE_QTSQL -# QT_USE_QTXML -# QT_USE_QTSVG -# QT_USE_QTTEST -# QT_USE_QTUITOOLS -# -# All the libraries required are stored in a variable called QT_LIBRARIES. -# Add this variable to your TARGET_LINK_LIBRARIES. -# -# macro QT4_WRAP_CPP(outfiles inputfile ... ) -# macro QT4_WRAP_UI(outfiles inputfile ... ) -# macro QT4_ADD_RESOURCE(outfiles inputfile ... ) -# macro QT4_AUTOMOC(inputfile ... ) -# macro QT4_GENERATE_MOC(inputfile outputfile ) -# -# QT_FOUND If false, don't try to use Qt. -# QT4_FOUND If false, don't try to use Qt 4. -# -# QT_QTCORE_FOUND True if QtCore was found. -# QT_QTGUI_FOUND True if QtGui was found. -# QT_QT3SUPPORT_FOUND True if Qt3Support was found. -# QT_QTASSISTANT_FOUND True if QtAssistant was found. -# QT_QTDESIGNER_FOUND True if QtDesigner was found. -# QT_QTMOTIF_FOUND True if QtMotif was found. -# QT_QTNETWORK_FOUND True if QtNetwork was found. -# QT_QTNSPLUGIN_FOUND True if QtNsPlugin was found. -# QT_QTOPENGL_FOUND True if QtOpenGL was found. -# QT_QTSQL_FOUND True if QtSql was found. -# QT_QTXML_FOUND True if QtXml was found. -# QT_QTSVG_FOUND True if QtSvg was found. -# QT_QTTEST_FOUND True if QtTest was found. -# QT_QTUITOOLS_FOUND True if QtUiTools was found. -# -# QT_DEFINITIONS Definitions to use when compiling code that uses Qt. -# -# QT_INCLUDES List of paths to all include directories of -# Qt4 QT_INCLUDE_DIR and QT_QTCORE_INCLUDE_DIR are -# always in this variable even if NOTFOUND, -# all other INCLUDE_DIRS are -# only added if they are found. -# -# QT_INCLUDE_DIR Path to "include" of Qt4 -# QT_QT_INCLUDE_DIR Path to "include/Qt" -# QT_QT3SUPPORT_INCLUDE_DIR Path to "include/Qt3Support" -# QT_QTASSISTANT_INCLUDE_DIR Path to "include/QtAssistant" -# QT_QTCORE_INCLUDE_DIR Path to "include/QtCore" -# QT_QTDESIGNER_INCLUDE_DIR Path to "include/QtDesigner" -# QT_QTGUI_INCLUDE_DIR Path to "include/QtGui" -# QT_QTMOTIF_INCLUDE_DIR Path to "include/QtMotif" -# QT_QTNETWORK_INCLUDE_DIR Path to "include/QtNetwork" -# QT_QTNSPLUGIN_INCLUDE_DIR Path to "include/QtNsPlugin" -# QT_QTOPENGL_INCLUDE_DIR Path to "include/QtOpenGL" -# QT_QTSQL_INCLUDE_DIR Path to "include/QtSql" -# QT_QTXML_INCLUDE_DIR Path to "include/QtXml" -# QT_QTSVG_INCLUDE_DIR Path to "include/QtSvg" -# QT_QTTEST_INCLUDE_DIR Path to "include/QtTest" -# -# QT_LIBRARY_DIR Path to "lib" of Qt4 -# -# QT_PLUGINS_DIR Path to "plugins" for Qt4 -# -# For every library of Qt there are three variables: -# QT_QTFOO_LIBRARY_RELEASE, which contains the full path to the release version -# QT_QTFOO_LIBRARY_DEBUG, which contains the full path to the debug version -# QT_QTFOO_LIBRARY, the full path to the release version if available, otherwise to the debug version -# -# So there are the following variables: -# The Qt3Support library: QT_QT3SUPPORT_LIBRARY -# QT_QT3SUPPORT_LIBRARY_RELEASE -# QT_QT3SUPPORT_DEBUG -# -# The QtAssistant library: QT_QTASSISTANT_LIBRARY -# QT_QTASSISTANT_LIBRARY_RELEASE -# QT_QTASSISTANT_LIBRARY_DEBUG -# -# The QtCore library: QT_QTCORE_LIBRARY -# QT_QTCORE_LIBRARY_RELEASE -# QT_QTCORE_LIBRARY_DEBUG -# -# The QtDesigner library: QT_QTDESIGNER_LIBRARY -# QT_QTDESIGNER_LIBRARY_RELEASE -# QT_QTDESIGNER_LIBRARY_DEBUG -# -# The QtGui library: QT_QTGUI_LIBRARY -# QT_QTGUI_LIBRARY_RELEASE -# QT_QTGUI_LIBRARY_DEBUG -# -# The QtMotif library: QT_QTMOTIF_LIBRARY -# QT_QTMOTIF_LIBRARY_RELEASE -# QT_QTMOTIF_LIBRARY_DEBUG -# -# The QtNetwork library: QT_QTNETWORK_LIBRARY -# QT_QTNETWORK_LIBRARY_RELEASE -# QT_QTNETWORK_LIBRARY_DEBUG -# -# The QtNsPLugin library: QT_QTNSPLUGIN_LIBRARY -# QT_QTNSPLUGIN_LIBRARY_RELEASE -# QT_QTNSPLUGIN_LIBRARY_DEBUG -# -# The QtOpenGL library: QT_QTOPENGL_LIBRARY -# QT_QTOPENGL_LIBRARY_RELEASE -# QT_QTOPENGL_LIBRARY_DEBUG -# -# The QtSql library: QT_QTSQL_LIBRARY -# QT_QTSQL_LIBRARY_RELEASE -# QT_QTSQL_LIBRARY_DEBUG -# -# The QtXml library: QT_QTXML_LIBRARY -# QT_QTXML_LIBRARY_RELEASE -# QT_QTXML_LIBRARY_DEBUG -# -# The QtSvg library: QT_QTSVG_LIBRARY -# QT_QTSVG_LIBRARY_RELEASE -# QT_QTSVG_LIBRARY_DEBUG -# -# The QtTest library: QT_QTTEST_LIBRARY -# QT_QTTEST_LIBRARY_RELEASE -# QT_QTTEST_LIBRARY_DEBUG -# -# The qtmain library for Windows QT_QTMAIN_LIBRARY -# QT_QTMAIN_LIBRARY_RELEASE -# QT_QTMAIN_LIBRARY_DEBUG -# -#The QtUiTools library: QT_QTUITOOLS_LIBRARY -# QT_QTUITOOLS_LIBRARY_RELEASE -# QT_QTUITOOLS_LIBRARY_DEBUG -# -# also defined, but NOT for general use are -# QT_MOC_EXECUTABLE Where to find the moc tool. -# QT_UIC_EXECUTABLE Where to find the uic tool. -# QT_UIC3_EXECUTABLE Where to find the uic3 tool. -# QT_RCC_EXECUTABLE Where to find the rcc tool -# -# QT_DOC_DIR Path to "doc" of Qt4 -# QT_MKSPECS_DIR Path to "mkspecs" of Qt4 -# -# -# These are around for backwards compatibility -# they will be set -# QT_WRAP_CPP Set true if QT_MOC_EXECUTABLE is found -# QT_WRAP_UI Set true if QT_UIC_EXECUTABLE is found -# -# These variables do _NOT_ have any effect anymore (compared to FindQt.cmake) -# QT_MT_REQUIRED Qt4 is now always multithreaded -# -# These variables are set to "" Because Qt structure changed -# (They make no sense in Qt4) -# QT_QT_LIBRARY Qt-Library is now split - -INCLUDE(CheckSymbolExists) -INCLUDE(MacroAddFileDependencies) - -set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true) - -set(QT_USE_FILE ${CMAKE_ROOT}/Modules/UseQt4.cmake) - -set(QT_DEFINITIONS "") - -# check for qmake -find_program(QT_QMAKE_EXECUTABLE NAMES qmake qmake-qt4 PATHS - "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\4.0.0;InstallDir]/bin" - "[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\4.0.0;InstallDir]/bin" - $ENV{QTDIR}/bin) - -set(QT4_INSTALLED_VERSION_TOO_OLD FALSE) - -## macro for asking qmake to process pro files -macro(QT_QUERY_QMAKE outvar invar) - file(WRITE ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmpQmake/tmp.pro - "message(CMAKE_MESSAGE<$$${invar}>)") - execute_process(COMMAND ${QT_QMAKE_EXECUTABLE} - WORKING_DIRECTORY - ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmpQmake - OUTPUT_VARIABLE _qmake_query_output - ERROR_VARIABLE _qmake_query_output ) - file(REMOVE_RECURSE - "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmpQmake") - string(REGEX REPLACE ".*CMAKE_MESSAGE<([^>]*).*" "\\1" - ${outvar} "${_qmake_query_output}") -endmacro(QT_QUERY_QMAKE) - - -if(QT_QMAKE_EXECUTABLE) - - set(QT4_QMAKE_FOUND FALSE) - - exec_program(${QT_QMAKE_EXECUTABLE} ARGS "-query QT_VERSION" - OUTPUT_VARIABLE QTVERSION) - # check for qt3 qmake and then try and find qmake-qt4 in the path - if("${QTVERSION}" MATCHES "Unknown") - set(QT_QMAKE_EXECUTABLE NOTFOUND CACHE FILEPATH "" FORCE) - find_program(QT_QMAKE_EXECUTABLE NAMES qmake-qt4 PATHS - "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\4.0.0;InstallDir]/bin" - "[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\4.0.0;InstallDir]/bin" - $ENV{QTDIR}/bin - ) - if(QT_QMAKE_EXECUTABLE) - EXEC_PROGRAM(${QT_QMAKE_EXECUTABLE} - ARGS "-query QT_VERSION" OUTPUT_VARIABLE QTVERSION) - endif() - endif() - # check that we found the Qt4 qmake, Qt3 qmake output won't match here - string(REGEX MATCH "^[0-9]+\\.[0-9]+\\.[0-9]+" qt_version_tmp "${QTVERSION}") - if(qt_version_tmp) - - # we need at least version 4.0.0 - if(NOT QT_MIN_VERSION) - set(QT_MIN_VERSION "4.0.0") - endif() - - # now parse the parts of the user given version string into variables - string(REGEX MATCH "^[0-9]+\\.[0-9]+\\.[0-9]+" req_qt_major_vers "${QT_MIN_VERSION}") - if(NOT req_qt_major_vers) - message( FATAL_ERROR "Invalid Qt version string given: \"${QT_MIN_VERSION}\", expected e.g. \"4.0.1\"") - endif() - - # now parse the parts of the user given version string into variables - string(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" - req_qt_major_vers "${QT_MIN_VERSION}") - string(REGEX REPLACE "^[0-9]+\\.([0-9])+\\.[0-9]+" "\\1" - req_qt_minor_vers "${QT_MIN_VERSION}") - string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" - req_qt_patch_vers "${QT_MIN_VERSION}") - - if(NOT req_qt_major_vers EQUAL 4) - message( FATAL_ERROR "Invalid Qt version string given: \"${QT_MIN_VERSION}\", major version 4 is required, e.g. \"4.0.1\"") - endif() - - # and now the version string given by qmake - string(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" - found_qt_major_vers "${QTVERSION}") - string(REGEX REPLACE "^[0-9]+\\.([0-9])+\\.[0-9]+.*" "\\1" - found_qt_minor_vers "${QTVERSION}") - string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" - found_qt_patch_vers "${QTVERSION}") - - # compute an overall version number which can be compared at once - math(EXPR req_vers "${req_qt_major_vers}*10000 + ${req_qt_minor_vers}*100 + ${req_qt_patch_vers}") - math(EXPR found_vers "${found_qt_major_vers}*10000 + ${found_qt_minor_vers}*100 + ${found_qt_patch_vers}") - - if(found_vers LESS req_vers) - set(QT4_QMAKE_FOUND FALSE) - set(QT4_INSTALLED_VERSION_TOO_OLD TRUE) - else() - set(QT4_QMAKE_FOUND TRUE) - endif() - endif() - -endif() - -if(QT4_QMAKE_FOUND) - - # ask qmake for the library dir - # Set QT_LIBRARY_DIR - if(NOT QT_LIBRARY_DIR) - exec_program( ${QT_QMAKE_EXECUTABLE} - ARGS "-query QT_INSTALL_LIBS" - OUTPUT_VARIABLE QT_LIBRARY_DIR_TMP) - if(EXISTS "${QT_LIBRARY_DIR_TMP}") - set(QT_LIBRARY_DIR ${QT_LIBRARY_DIR_TMP} CACHE PATH "Qt library dir") - else() - message("Warning: QT_QMAKE_EXECUTABLE reported QT_INSTALL_LIBS as ${QT_LIBRARY_DIR_TMP}") - message("Warning: ${QT_LIBRARY_DIR_TMP} does NOT exist, Qt must NOT be installed correctly.") - endif() - endif() - - if(APPLE) - if(EXISTS ${QT_LIBRARY_DIR}/QtCore.framework) - set(QT_USE_FRAMEWORKS ON - CACHE BOOL "Set to ON if Qt build uses frameworks.") - else() - set(QT_USE_FRAMEWORKS OFF - CACHE BOOL "Set to ON if Qt build uses frameworks.") - endif() - - mark_as_advanced(QT_USE_FRAMEWORKS) - endif() - - # ask qmake for the binary dir - if(NOT QT_BINARY_DIR) - exec_program(${QT_QMAKE_EXECUTABLE} - ARGS "-query QT_INSTALL_BINS" - OUTPUT_VARIABLE qt_bins ) - set(QT_BINARY_DIR ${qt_bins} CACHE INTERNAL "") - endif() - - # ask qmake for the include dir - if(NOT QT_HEADERS_DIR) - EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE} - ARGS "-query QT_INSTALL_HEADERS" - OUTPUT_VARIABLE qt_headers ) - set(QT_HEADERS_DIR ${qt_headers} CACHE INTERNAL "") - endif() - - - # ask qmake for the documentation directory - if(NOT QT_DOC_DIR) - exec_program( ${QT_QMAKE_EXECUTABLE} - ARGS "-query QT_INSTALL_DOCS" - OUTPUT_VARIABLE qt_doc_dir ) - set(QT_DOC_DIR ${qt_doc_dir} CACHE PATH "The location of the Qt docs") - endif() - - # ask qmake for the mkspecs directory - if(NOT QT_MKSPECS_DIR) - exec_program( ${QT_QMAKE_EXECUTABLE} - ARGS "-query QMAKE_MKSPECS" - OUTPUT_VARIABLE qt_mkspecs_dir ) - set(QT_MKSPECS_DIR ${qt_mkspecs_dir} CACHE PATH - "The location of the Qt mkspecs") - endif() - - # ask qmake for the plugins directory - if(NOT QT_PLUGINS_DIR) - exec_program( ${QT_QMAKE_EXECUTABLE} - ARGS "-query QT_INSTALL_PLUGINS" - OUTPUT_VARIABLE qt_plugins_dir ) - set(QT_PLUGINS_DIR ${qt_plugins_dir} CACHE PATH - "The location of the Qt plugins") - endif() - ######################################## - # - # Setting the INCLUDE-Variables - # - ######################################## - - find_path(QT_QTCORE_INCLUDE_DIR QtGlobal - ${QT_HEADERS_DIR}/QtCore - ${QT_LIBRARY_DIR}/QtCore.framework/Headers - NO_DEFAULT_PATH) - - # Set QT_INCLUDE_DIR by removing "/QtCore" in the string ${QT_QTCORE_INCLUDE_DIR} - if(QT_QTCORE_INCLUDE_DIR AND NOT QT_INCLUDE_DIR) - if(QT_USE_FRAMEWORKS) - set(QT_INCLUDE_DIR ${QT_HEADERS_DIR}) - else() - string(REGEX REPLACE "/QtCore$" "" qt4_include_dir ${QT_QTCORE_INCLUDE_DIR}) - set(QT_INCLUDE_DIR ${qt4_include_dir} CACHE PATH "") - endif() - endif() - - if(NOT QT_INCLUDE_DIR) - if(NOT Qt4_FIND_QUIETLY AND Qt4_FIND_REQUIRED) - message( FATAL_ERROR "Could NOT find QtGlobal header") - endif() - endif() - - ############################################# - # - # Find out what window system we're using - # - ############################################# - # Save required includes variable - set(CMAKE_REQUIRED_INCLUDES_SAVE ${CMAKE_REQUIRED_INCLUDES}) - # Add QT_INCLUDE_DIR to CMAKE_REQUIRED_INCLUDES - set(CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES};${QT_INCLUDE_DIR}") - # Check for Window system symbols (note: only one should end up being set) - check_symbol_exists(Q_WS_X11 "QtCore/qglobal.h" Q_WS_X11) - check_symbol_exists(Q_WS_MAC "QtCore/qglobal.h" Q_WS_MAC) - check_symbol_exists(Q_WS_WIN "QtCore/qglobal.h" Q_WS_WIN) - - if(QT_QTCOPY_REQUIRED) - check_symbol_exists(QT_IS_QTCOPY "QtCore/qglobal.h" QT_KDE_QT_COPY) - if(NOT QT_IS_QTCOPY) - message(FATAL_ERROR "qt-copy is required, but hasn't been found") - endif() - endif() - - # Restore CMAKE_REQUIRED_INCLUDES variable - set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_SAVE}) - # - ############################################# - - IF (QT_USE_FRAMEWORKS) - set(QT_DEFINITIONS ${QT_DEFINITIONS} -F${QT_LIBRARY_DIR} -L${QT_LIBRARY_DIR} ) - endif() - - # Set QT_QT3SUPPORT_INCLUDE_DIR - FIND_PATH(QT_QT3SUPPORT_INCLUDE_DIR Qt3Support - PATHS - ${QT_INCLUDE_DIR}/Qt3Support - ${QT_LIBRARY_DIR}/Qt3Support.framework/Headers - NO_DEFAULT_PATH - ) - - # Set QT_QT_INCLUDE_DIR - FIND_PATH(QT_QT_INCLUDE_DIR qglobal.h - PATHS - ${QT_INCLUDE_DIR}/Qt - ${QT_LIBRARY_DIR}/QtCore.framework/Headers - NO_DEFAULT_PATH - ) - - # Set QT_QTGUI_INCLUDE_DIR - FIND_PATH(QT_QTGUI_INCLUDE_DIR QtGui - PATHS - ${QT_INCLUDE_DIR}/QtGui - ${QT_LIBRARY_DIR}/QtGui.framework/Headers - NO_DEFAULT_PATH - ) - - # Set QT_QTSVG_INCLUDE_DIR - FIND_PATH(QT_QTSVG_INCLUDE_DIR QtSvg - PATHS - ${QT_INCLUDE_DIR}/QtSvg - ${QT_LIBRARY_DIR}/QtSvg.framework/Headers - NO_DEFAULT_PATH - ) - - # Set QT_QTTEST_INCLUDE_DIR - FIND_PATH(QT_QTTEST_INCLUDE_DIR QtTest - PATHS - ${QT_INCLUDE_DIR}/QtTest - ${QT_LIBRARY_DIR}/QtTest.framework/Headers - NO_DEFAULT_PATH - ) - - # Set QT_QTUITOOLS_INCLUDE_DIR - FIND_PATH(QT_QTUITOOLS_INCLUDE_DIR QtUiTools - PATHS - ${QT_INCLUDE_DIR}/QtUiTools - ${QT_LIBRARY_DIR}/QtUiTools.framework/Headers - NO_DEFAULT_PATH - ) - - - - # Set QT_QTMOTIF_INCLUDE_DIR - IF(Q_WS_X11) - FIND_PATH(QT_QTMOTIF_INCLUDE_DIR QtMotif PATHS ${QT_INCLUDE_DIR}/QtMotif NO_DEFAULT_PATH ) - endif() - - # Set QT_QTNETWORK_INCLUDE_DIR - FIND_PATH(QT_QTNETWORK_INCLUDE_DIR QtNetwork - PATHS - ${QT_INCLUDE_DIR}/QtNetwork - ${QT_LIBRARY_DIR}/QtNetwork.framework/Headers - NO_DEFAULT_PATH - ) - - # Set QT_QTNSPLUGIN_INCLUDE_DIR - FIND_PATH(QT_QTNSPLUGIN_INCLUDE_DIR QtNsPlugin - PATHS - ${QT_INCLUDE_DIR}/QtNsPlugin - ${QT_LIBRARY_DIR}/QtNsPlugin.framework/Headers - NO_DEFAULT_PATH - ) - - # Set QT_QTOPENGL_INCLUDE_DIR - FIND_PATH(QT_QTOPENGL_INCLUDE_DIR QtOpenGL - PATHS - ${QT_INCLUDE_DIR}/QtOpenGL - ${QT_LIBRARY_DIR}/QtOpenGL.framework/Headers - NO_DEFAULT_PATH - ) - - # Set QT_QTSQL_INCLUDE_DIR - FIND_PATH(QT_QTSQL_INCLUDE_DIR QtSql - PATHS - ${QT_INCLUDE_DIR}/QtSql - ${QT_LIBRARY_DIR}/QtSql.framework/Headers - NO_DEFAULT_PATH - ) - - # Set QT_QTXML_INCLUDE_DIR - FIND_PATH(QT_QTXML_INCLUDE_DIR QtXml - PATHS - ${QT_INCLUDE_DIR}/QtXml - ${QT_LIBRARY_DIR}/QtXml.framework/Headers - NO_DEFAULT_PATH - ) - - # Set QT_QTASSISTANT_INCLUDE_DIR - FIND_PATH(QT_QTASSISTANT_INCLUDE_DIR QtAssistant - PATHS - ${QT_INCLUDE_DIR}/QtAssistant - ${QT_HEADERS_DIR}/QtAssistant - NO_DEFAULT_PATH - ) - - # Set QT_QTDESIGNER_INCLUDE_DIR - FIND_PATH(QT_QTDESIGNER_INCLUDE_DIR QDesignerComponents - PATHS - ${QT_INCLUDE_DIR}/QtDesigner - ${QT_HEADERS_DIR}/QtDesigner - NO_DEFAULT_PATH - ) - - # Make variables changeble to the advanced user - MARK_AS_ADVANCED( QT_LIBRARY_DIR QT_INCLUDE_DIR QT_QT_INCLUDE_DIR QT_DOC_DIR) - - # Set QT_INCLUDES - set( QT_INCLUDES ${QT_INCLUDE_DIR} ${QT_QT_INCLUDE_DIR} ${QT_MKSPECS_DIR}/default ) - - # Set QT_QTCORE_LIBRARY by searching for a lib with "QtCore." as part of the filename - FIND_LIBRARY(QT_QTCORE_LIBRARY_RELEASE NAMES QtCore QtCore4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH ) - FIND_LIBRARY(QT_QTCORE_LIBRARY_DEBUG NAMES QtCore_debug QtCored QtCored4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - - # Set QT_QT3SUPPORT_LIBRARY - FIND_LIBRARY(QT_QT3SUPPORT_LIBRARY_RELEASE NAMES Qt3Support Qt3Support4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - FIND_LIBRARY(QT_QT3SUPPORT_LIBRARY_DEBUG NAMES Qt3Support_debug Qt3Supportd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - - # Set QT_QTGUI_LIBRARY - FIND_LIBRARY(QT_QTGUI_LIBRARY_RELEASE NAMES QtGui QtGui4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - FIND_LIBRARY(QT_QTGUI_LIBRARY_DEBUG NAMES QtGui_debug QtGuid4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - - # Set QT_QTMOTIF_LIBRARY - IF(Q_WS_X11) - FIND_LIBRARY(QT_QTMOTIF_LIBRARY_RELEASE NAMES QtMotif PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - FIND_LIBRARY(QT_QTMOTIF_LIBRARY_DEBUG NAMES QtMotif_debug PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - endif() - - # Set QT_QTNETWORK_LIBRARY - FIND_LIBRARY(QT_QTNETWORK_LIBRARY_RELEASE NAMES QtNetwork QtNetwork4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - FIND_LIBRARY(QT_QTNETWORK_LIBRARY_DEBUG NAMES QtNetwork_debug QtNetworkd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - - # Set QT_QTNSPLUGIN_LIBRARY - FIND_LIBRARY(QT_QTNSPLUGIN_LIBRARY_RELEASE NAMES QtNsPlugin PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - FIND_LIBRARY(QT_QTNSPLUGIN_LIBRARY_DEBUG NAMES QtNsPlugin_debug PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - - # Set QT_QTOPENGL_LIBRARY - FIND_LIBRARY(QT_QTOPENGL_LIBRARY_RELEASE NAMES QtOpenGL QtOpenGL4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - FIND_LIBRARY(QT_QTOPENGL_LIBRARY_DEBUG NAMES QtOpenGL_debug QtOpenGLd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - - # Set QT_QTSQL_LIBRARY - FIND_LIBRARY(QT_QTSQL_LIBRARY_RELEASE NAMES QtSql QtSql4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - FIND_LIBRARY(QT_QTSQL_LIBRARY_DEBUG NAMES QtSql_debug QtSqld4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - - # Set QT_QTXML_LIBRARY - FIND_LIBRARY(QT_QTXML_LIBRARY_RELEASE NAMES QtXml QtXml4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - FIND_LIBRARY(QT_QTXML_LIBRARY_DEBUG NAMES QtXml_debug QtXmld4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - - # Set QT_QTSVG_LIBRARY - FIND_LIBRARY(QT_QTSVG_LIBRARY_RELEASE NAMES QtSvg QtSvg4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - FIND_LIBRARY(QT_QTSVG_LIBRARY_DEBUG NAMES QtSvg_debug QtSvgd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - - # Set QT_QTUITOOLS_LIBRARY - FIND_LIBRARY(QT_QTUITOOLS_LIBRARY_RELEASE NAMES QtUiTools QtUiTools4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - FIND_LIBRARY(QT_QTUITOOLS_LIBRARY_DEBUG NAMES QtUiTools_debug QtUiToolsd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - - # Set QT_QTTEST_LIBRARY - FIND_LIBRARY(QT_QTTEST_LIBRARY_RELEASE NAMES QtTest QtTest4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - FIND_LIBRARY(QT_QTTEST_LIBRARY_DEBUG NAMES QtTest_debug QtTest_debug4 QtTestd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - - MARK_AS_ADVANCED(QT_QT3SUPPORT_LIBRARY QT_QTGUI_LIBRARY ) - - IF( NOT QT_QTCORE_LIBRARY_DEBUG AND NOT QT_QTCORE_LIBRARY_RELEASE ) - IF( NOT Qt4_FIND_QUIETLY AND Qt4_FIND_REQUIRED) - message( FATAL_ERROR "Could NOT find QtCore. Check ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log for more details.") - endif() - endif() - - # Set QT_QTASSISTANT_LIBRARY - FIND_LIBRARY(QT_QTASSISTANT_LIBRARY_RELEASE NAMES QtAssistantClient QtAssistantClient4 QtAssistant QtAssistant4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - FIND_LIBRARY(QT_QTASSISTANT_LIBRARY_DEBUG NAMES QtAssistantClientd QtAssistantClientd4 QtAssistantClient_debug QtAssistant_debug QtAssistantd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - - # Set QT_QTDESIGNER_LIBRARY - FIND_LIBRARY(QT_QTDESIGNER_LIBRARY_RELEASE NAMES QtDesigner QtDesigner4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - FIND_LIBRARY(QT_QTDESIGNER_LIBRARY_DEBUG NAMES QtDesigner_debug QtDesignerd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - - # Set QT_QTMAIN_LIBRARY - IF(WIN32) - FIND_LIBRARY(QT_QTMAIN_LIBRARY_RELEASE NAMES qtmain PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - FIND_LIBRARY(QT_QTMAIN_LIBRARY_DEBUG NAMES qtmaind PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - endif() - - ############################################ - # - # Check the existence of the libraries. - # - ############################################ - - MACRO (_QT4_ADJUST_LIB_VARS basename) - IF (QT_${basename}_LIBRARY_RELEASE OR QT_${basename}_LIBRARY_DEBUG) - - # if only the release version was found, set the debug variable also to the release version - IF (QT_${basename}_LIBRARY_RELEASE AND NOT QT_${basename}_LIBRARY_DEBUG) - set(QT_${basename}_LIBRARY_DEBUG ${QT_${basename}_LIBRARY_RELEASE}) - set(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY_RELEASE}) - set(QT_${basename}_LIBRARIES ${QT_${basename}_LIBRARY_RELEASE}) - endif() - - # if only the debug version was found, set the release variable also to the debug version - IF (QT_${basename}_LIBRARY_DEBUG AND NOT QT_${basename}_LIBRARY_RELEASE) - set(QT_${basename}_LIBRARY_RELEASE ${QT_${basename}_LIBRARY_DEBUG}) - set(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY_DEBUG}) - set(QT_${basename}_LIBRARIES ${QT_${basename}_LIBRARY_DEBUG}) - endif() - IF (QT_${basename}_LIBRARY_DEBUG AND QT_${basename}_LIBRARY_RELEASE) - # if the generator supports configuration types then set - # optimized and debug libraries, or if the CMAKE_BUILD_TYPE has a value - IF (CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE) - set(QT_${basename}_LIBRARY optimized ${QT_${basename}_LIBRARY_RELEASE} debug ${QT_${basename}_LIBRARY_DEBUG}) - else() - # if there are no configuration types and CMAKE_BUILD_TYPE has no value - # then just use the release libraries - set(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY_RELEASE} ) - endif() - set(QT_${basename}_LIBRARIES optimized ${QT_${basename}_LIBRARY_RELEASE} debug ${QT_${basename}_LIBRARY_DEBUG}) - endif() - - set(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY} CACHE FILEPATH "The Qt ${basename} library") - - IF (QT_${basename}_LIBRARY) - set(QT_${basename}_FOUND 1) - endif() - endif() - - #add the include directory to QT_INCLUDES - IF (QT_${basename}_INCLUDE_DIR) - set(QT_INCLUDES ${QT_INCLUDES} "${QT_${basename}_INCLUDE_DIR}") - endif() - - # Make variables changeble to the advanced user - MARK_AS_ADVANCED(QT_${basename}_LIBRARY QT_${basename}_LIBRARY_RELEASE QT_${basename}_LIBRARY_DEBUG QT_${basename}_INCLUDE_DIR) - ENDMACRO (_QT4_ADJUST_LIB_VARS) - - - # Set QT_xyz_LIBRARY variable and add - # library include path to QT_INCLUDES - _QT4_ADJUST_LIB_VARS(QTCORE) - _QT4_ADJUST_LIB_VARS(QTGUI) - _QT4_ADJUST_LIB_VARS(QT3SUPPORT) - _QT4_ADJUST_LIB_VARS(QTASSISTANT) - _QT4_ADJUST_LIB_VARS(QTDESIGNER) - _QT4_ADJUST_LIB_VARS(QTNETWORK) - _QT4_ADJUST_LIB_VARS(QTNSPLUGIN) - _QT4_ADJUST_LIB_VARS(QTOPENGL) - _QT4_ADJUST_LIB_VARS(QTSQL) - _QT4_ADJUST_LIB_VARS(QTXML) - _QT4_ADJUST_LIB_VARS(QTSVG) - _QT4_ADJUST_LIB_VARS(QTUITOOLS) - _QT4_ADJUST_LIB_VARS(QTTEST) - - # platform dependent libraries - IF(Q_WS_X11) - _QT4_ADJUST_LIB_VARS(QTMOTIF) - endif() - IF(WIN32) - _QT4_ADJUST_LIB_VARS(QTMAIN) - endif() - - ####################################### - # - # Check the executables of Qt - # ( moc, uic, rcc ) - # - ####################################### - - - # find moc and uic using qmake - QT_QUERY_QMAKE(QT_MOC_EXECUTABLE_INTERNAL "QMAKE_MOC") - QT_QUERY_QMAKE(QT_UIC_EXECUTABLE_INTERNAL "QMAKE_UIC") - - FILE(TO_CMAKE_PATH - "${QT_MOC_EXECUTABLE_INTERNAL}" QT_MOC_EXECUTABLE_INTERNAL) - FILE(TO_CMAKE_PATH - "${QT_UIC_EXECUTABLE_INTERNAL}" QT_UIC_EXECUTABLE_INTERNAL) - - set(QT_MOC_EXECUTABLE - ${QT_MOC_EXECUTABLE_INTERNAL} CACHE FILEPATH "The moc executable") - set(QT_UIC_EXECUTABLE - ${QT_UIC_EXECUTABLE_INTERNAL} CACHE FILEPATH "The uic executable") - - FIND_PROGRAM(QT_UIC3_EXECUTABLE - NAMES uic3 - PATHS ${QT_BINARY_DIR} - NO_DEFAULT_PATH - ) - - FIND_PROGRAM(QT_RCC_EXECUTABLE - NAMES rcc - PATHS ${QT_BINARY_DIR} - NO_DEFAULT_PATH - ) - - IF (QT_MOC_EXECUTABLE) - set(QT_WRAP_CPP "YES") - endif() - - IF (QT_UIC_EXECUTABLE) - set(QT_WRAP_UI "YES") - endif() - - - - MARK_AS_ADVANCED( QT_UIC_EXECUTABLE QT_UIC3_EXECUTABLE QT_MOC_EXECUTABLE QT_RCC_EXECUTABLE ) - - ###################################### - # - # Macros for building Qt files - # - ###################################### - - MACRO (QT4_GET_MOC_INC_DIRS _moc_INC_DIRS) - set(${_moc_INC_DIRS}) - GET_DIRECTORY_PROPERTY(_inc_DIRS INCLUDE_DIRECTORIES) - - FOREACH(_current ${_inc_DIRS}) - set(${_moc_INC_DIRS} ${${_moc_INC_DIRS}} "-I" ${_current}) - ENDFOREACH(_current ${_inc_DIRS}) - ENDMACRO(QT4_GET_MOC_INC_DIRS) - - - MACRO (QT4_GENERATE_MOC infile outfile ) - # get include dirs - QT4_GET_MOC_INC_DIRS(moc_includes) - - GET_FILENAME_COMPONENT(infile ${infile} ABSOLUTE) - - ADD_CUSTOM_COMMAND(OUTPUT ${outfile} - COMMAND ${QT_MOC_EXECUTABLE} - ARGS ${moc_includes} -o ${outfile} ${infile} - DEPENDS ${infile}) - - MACRO_ADD_FILE_DEPENDENCIES(${infile} ${outfile}) - ENDMACRO (QT4_GENERATE_MOC) - - - # QT4_WRAP_CPP(outfiles inputfile ... ) - # TODO perhaps add support for -D, -U and other minor options - - MACRO (QT4_WRAP_CPP outfiles ) - # get include dirs - QT4_GET_MOC_INC_DIRS(moc_includes) - - FOREACH (it ${ARGN}) - GET_FILENAME_COMPONENT(it ${it} ABSOLUTE) - GET_FILENAME_COMPONENT(outfile ${it} NAME_WE) - - set(outfile ${CMAKE_CURRENT_BINARY_DIR}/moc_${outfile}.cxx) - ADD_CUSTOM_COMMAND(OUTPUT ${outfile} - COMMAND ${QT_MOC_EXECUTABLE} - ARGS ${moc_includes} -o ${outfile} ${it} - DEPENDS ${it}) - set(${outfiles} ${${outfiles}} ${outfile}) - ENDFOREACH(it) - - ENDMACRO (QT4_WRAP_CPP) - - - - -macro (QT4_EXTRACT_OPTIONS _qt4_files _qt4_options) - set(${_qt4_files}) - set(${_qt4_options}) - set(_QT4_DOING_OPTIONS FALSE) - foreach (_currentArg ${ARGN}) - if ("${_currentArg}" STREQUAL "OPTIONS") - set(_QT4_DOING_OPTIONS TRUE) - else () - if (_QT4_DOING_OPTIONS) - list(APPEND ${_qt4_options} "${_currentArg}") - else() - list(APPEND ${_qt4_files} "${_currentArg}") - endif() - endif() - endforeach() -endmacro() - - # QT4_WRAP_UI(outfiles inputfile ... ) - - MACRO (QT4_WRAP_UI outfiles ) - QT4_EXTRACT_OPTIONS(ui_files_list ui_options ${ARGN}) - FOREACH (it ${ui_files_list}) - - GET_FILENAME_COMPONENT(outfile ${it} NAME_WE) - GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE) - - set(outfile ${CMAKE_CURRENT_BINARY_DIR}/ui_${outfile}.h) - ADD_CUSTOM_COMMAND(OUTPUT ${outfile} - COMMAND ${QT_UIC_EXECUTABLE} - ARGS ${ui_options} -o ${outfile} ${infile} - MAIN_DEPENDENCY ${infile}) - ENDFOREACH (it) - - ENDMACRO (QT4_WRAP_UI) - - - # QT4_ADD_RESOURCE(outfiles inputfile ... ) - # TODO perhaps consider adding support for compression and root options to rcc - - MACRO (QT4_ADD_RESOURCES outfiles ) - - FOREACH (it ${ARGN}) - GET_FILENAME_COMPONENT(outfilename ${it} NAME_WE) - GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE) - set(outfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${outfilename}.cxx) - ADD_CUSTOM_COMMAND(OUTPUT ${outfile} - COMMAND ${QT_RCC_EXECUTABLE} - ARGS -name ${outfilename} -o ${outfile} ${infile} - MAIN_DEPENDENCY ${infile} ) - set(${outfiles} ${${outfiles}} ${outfile}) - ENDFOREACH (it) - - ENDMACRO (QT4_ADD_RESOURCES) - - - MACRO(QT4_AUTOMOC) - QT4_GET_MOC_INC_DIRS(_moc_INCS) - - set(_matching_FILES ) - FOREACH (_current_FILE ${ARGN}) - - GET_FILENAME_COMPONENT(_abs_FILE ${_current_FILE} ABSOLUTE) - # if "SKIP_AUTOMOC" is set to true, we will not handle this file here. - # here. this is required to make bouic work correctly: - # we need to add generated .cpp files to the sources (to compile them), - # but we cannot let automoc handle them, as the .cpp files don't exist yet when - # cmake is run for the very first time on them -> however the .cpp files might - # exist at a later run. at that time we need to skip them, so that we don't add two - # different rules for the same moc file - GET_SOURCE_FILE_PROPERTY(_skip ${_abs_FILE} SKIP_AUTOMOC) - - IF ( NOT _skip AND EXISTS ${_abs_FILE} ) - - FILE(READ ${_abs_FILE} _contents) - - GET_FILENAME_COMPONENT(_abs_PATH ${_abs_FILE} PATH) - - STRING(REGEX MATCHALL "#include +[^ ]+\\.moc[\">]" _match "${_contents}") - IF(_match) - FOREACH (_current_MOC_INC ${_match}) - STRING(REGEX MATCH "[^ <\"]+\\.moc" _current_MOC "${_current_MOC_INC}") - - GET_filename_component(_basename ${_current_MOC} NAME_WE) - # set(_header ${CMAKE_CURRENT_SOURCE_DIR}/${_basename}.h) - set(_header ${_abs_PATH}/${_basename}.h) - set(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_current_MOC}) - ADD_CUSTOM_COMMAND(OUTPUT ${_moc} - COMMAND ${QT_MOC_EXECUTABLE} - ARGS ${_moc_INCS} ${_header} -o ${_moc} - DEPENDS ${_header} - ) - - MACRO_ADD_FILE_DEPENDENCIES(${_abs_FILE} ${_moc}) - ENDFOREACH (_current_MOC_INC) - endif() - endif() - ENDFOREACH (_current_FILE) - ENDMACRO(QT4_AUTOMOC) - - - - ###################################### - # - # decide if Qt got found - # - ###################################### - - # if the includes,libraries,moc,uic and rcc are found then we have it - IF( QT_LIBRARY_DIR AND QT_INCLUDE_DIR AND QT_MOC_EXECUTABLE AND QT_UIC_EXECUTABLE AND QT_RCC_EXECUTABLE) - set( QT4_FOUND "YES" ) - IF( NOT Qt4_FIND_QUIETLY) - message(STATUS "Found Qt-Version ${QTVERSION}") - endif() - else() - set( QT4_FOUND "NO") - IF( Qt4_FIND_REQUIRED) - message( FATAL_ERROR "Qt libraries, includes, moc, uic or/and rcc NOT found!") - endif() - endif() - set(QT_FOUND ${QT4_FOUND}) - - ####################################### - # - # Qt configuration - # - ####################################### - IF(EXISTS "${QT_MKSPECS_DIR}/qconfig.pri") - FILE(READ ${QT_MKSPECS_DIR}/qconfig.pri _qconfig_FILE_contents) - STRING(REGEX MATCH "QT_CONFIG[^\n]+" QT_QCONFIG ${_qconfig_FILE_contents}) - STRING(REGEX MATCH "CONFIG[^\n]+" QT_CONFIG ${_qconfig_FILE_contents}) - endif() - - - ############################################### - # - # configuration/system dependent settings - # - ############################################### - - set(QT_GUI_LIB_DEPENDENCIES "") - set(QT_CORE_LIB_DEPENDENCIES "") - - # shared build needs -DQT_SHARED - IF(NOT QT_CONFIG MATCHES "static") - # warning currently only qconfig.pri on Windows potentially contains "static" - # so QT_SHARED might not get defined properly on Mac/X11 (which seems harmless right now) - # Trolltech said they'd consider exporting it for all platforms in future releases. - set(QT_DEFINITIONS ${QT_DEFINITIONS} -DQT_SHARED) - endif() - - ## system png - IF(QT_QCONFIG MATCHES "system-png") - FIND_LIBRARY(QT_PNG_LIBRARY NAMES png) - set(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${QT_PNG_LIBRARY}) - MARK_AS_ADVANCED(QT_PNG_LIBRARY) - endif() - - # for X11, get X11 library directory - IF(Q_WS_X11) - QT_QUERY_QMAKE(QMAKE_LIBDIR_X11 "QMAKE_LIBDIR_X11") - endif() - - ## X11 SM - IF(QT_QCONFIG MATCHES "x11sm") - # ask qmake where the x11 libs are - FIND_LIBRARY(QT_X11_SM_LIBRARY NAMES SM PATHS ${QMAKE_LIBDIR_X11}) - FIND_LIBRARY(QT_X11_ICE_LIBRARY NAMES ICE PATHS ${QMAKE_LIBDIR_X11}) - set(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${QT_X11_SM_LIBRARY} ${QT_X11_ICE_LIBRARY}) - MARK_AS_ADVANCED(QT_X11_SM_LIBRARY) - MARK_AS_ADVANCED(QT_X11_ICE_LIBRARY) - endif() - - ## Xi - IF(QT_QCONFIG MATCHES "tablet") - FIND_LIBRARY(QT_XI_LIBRARY NAMES Xi PATHS ${QMAKE_LIBDIR_X11}) - set(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${QT_XI_LIBRARY}) - MARK_AS_ADVANCED(QT_XI_LIBRARY) - endif() - - ## Xrender - IF(QT_QCONFIG MATCHES "xrender") - FIND_LIBRARY(QT_XRENDER_LIBRARY NAMES Xrender PATHS ${QMAKE_LIBDIR_X11}) - set(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${QT_XRENDER_LIBRARY}) - MARK_AS_ADVANCED(QT_XRENDER_LIBRARY) - endif() - - ## Xrandr - IF(QT_QCONFIG MATCHES "xrandr") - FIND_LIBRARY(QT_XRANDR_LIBRARY NAMES Xrandr PATHS ${QMAKE_LIBDIR_X11}) - set(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${QT_XRANDR_LIBRARY}) - MARK_AS_ADVANCED(QT_XRANDR_LIBRARY) - endif() - - ## Xcursor - IF(QT_QCONFIG MATCHES "xcursor") - FIND_LIBRARY(QT_XCURSOR_LIBRARY NAMES Xcursor PATHS ${QMAKE_LIBDIR_X11}) - set(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${QT_XCURSOR_LIBRARY}) - MARK_AS_ADVANCED(QT_XCURSOR_LIBRARY) - endif() - - ## Xinerama - IF(QT_QCONFIG MATCHES "xinerama") - FIND_LIBRARY(QT_XINERAMA_LIBRARY NAMES Xinerama PATHS ${QMAKE_LIBDIR_X11}) - set(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${QT_XINERAMA_LIBRARY}) - MARK_AS_ADVANCED(QT_XINERAMA_LIBRARY) - endif() - - ## system-freetype - IF(QT_QCONFIG MATCHES "system-freetype") - FIND_LIBRARY(QT_FREETYPE_LIBRARY NAMES freetype) - set(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${QT_FREETYPE_LIBRARY}) - MARK_AS_ADVANCED(QT_FREETYPE_LIBRARY) - endif() - - ## fontconfig - IF(QT_QCONFIG MATCHES "fontconfig") - FIND_LIBRARY(QT_FONTCONFIG_LIBRARY NAMES fontconfig) - set(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${QT_FONTCONFIG_LIBRARY}) - MARK_AS_ADVANCED(QT_FONTCONFIG_LIBRARY) - endif() - - ## system-zlib - IF(QT_QCONFIG MATCHES "system-zlib") - FIND_LIBRARY(QT_ZLIB_LIBRARY NAMES z) - set(QT_CORE_LIB_DEPENDENCIES ${QT_CORE_LIB_DEPENDENCIES} ${QT_ZLIB_LIBRARY}) - MARK_AS_ADVANCED(QT_ZLIB_LIBRARY) - endif() - - IF(Q_WS_X11) - # X11 libraries Qt absolutely depends on - QT_QUERY_QMAKE(QT_LIBS_X11 "QMAKE_LIBS_X11") - SEPARATE_ARGUMENTS(QT_LIBS_X11) - FOREACH(QT_X11_LIB ${QT_LIBS_X11}) - STRING(REGEX REPLACE "-l" "" QT_X11_LIB "${QT_X11_LIB}") - set(QT_TMP_STR "QT_X11_${QT_X11_LIB}_LIBRARY") - FIND_LIBRARY(${QT_TMP_STR} NAMES "${QT_X11_LIB}" PATHS ${QMAKE_LIBDIR_X11}) - set(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${${QT_TMP_STR}}) - ENDFOREACH(QT_X11_LIB) - - QT_QUERY_QMAKE(QT_LIBS_THREAD "QMAKE_LIBS_THREAD") - set(QT_CORE_LIB_DEPENDENCIES ${QT_CORE_LIB_DEPENDENCIES} ${QT_LIBS_THREAD}) - - QT_QUERY_QMAKE(QMAKE_LIBS_DYNLOAD "QMAKE_LIBS_DYNLOAD") - set(QT_CORE_LIB_DEPENDENCIES ${QT_CORE_LIB_DEPENDENCIES} ${QMAKE_LIBS_DYNLOAD}) - - endif() - - IF(Q_WS_WIN) - set(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} Imm32 Winmm) - set(QT_CORE_LIB_DEPENDENCIES ${QT_CORE_LIB_DEPENDENCIES} Ws2_32) - endif() - - IF(Q_WS_MAC) - set(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} "-framework Carbon" "-framework QuickTime") - set(QT_CORE_LIB_DEPENDENCIES ${QT_CORE_LIB_DEPENDENCIES} "-framework ApplicationServices") - endif() - - ####################################### - # - # compatibility settings - # - ####################################### - # Backwards compatibility for CMake1.4 and 1.2 - set(QT_MOC_EXE ${QT_MOC_EXECUTABLE} ) - set(QT_UIC_EXE ${QT_UIC_EXECUTABLE} ) - - set( QT_QT_LIBRARY "") - -else() - - IF(Qt4_FIND_REQUIRED) - IF(QT4_INSTALLED_VERSION_TOO_OLD) - message(FATAL_ERROR "The installed Qt version ${QTVERSION} is too old, at least version ${QT_MIN_VERSION} is required") - else() - message( FATAL_ERROR "Qt qmake not found!") - endif() - else() - IF(QT4_INSTALLED_VERSION_TOO_OLD AND NOT Qt4_FIND_QUIETLY) - message(STATUS "The installed Qt version ${QTVERSION} is too old, at least version ${QT_MIN_VERSION} is required") - endif() - endif() - -endif() - diff --git a/development/cmake/modules/LyXMacros.cmake b/development/cmake/modules/LyXMacros.cmake index 2d93f46976..501da119a8 100644 --- a/development/cmake/modules/LyXMacros.cmake +++ b/development/cmake/modules/LyXMacros.cmake @@ -62,10 +62,6 @@ endmacro(LYX_ADD_UI_FILES) macro(LYX_AUTOMOC) - if (QT4_GET_MOC_INC_DIRS) - QT4_GET_MOC_INC_DIRS(_moc_INCS) - endif() - set(_matching_FILES) foreach (_current_FILE ${ARGN}) @@ -111,7 +107,7 @@ macro(LYX_AUTOMOC) #set(_moc ${_abs_PATH}/${_current_MOC}) add_custom_command(OUTPUT ${_moc} COMMAND ${QT_MOC_EXECUTABLE} - ARGS "-DQT_VERSION=${QT4_VERSION}" ${_def} ${_moc_INCS} ${_header} -o ${_moc} + ARGS "-DQT_VERSION=${QTx_VERSION}" ${_def} ${_moc_INCS} ${_header} -o ${_moc} MAIN_DEPENDENCY ${_header}) macro_add_file_dependencies(${_abs_FILE} ${_moc}) SET_SOURCE_FILES_PROPERTIES(${_moc} GENERATED) diff --git a/development/cmake/modules/LyXPaths.cmake b/development/cmake/modules/LyXPaths.cmake index aca4427e5c..658c206a1f 100644 --- a/development/cmake/modules/LyXPaths.cmake +++ b/development/cmake/modules/LyXPaths.cmake @@ -26,63 +26,59 @@ # if(NOT WIN32) - set(_prog_path ~/bin) + set(_prog_path ~/bin) else() + if(WINDEPS) + FIND_PROGRAM(LYX_QMAKE NAMES qmake) + if(NOT LYX_QMAKE) + message("------ qmake not found. Add YOUR_PATH\\lyx-windows-deps-msvc-qt4\\qt-4\\bin") + message("------ to PATH: set PATH=%PATH%;YOUR_PATH\\lyx-windows-deps-msvc-qt4\\qt-4\\bin") + message(FATAL_ERROR "Exit.") + else() + GET_FILENAME_COMPONENT(LYX_QMAKE_PATH ${LYX_QMAKE} PATH) + set(WINDEPSDIR "${LYX_QMAKE_PATH}/../..") + endif() -if(WINDEPS) - FIND_PROGRAM(LYX_QMAKE NAMES qmake) - if(NOT LYX_QMAKE) - message("------ qmake not found. Add YOUR_PATH\\lyx-windows-deps-msvc-qt4\\qt-4\\bin") - message("------ to PATH: set PATH=%PATH%;YOUR_PATH\\lyx-windows-deps-msvc-qt4\\qt-4\\bin") - message(FATAL_ERROR "Exit.") - else() - GET_FILENAME_COMPONENT(LYX_QMAKE_PATH ${LYX_QMAKE} PATH) - set(WINDEPSDIR "${LYX_QMAKE_PATH}/../..") + set(GNUWIN32_DIR ${WINDEPSDIR}) + + # don't stop in FindQt4.cmake because qmake will + # report wrong paths + set(QT_HEADERS_DIR "${WINDEPSDIR}/qt-4/include" CACHE STRING "Qt4 headers directory" FORCE) + set(QT_LIBRARY_DIR "${WINDEPSDIR}/qt-4/lib" CACHE STRING "Qt4 libraries directory" FORCE) + set(QT_BINARY_DIR "${WINDEPSDIR}/qt-4/bin" CACHE STRING "Qt4 binaries directory" FORCE) + set(QT_MKSPECS_DIR "${WINDEPSDIR}/qt-4/mkspecs" CACHE STRING "Qt4 mkspecs directory" FORCE) + set(QT_PLUGINS_DIR "${WINDEPSDIR}/qt-4/plugins" CACHE STRING "Qt4 plugins directory" FORCE) + set(QT_MOC_EXECUTABLE "${WINDEPSDIR}/qt-4/bin/moc.exe" CACHE STRING "Qt4 moc executable" FORCE) + set(QT_UIC_EXECUTABLE "${WINDEPSDIR}/qt-4/bin/uic.exe" CACHE STRING "Qt4 uic executable" FORCE) + set(QT_RCC_EXECUTABLE "${WINDEPSDIR}/qt-4/bin/rcc.exe" CACHE STRING "Qt4 rcc executable" FORCE) + endif() + + find_package(GNUWIN32 REQUIRED) + if(LYX_3RDPARTY_BUILD) + file(TO_CMAKE_PATH "$ENV{PROGRAMFILES}" _prog_path) + else() + file(TO_CMAKE_PATH "$ENV{PROGRAMFILES}" _prog_path) + + set(_zlib_path ${_prog_path}/zlib) + set(_iconv_path ${_prog_path}/iconv) + + set(_gnuwin32_dir ${GNUWIN32_DIR}) + + set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} + ${_gnuwin32_dir}/include + ${_zlib_path}/include + ${_iconv_path}/include) + + set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} + ${_gnuwin32_dir}/lib + ${_zlib_path}/lib + ${_iconv_path}/lib) + + #chek_include_files path + set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${_gnuwin32_dir}/include) endif() - - set(GNUWIN32_DIR ${WINDEPSDIR}) - - # don't stop in FindQt4.cmake because qmake will - # report wrong paths - set(QT_HEADERS_DIR "${WINDEPSDIR}/qt-4/include" CACHE STRING "Qt4 headers directory" FORCE) - set(QT_LIBRARY_DIR "${WINDEPSDIR}/qt-4/lib" CACHE STRING "Qt4 libraries directory" FORCE) - set(QT_BINARY_DIR "${WINDEPSDIR}/qt-4/bin" CACHE STRING "Qt4 binaries directory" FORCE) - set(QT_MKSPECS_DIR "${WINDEPSDIR}/qt-4/mkspecs" CACHE STRING "Qt4 mkspecs directory" FORCE) - set(QT_PLUGINS_DIR "${WINDEPSDIR}/qt-4/plugins" CACHE STRING "Qt4 plugins directory" FORCE) - set(QT_MOC_EXECUTABLE "${WINDEPSDIR}/qt-4/bin/moc.exe" CACHE STRING "Qt4 moc executable" FORCE) - set(QT_UIC_EXECUTABLE "${WINDEPSDIR}/qt-4/bin/uic.exe" CACHE STRING "Qt4 uic executable" FORCE) - set(QT_RCC_EXECUTABLE "${WINDEPSDIR}/qt-4/bin/rcc.exe" CACHE STRING "Qt4 rcc executable" FORCE) endif() -find_package(GNUWIN32 REQUIRED) -if(LYX_3RDPARTY_BUILD) - file(TO_CMAKE_PATH "$ENV{PROGRAMFILES}" _prog_path) -else() - - file(TO_CMAKE_PATH "$ENV{PROGRAMFILES}" _prog_path) - - set(_zlib_path ${_prog_path}/zlib) - set(_iconv_path ${_prog_path}/iconv) - - set(_gnuwin32_dir ${GNUWIN32_DIR}) - - set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} - ${_gnuwin32_dir}/include - ${_zlib_path}/include - ${_iconv_path}/include) - - set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} - ${_gnuwin32_dir}/lib - ${_zlib_path}/lib - ${_iconv_path}/lib) - - #chek_include_files path - set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${_gnuwin32_dir}/include) -endif() - -endif() - - if(WIN32) set(locale_dir Resources/locale) else() diff --git a/development/cmake/post_install/CMakeLists.txt b/development/cmake/post_install/CMakeLists.txt index f0eea8452d..52a2f782af 100644 --- a/development/cmake/post_install/CMakeLists.txt +++ b/development/cmake/post_install/CMakeLists.txt @@ -36,10 +36,6 @@ if(LYX_BUNDLE) endif() install_qt_plugin("Qt5::QCocoaIntegrationPlugin") endif() - else() - # With QT4, just copy all the plugins - file(GLOB QT_PLUGIN_DIRECTORIES "${QT_PLUGINS_DIR}/*") - install(DIRECTORY ${QT_PLUGIN_DIRECTORIES} DESTINATION "${qtplugin_dest_dir}/plugins/" COMPONENT Runtime) endif() # Install code does the following: diff --git a/development/lyxserver/server_monitor.cpp b/development/lyxserver/server_monitor.cpp index dc4f15d05a..0b28fe6a2e 100644 --- a/development/lyxserver/server_monitor.cpp +++ b/development/lyxserver/server_monitor.cpp @@ -11,8 +11,8 @@ * receives information back from LyX. * * Build instructions: - * 1) Run moc or moc-qt4 on server_monitor.h to produce moc_server_monitor.cpp: - * moc-qt4 server_monitor.h -o moc_server_monitor.cpp + * 1) Run moc or moc-qt5 on server_monitor.h to produce moc_server_monitor.cpp: + * moc server_monitor.h -o moc_server_monitor.cpp * 2) If the QtGui.pc file is not in the pkg-config search path, find the * directory where it is located (e.g., use the command `locate QtGui.pc') * and set the environment variable PKG_CONFIG_PATH to this directory. @@ -22,7 +22,7 @@ * If the command `pkg-config --modversion QtGui' does not complain and * prints the Qt version, you don't need to set PKG_CONFIG_PATH. * 3) Compile using the following command: - * g++ server_monitor.cpp -o monitor -I. `pkg-config --cflags --libs QtGui` + * g++ -fPIC server_monitor.cpp -o monitor -I. `pkg-config --cflags --libs Qt5Gui Qt5Widgets` * * Alternatively, you can create a Makefile with qmake and then build * the executable by running make (or nmake, if you use msvc): @@ -41,9 +41,7 @@ #include #include #include -#if QT_VERSION >= 0x050000 #include -#endif #include "server_monitor.h" diff --git a/development/lyxserver/server_monitor.pro b/development/lyxserver/server_monitor.pro index 934b176778..d5f40bc40b 100644 --- a/development/lyxserver/server_monitor.pro +++ b/development/lyxserver/server_monitor.pro @@ -1,4 +1,4 @@ CONFIG += console HEADERS += server_monitor.h SOURCES += server_monitor.cpp -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets +QT += widgets diff --git a/lib/RELEASE-NOTES b/lib/RELEASE-NOTES index 7e817359f4..bd562bf802 100644 --- a/lib/RELEASE-NOTES +++ b/lib/RELEASE-NOTES @@ -222,7 +222,8 @@ !!Changes with respect to external programs and libraries in 2.4: * The Qt5 libraries are now used by default. In order to link against - Qt4 the configure option --disable-qt5 has to be used. + Qt6 the configure option --enable-qt6 has to be used. Qt4 is not + supported anymore. * The dependency on pplatex/dvipost was dropped. diff --git a/lib/fonts/test/check_glyphs.lyx b/lib/fonts/test/check_glyphs.lyx index f32ef31875..b4d5c5f5df 100644 --- a/lib/fonts/test/check_glyphs.lyx +++ b/lib/fonts/test/check_glyphs.lyx @@ -1,5 +1,5 @@ #LyX 2.4 created this file. For more info see https://www.lyx.org/ -\lyxformat 598 +\lyxformat 610 \begin_document \begin_header \save_transient_properties true @@ -83,6 +83,7 @@ \html_css_as_file 0 \html_be_strict false \docbook_table_output 0 +\docbook_mathml_prefix 1 \end_header \begin_body @@ -562,8 +563,9 @@ This file contains each symbol of the font stmary10.ttf that is made accessible \end_layout \begin_layout Standard -The critical codepoints (9,10,12,13) for qt4/qt5 transition (compare mathed - and instant preview result): +The codepoints (9,10,12,13) are not displayed correctly by Qt. + We work around this by duplicating the glyphs on our TeX fonts. + (compare mathed and instant preview result): \end_layout \begin_layout Standard diff --git a/lib/symbols b/lib/symbols index 9c33bce56a..dbcae9f7c2 100644 --- a/lib/symbols +++ b/lib/symbols @@ -871,15 +871,13 @@ Ydown stmry 5 0 mathbin x x stmaryrd Yleft stmry 6 0 mathbin x x stmaryrd Yright stmry 7 0 mathbin x x stmaryrd varcurlyvee stmry 8 0 mathbin x x stmaryrd -# qt4 does not display characters at the \t position (0x09) -# therefore our .ttf font contains a copy at 170 (0xaa) -#varcurlywedge stmry 9 0 mathbin x x stmaryrd -#10,12,13 codepoints broken in qt5 +# qt does not display characters at codepoints 9, 10,12,13 +# therefore our copies of the TeX fonts have duplicate glyphs after 170 varcurlywedge stmry 170 0 mathbin x x stmaryrd minuso stmry 171 0 mathbin x x stmaryrd baro stmry 11 0 mathbin x x stmaryrd sslash stmry 172 0 mathbin x x stmaryrd -#for whatever reason qt5 refuses to display anything at position 173 +#for whatever reason qt refuses to display anything at position 173 bbslash stmry 174 0 mathbin x x stmaryrd moo stmry 14 0 mathbin x x stmaryrd varotimes stmry 15 0 mathbin x x stmaryrd diff --git a/src/frontends/qt/CMakeLists.txt b/src/frontends/qt/CMakeLists.txt index 38f330143d..a007c2f492 100644 --- a/src/frontends/qt/CMakeLists.txt +++ b/src/frontends/qt/CMakeLists.txt @@ -13,7 +13,6 @@ endif() file(GLOB moc_files ${TOP_SRC_DIR}/src/frontends/qt/${LYX_MOC_FILES}) list(REMOVE_ITEM frontends_qt_sources ${moc_files} .) -list(REMOVE_ITEM frontends_qt_sources ${TOP_SRC_DIR}/src/frontends/qt/liblyxqt4.cpp) file(GLOB frontends_qt_headers ${TOP_SRC_DIR}/src/frontends/qt/${LYX_HPP_FILES}) file(GLOB frontend_qt_UI ${TOP_SRC_DIR}/src/frontends/qt/ui/*.ui) diff --git a/src/frontends/qt/FancyLineEdit.cpp b/src/frontends/qt/FancyLineEdit.cpp index b9874d2e89..666ad5fdce 100644 --- a/src/frontends/qt/FancyLineEdit.cpp +++ b/src/frontends/qt/FancyLineEdit.cpp @@ -19,8 +19,6 @@ #include "GuiApplication.h" #endif -#if QT_VERSION >= 0x040600 - #include #include #include @@ -33,9 +31,7 @@ #include #include #include -#if QT_VERSION >= 0x050000 #include -#endif enum { margin = 6 }; @@ -120,7 +116,7 @@ FancyLineEdit::FancyLineEdit(QWidget *parent) : { ensurePolished(); updateMargins(); - + connect(this, SIGNAL(textChanged(QString)), this, SLOT(checkButtons(QString))); connect(m_d->m_iconbutton[Left], SIGNAL(clicked()), @@ -198,10 +194,8 @@ void FancyLineEdit::updateMargins() Side realRight = (leftToRight ? Right : Left); qreal dpr = 1.0; -#if QT_VERSION >= 0x050000 // Consider device/pixel ratio (HiDPI) dpr = devicePixelRatio(); -#endif int leftMargin = (m_d->m_iconbutton[realLeft]->pixmap().width() / dpr ) + 8; int rightMargin = (m_d->m_iconbutton[realRight]->pixmap().width() / dpr) + 8; // Note KDE does not reserve space for the highlight color @@ -224,7 +218,7 @@ void FancyLineEdit::updateButtonPositions() Side iconpos = (Side)i; if (layoutDirection() == Qt::RightToLeft) iconpos = (iconpos == Left ? Right : Left); - + if (iconpos == FancyLineEdit::Right) { const int iconoffset = textMargins().right() + 4; m_d->m_iconbutton[i]->setGeometry( @@ -342,12 +336,9 @@ IconButton::IconButton(QWidget *parent) void IconButton::paintEvent(QPaintEvent *) { - qreal dpr = 1.0; -#if QT_VERSION >= 0x050000 // Consider device/pixel ratio (HiDPI) QWindow * window = this->window()->windowHandle(); - dpr = window->devicePixelRatio(); -#endif + qreal const dpr = window->devicePixelRatio(); QRect pixmapRect(QPoint(), m_pixmap.size() / dpr); pixmapRect.moveCenter(rect().center()); QPixmap pm = m_pixmap; @@ -381,6 +372,4 @@ void IconButton::animateShow(bool visible) } // namespace lyx -#endif // QT_VERSION >= 0x040600 - #include "moc_FancyLineEdit.cpp" diff --git a/src/frontends/qt/GuiApplication.cpp b/src/frontends/qt/GuiApplication.cpp index ff33065fe3..d04511ae7f 100644 --- a/src/frontends/qt/GuiApplication.cpp +++ b/src/frontends/qt/GuiApplication.cpp @@ -122,26 +122,16 @@ #include #include -#ifdef Q_WS_X11 -#include -#include -#include -#undef CursorShape -#undef None -#elif defined(QPA_XCB) +#if defined(QPA_XCB) #include #ifdef HAVE_QT5_X11_EXTRAS #include #endif #endif -#if (QT_VERSION < 0x050000) || (QT_VERSION >= 0x050400) +#if (QT_VERSION >= 0x050400) #if defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN) -#if (QT_VERSION < 0x050000) -#include -#define QWINDOWSMIME QWindowsMime -#define QVARIANTTYPE QVariant::Type -#elif (QT_VERSION >= 0x060000) +#if (QT_VERSION >= 0x060000) #include #include #include @@ -177,7 +167,7 @@ namespace lyx { frontend::Application * createApplication(int & argc, char * argv[]) { -#if !defined(Q_WS_X11) && !defined(QPA_XCB) +#if !defined(QPA_XCB) // prune -geometry argument(s) by shifting // the following ones 2 places down. for (int i = 0 ; i < argc ; ++i) { @@ -719,7 +709,6 @@ QPixmap getPixmap(QString const & path, QString const & name, QString const & ex QIcon getIcon(FuncRequest const & f, bool unknown, bool rtl) { -#if (QT_VERSION >= 0x040600) if (lyxrc.use_system_theme_icons) { // use the icons from system theme that are available QString action = toqstr(lyxaction.getActionName(f.action())); @@ -732,7 +721,6 @@ QIcon getIcon(FuncRequest const & f, bool unknown, bool rtl) return thmicn; } } -#endif IconInfo icondata = iconInfo(f, unknown, rtl); if (icondata.filepath.isEmpty()) @@ -784,11 +772,7 @@ public: QString translate(const char * /* context */, const char *sourceText, -#if QT_VERSION >= 0x050000 const char * /* disambiguation */ = nullptr, int /* n */ = -1) const override -#else - const char * /*comment*/ = 0) const override -#endif { // Here we declare the strings that need to be translated from Qt own GUI // This is needed to include these strings to po files @@ -879,7 +863,7 @@ public: //////////////////////////////////////////////////////////////////////// // Windows specific stuff goes here... -#if (QT_VERSION < 0x050000) || (QT_VERSION >= 0x050400) +#if (QT_VERSION >= 0x050400) #if defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN) // QWindowsMimeMetafile can only be compiled on Windows. @@ -1045,7 +1029,7 @@ struct GuiApplication::Private , last_state_(Qt::ApplicationInactive) #endif { - #if (QT_VERSION < 0x050000) || (QT_VERSION >= 0x050400) + #if (QT_VERSION >= 0x050400) #if defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN) /// WMF Mime handler for Windows clipboard. wmf_mime_ = new QWindowsMimeMetafile; @@ -1134,7 +1118,7 @@ struct GuiApplication::Private QMacPasteboardMimeGraphics mac_pasteboard_mime_; #endif -#if (QT_VERSION < 0x050000) || (QT_VERSION >= 0x050400) +#if (QT_VERSION >= 0x050400) #if defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN) /// WMF Mime handler for Windows clipboard. QWindowsMimeMetafile * wmf_mime_; @@ -1213,7 +1197,7 @@ GuiApplication::GuiApplication(int & argc, char ** argv) #endif #endif -#if defined(Q_WS_X11) || defined(QPA_XCB) +#if defined(QPA_XCB) // doubleClickInterval() is 400 ms on X11 which is just too long. // On Windows and Mac OS X, the operating system's value is used. // On Microsoft Windows, calling this function sets the double @@ -1239,11 +1223,8 @@ GuiApplication::GuiApplication(int & argc, char ** argv) if (lyxrc.typewriter_font_name.empty()) lyxrc.typewriter_font_name = fromqstr(typewriterFontName()); -#if (QT_VERSION >= 0x050000) - // Qt4 does this in event(), see below. // Track change of keyboard connect(inputMethod(), SIGNAL(localeChanged()), this, SLOT(onLocaleChanged())); -#endif d->general_timer_.setInterval(500); connect(&d->general_timer_, SIGNAL(timeout()), @@ -1266,36 +1247,9 @@ GuiApplication * theGuiApp() } -#if QT_VERSION < 0x050000 -// Emulate platformName() for Qt4 - -// FIXME: when ditching this method, remove all tests -// platformName() == "qt4x11" -// in the code -QString GuiApplication::platformName() const -{ -# if defined(Q_WS_X11) - // Note that this one does not really exist - return "qt4x11"; -# elif defined(Q_OS_MAC) - return "cocoa"; -# elif defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN) - return "windows"; -# else - LYXERR0("Unknown platform!"); - return "unknown"; -# endif -} -#endif - - double GuiApplication::pixelRatio() const { -#if QT_VERSION >= 0x050000 return qt_scale_factor * devicePixelRatio(); -#else - return 1.0; -#endif } @@ -2363,11 +2317,7 @@ docstring GuiApplication::viewStatusMessage() string GuiApplication::inputLanguageCode() const { -#if (QT_VERSION < 0x050000) - QLocale loc = keyboardInputLocale(); -#else QLocale loc = inputMethod()->locale(); -#endif //LYXERR0("input lang = " << fromqstr(loc.name())); return loc.name() == "C" ? "en_US" : fromqstr(loc.name()); } @@ -2862,12 +2812,10 @@ void GuiApplication::execBatchCommands() return; #ifdef Q_OS_MAC -#if QT_VERSION > 0x040600 setAttribute(Qt::AA_MacDontSwapCtrlAndMeta,lyxrc.mac_dontswap_ctrl_meta); -#endif -#if QT_VERSION >= 0x050000 && QT_VERSION < 0x060000 +# if QT_VERSION < 0x060000 setAttribute(Qt::AA_UseHighDpiPixmaps,true); -#endif +# endif // Create the global default menubar which is shown for the dialogs // and if no GuiView is visible. // This must be done after the session was recovered to know the "last files". @@ -3033,15 +2981,6 @@ bool GuiApplication::event(QEvent * e) e->accept(); return true; } -#if (QT_VERSION < 0x050000) - // Qt5 uses a signal for that, see above. - case QEvent::KeyboardLayoutChange: - //LYXERR0("keyboard change"); - if (currentView() && currentView()->currentBufferView()) - currentView()->currentBufferView()->cursor().setLanguageFromInput(); - e->accept(); - return true; -#endif case QEvent::ApplicationPaletteChange: { // runtime switch from/to dark mode onPaletteChanged(); @@ -3551,56 +3490,7 @@ bool GuiApplication::longOperationStarted() { // // X11 specific stuff goes here... -#ifdef Q_WS_X11 -bool GuiApplication::x11EventFilter(XEvent * xev) -{ - if (!current_view_) - return false; - - switch (xev->type) { - case SelectionRequest: { - if (xev->xselectionrequest.selection != XA_PRIMARY) - break; - LYXERR(Debug::SELECTION, "X requested selection."); - BufferView * bv = current_view_->currentBufferView(); - if (bv) { - docstring const sel = bv->requestSelection(); - if (!sel.empty()) { - d->selection_.put(sel); - // Refresh the selection request timestamp. - // We have to do this by ourselves as Qt seems - // not doing that, maybe because of our - // "persistent selection" implementation - // (see comments in GuiSelection.cpp). - XSelectionEvent nev; - nev.type = SelectionNotify; - nev.display = xev->xselectionrequest.display; - nev.requestor = xev->xselectionrequest.requestor; - nev.selection = xev->xselectionrequest.selection; - nev.target = xev->xselectionrequest.target; - nev.property = 0L; // None - nev.time = CurrentTime; - XSendEvent(QX11Info::display(), - nev.requestor, False, 0, - reinterpret_cast(&nev)); - return true; - } - } - break; - } - case SelectionClear: { - if (xev->xselectionclear.selection != XA_PRIMARY) - break; - LYXERR(Debug::SELECTION, "Lost selection."); - BufferView * bv = current_view_->currentBufferView(); - if (bv) - bv->clearSelection(); - break; - } - } - return false; -} -#elif defined(QPA_XCB) +#if defined(QPA_XCB) bool GuiApplication::nativeEventFilter(const QByteArray & eventType, void * message, long *) { diff --git a/src/frontends/qt/GuiApplication.h b/src/frontends/qt/GuiApplication.h index e40815e8be..f0483c315a 100644 --- a/src/frontends/qt/GuiApplication.h +++ b/src/frontends/qt/GuiApplication.h @@ -117,9 +117,7 @@ public: //@{ bool notify(QObject * receiver, QEvent * event) override; void commitData(QSessionManager & sm); -#ifdef Q_WS_X11 - bool x11EventFilter(XEvent * ev) override; -#elif defined(QPA_XCB) +#if defined(QPA_XCB) virtual bool nativeEventFilter(const QByteArray & eventType, void * message, long * result) override; #endif @@ -164,21 +162,12 @@ public: /// GuiView & view(int id) const; -#if (QT_VERSION < 0x050000) - /// Emulate platformName() for Qt4 - QString platformName() const; -#endif - /// Current ratio between physical pixels and device-independent pixels double pixelRatio() const; /// How to load image files support::search_mode imageSearchMode() const { -#if QT_VERSION >= 0x050000 return pixelRatio() > 1 ? support::check_hidpi : support::must_exist; -#else - return support::must_exist; -#endif } /// return true if the key is part of a shortcut diff --git a/src/frontends/qt/GuiBibtex.cpp b/src/frontends/qt/GuiBibtex.cpp index 3c71884246..b9c928a2de 100644 --- a/src/frontends/qt/GuiBibtex.cpp +++ b/src/frontends/qt/GuiBibtex.cpp @@ -108,13 +108,8 @@ GuiBibtex::GuiBibtex(GuiView & lv) this, SLOT(filterChanged(QString))); connect(filter_, SIGNAL(returnPressed()), this, SLOT(filterPressed())); -#if (QT_VERSION < 0x050000) - connect(filter_, SIGNAL(downPressed()), - availableLV, SLOT(setFocus())); -#else connect(filter_, &FancyLineEdit::downPressed, availableLV, [this](){ focusAndHighlight(availableLV); }); -#endif availableLV->setToolTip(formatToolTip(qt_("This list consists of all databases that are indexed by LaTeX and thus are found without a file path. " "This is usually everything in the bib/ subdirectory of LaTeX's texmf tree. " @@ -129,11 +124,7 @@ GuiBibtex::GuiBibtex(GuiView & lv) bc().addReadOnly(bibtocCB); bc().addReadOnly(bibEncodingCO); -#if (QT_VERSION < 0x050000) - selectedLV->horizontalHeader()->setResizeMode(QHeaderView::Stretch); -#else selectedLV->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); -#endif // Always put the default encoding in the first position. bibEncodingCO->addItem(qt_("Document Encoding"), "default"); diff --git a/src/frontends/qt/GuiCitation.cpp b/src/frontends/qt/GuiCitation.cpp index 4b5548803b..c5fa266310 100644 --- a/src/frontends/qt/GuiCitation.cpp +++ b/src/frontends/qt/GuiCitation.cpp @@ -153,13 +153,8 @@ GuiCitation::GuiCitation(GuiView & lv) this, SLOT(filterChanged(QString))); connect(filter_, SIGNAL(returnPressed()), this, SLOT(filterPressed())); -#if (QT_VERSION < 0x050000) - connect(filter_, SIGNAL(downPressed()), - availableLV, SLOT(setFocus())); -#else connect(filter_, &FancyLineEdit::downPressed, availableLV, [this](){ focusAndHighlight(availableLV); }); -#endif connect(regexp_, SIGNAL(triggered()), this, SLOT(regexChanged())); connect(casesense_, SIGNAL(triggered()), @@ -167,11 +162,7 @@ GuiCitation::GuiCitation(GuiView & lv) connect(instant_, SIGNAL(triggered(bool)), this, SLOT(instantChanged(bool))); -#if (QT_VERSION < 0x050000) - selectedLV->horizontalHeader()->setResizeMode(QHeaderView::Stretch); -#else selectedLV->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); -#endif selectedLV->setToolTip(qt_("Ordered list of all cited references.\n" "You can reorder, add and remove references with the buttons on the left.")); diff --git a/src/frontends/qt/GuiCompleter.cpp b/src/frontends/qt/GuiCompleter.cpp index 281ff355bb..2aee436912 100644 --- a/src/frontends/qt/GuiCompleter.cpp +++ b/src/frontends/qt/GuiCompleter.cpp @@ -455,8 +455,8 @@ void GuiCompleter::asyncUpdatePopup() // has a bad memory about it and we have to tell him again and again. QTreeView * listView = static_cast(popup()); listView->header()->setStretchLastSection(false); - setSectionResizeMode(listView->header(), 0, QHeaderView::Stretch); - setSectionResizeMode(listView->header(), 1, QHeaderView::Fixed); + listView->header()->setSectionResizeMode(0, QHeaderView::Stretch); + listView->header()->setSectionResizeMode(1, QHeaderView::Fixed); listView->header()->resizeSection(1, 22); // show/update popup diff --git a/src/frontends/qt/GuiDocument.cpp b/src/frontends/qt/GuiDocument.cpp index b3f31302dd..83581d0bd5 100644 --- a/src/frontends/qt/GuiDocument.cpp +++ b/src/frontends/qt/GuiDocument.cpp @@ -909,13 +909,8 @@ GuiDocument::GuiDocument(GuiView & lv) masterChildModule->childrenTW->setColumnCount(2); masterChildModule->childrenTW->headerItem()->setText(0, qt_("Child Document")); masterChildModule->childrenTW->headerItem()->setText(1, qt_("Include to Output")); -#if (QT_VERSION > 0x050000) - masterChildModule->childrenTW->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents); - masterChildModule->childrenTW->header()->setSectionResizeMode(1, QHeaderView::ResizeToContents); -#else - masterChildModule->childrenTW->header()->setResizeMode(0, QHeaderView::ResizeToContents); - masterChildModule->childrenTW->header()->setResizeMode(1, QHeaderView::ResizeToContents); -#endif + masterChildModule->childrenTW->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents); + masterChildModule->childrenTW->header()->setSectionResizeMode(1, QHeaderView::ResizeToContents); // Formats outputModule = new UiWidget(this); @@ -1356,7 +1351,7 @@ GuiDocument::GuiDocument(GuiView & lv) numberingModule->tocTW->headerItem()->setText(0, qt_("Example")); numberingModule->tocTW->headerItem()->setText(1, qt_("Numbered")); numberingModule->tocTW->headerItem()->setText(2, qt_("Appears in TOC")); - setSectionResizeMode(numberingModule->tocTW->header(), QHeaderView::ResizeToContents); + numberingModule->tocTW->header()->setSectionResizeMode(QHeaderView::ResizeToContents); connect(numberingModule->linenoCB, SIGNAL(toggled(bool)), this, SLOT(linenoToggled(bool))); connect(numberingModule->linenoCB, SIGNAL(clicked()), @@ -1446,7 +1441,7 @@ GuiDocument::GuiDocument(GuiView & lv) headers << qt_("Package") << qt_("Load automatically") << qt_("Load always") << qt_("Do not load"); mathsModule->packagesTW->setHorizontalHeaderLabels(headers); - setSectionResizeMode(mathsModule->packagesTW->horizontalHeader(), QHeaderView::Stretch); + mathsModule->packagesTW->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); map const & packages = BufferParams::auto_packages(); mathsModule->packagesTW->setRowCount(packages.size()); int packnum = 0; @@ -1649,10 +1644,10 @@ GuiDocument::GuiDocument(GuiView & lv) // Modules modulesModule = new UiWidget(this); modulesModule->availableLV->header()->setVisible(false); - setSectionResizeMode(modulesModule->availableLV->header(), QHeaderView::ResizeToContents); + modulesModule->availableLV->header()->setSectionResizeMode(QHeaderView::ResizeToContents); modulesModule->availableLV->header()->setStretchLastSection(false); modulesModule->selectedLV->header()->setVisible(false); - setSectionResizeMode(modulesModule->selectedLV->header(), QHeaderView::ResizeToContents); + modulesModule->selectedLV->header()->setSectionResizeMode(QHeaderView::ResizeToContents); modulesModule->selectedLV->header()->setStretchLastSection(false); selectionManager = new ModuleSelectionManager(this, modulesModule->availableLV, @@ -1679,13 +1674,8 @@ GuiDocument::GuiDocument(GuiView & lv) this, SLOT(moduleFilterChanged(QString))); connect(filter_, SIGNAL(returnPressed()), this, SLOT(moduleFilterPressed())); -#if (QT_VERSION < 0x050000) - connect(filter_, SIGNAL(downPressed()), - modulesModule->availableLV, SLOT(setFocus())); -#else connect(filter_, &FancyLineEdit::downPressed, modulesModule->availableLV, [this](){ focusAndHighlight(modulesModule->availableLV); }); -#endif // PDF support @@ -1793,11 +1783,6 @@ GuiDocument::GuiDocument(GuiView & lv) docPS->addPanel(outputModule, N_("Formats[[output]]")); docPS->addPanel(preambleModule, N_("LaTeX Preamble")); docPS->setCurrentPanel("Document Class"); -// FIXME: hack to work around resizing bug in Qt >= 4.2 -// bug verified with Qt 4.2.{0-3} (JSpitzm) -#if QT_VERSION >= 0x040200 - docPS->updateGeometry(); -#endif } diff --git a/src/frontends/qt/GuiFontLoader.cpp b/src/frontends/qt/GuiFontLoader.cpp index a47e555092..ea3f1965f2 100644 --- a/src/frontends/qt/GuiFontLoader.cpp +++ b/src/frontends/qt/GuiFontLoader.cpp @@ -66,27 +66,9 @@ namespace { struct SymbolFont { FontFamily lyx_family; QString family; -#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) - QString xlfd; -#endif }; SymbolFont symbol_fonts[] = { -#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) - { SYMBOL_FAMILY,"symbol", "-*-symbol-*-*-*-*-*-*-*-*-*-*-adobe-fontspecific"}, - { CMR_FAMILY, "cmr10", "-*-cmr10-medium-*-*-*-*-*-*-*-*-*-*-*" }, - { CMSY_FAMILY, "cmsy10", "-*-cmsy10-*-*-*-*-*-*-*-*-*-*-*-*" }, - { CMM_FAMILY, "cmmi10", "-*-cmmi10-medium-*-*-*-*-*-*-*-*-*-*-*" }, - { CMEX_FAMILY, "cmex10", "-*-cmex10-*-*-*-*-*-*-*-*-*-*-*-*" }, - { MSA_FAMILY, "msam10", "-*-msam10-*-*-*-*-*-*-*-*-*-*-*-*" }, - { MSB_FAMILY, "msbm10", "-*-msbm10-*-*-*-*-*-*-*-*-*-*-*-*" }, - { DS_FAMILY, "dsrom10", "-*-dsrom10-*-*-*-*-*-*-*-*-*-*-*-*" }, - { EUFRAK_FAMILY,"eufm10", "-*-eufm10-medium-*-*-*-*-*-*-*-*-*-*-*" }, - { RSFS_FAMILY, "rsfs10", "-*-rsfs10-medium-*-*-*-*-*-*-*-*-*-*-*" }, - { STMARY_FAMILY,"stmary10","-*-stmary10-medium-*-*-*-*-*-*-*-*-*-*-*" }, - { WASY_FAMILY, "wasy10", "-*-wasy10-medium-*-*-*-*-*-*-*-*-*-*-*" }, - { ESINT_FAMILY, "esint10","-*-esint10-medium-*-*-*-*-*-*-*-*-*-*-*" } -#else { SYMBOL_FAMILY,"symbol"}, { CMR_FAMILY, "cmr10"}, { CMSY_FAMILY, "cmsy10"}, @@ -100,7 +82,6 @@ SymbolFont symbol_fonts[] = { { STMARY_FAMILY,"stmary10"}, { WASY_FAMILY, "wasy10"}, { ESINT_FAMILY, "esint10"} -#endif }; size_t const nr_symbol_fonts = sizeof(symbol_fonts) / sizeof(symbol_fonts[0]); @@ -147,19 +128,6 @@ GuiFontInfo & fontinfo(FontInfo const & f) } -#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) -QString rawName(QString const & family) -{ - for (size_t i = 0; i < nr_symbol_fonts; ++i) - if (family == symbol_fonts[i].family) - return symbol_fonts[i].xlfd; - - LYXERR(Debug::FONT, "BUG: family not found !"); - return QString(); -} -#endif - - QString symbolFamily(FontFamily family) { for (size_t i = 0; i < nr_symbol_fonts; ++i) { @@ -190,10 +158,7 @@ static bool isChosenFont(QFont & font, QString const & family, LYXERR_NOPOS(Debug::FONT, "got: " << fi.family()); if (fi.family().contains(family) -#if QT_VERSION >= 0x040800 - && (style.isEmpty() || fi.styleName().contains(style)) -#endif - ) { + && (style.isEmpty() || fi.styleName().contains(style))) { LYXERR_NOENDL(Debug::FONT, " got it "); return true; } @@ -209,8 +174,7 @@ QFont symbolFont(QString const & family, bool * ok) upper[0] = family[0].toUpper(); QFont font; - if (guiApp->platformName() == "qt4x11" - || guiApp->platformName() == "xcb" + if (guiApp->platformName() == "xcb" || guiApp->platformName().contains("wayland")) { // On *nix we have to also specify the foundry to be able to // discriminate our fonts when the texlive fonts are managed by @@ -220,7 +184,6 @@ QFont symbolFont(QString const & family, bool * ok) font.setFamily(family); } font.setStyleStrategy(QFont::NoFontMerging); -#if QT_VERSION >= 0x040800 font.setStyleName("LyX"); if (isChosenFont(font, family, "LyX")) { @@ -231,7 +194,6 @@ QFont symbolFont(QString const & family, bool * ok) LYXERR_NOENDL(Debug::FONT, "Trying normal " << family << " ... "); font.setStyleName(QString()); -#endif if (isChosenFont(font, family, QString())) { LYXERR_NOPOS(Debug::FONT, "normal!"); @@ -248,20 +210,6 @@ QFont symbolFont(QString const & family, bool * ok) return font; } -#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) - // A simple setFamily() fails on Qt 2 - - QString const raw = rawName(family); - LYXERR_NOENDL(Debug::FONT, "Trying " << raw << " ... "); - font.setRawName(raw); - - if (isChosenFont(font, family, QString())) { - LYXERR_NOPOS(Debug::FONT, "raw version!"); - *ok = true; - return font; - } -#endif - LYXERR_NOPOS(Debug::FONT, " FAILED :-("); *ok = false; return font; @@ -336,15 +284,6 @@ QFont makeQFont(FontInfo const & f) QString family = makeFontName(toqstr(lyxrc.roman_font_name), toqstr(lyxrc.roman_font_foundry)); font.setFamily(family); -#ifdef Q_OS_MAC -#if QT_VERSION >= 0x040300 //&& QT_VERSION < 0x040800 - // Workaround for a Qt bug, see http://www.lyx.org/trac/ticket/3684 - // and http://bugreports.qt.nokia.com/browse/QTBUG-11145. - // FIXME: Check whether this is really fixed in Qt 4.8 - if (family == "Times" && !font.exactMatch()) - font.setFamily("Times New Roman"); -#endif -#endif break; } case SANS_FAMILY: @@ -394,10 +333,6 @@ QFont makeQFont(FontInfo const & f) else LYXERR(Debug::FONT, "This font is NOT an exact match"); -#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) - LYXERR(Debug::FONT, "XFLD: " << font.rawName()); -#endif - font.setPointSizeF(f.realSize() * lyxrc.currentZoom / 100.0); LYXERR(Debug::FONT, "The font has size: " << font.pointSizeF()); @@ -451,15 +386,12 @@ bool FontLoader::available(FontInfo const & f) bool FontLoader::canBeDisplayed(char_type c) { - // bug 8493 - if (c == 0x0009) - // FIXME check whether this is still needed for Qt5 + // bug 8493: with Qt5, characters with codepoints 9, 10, 12 and 13 + // are rendered as spaces. We handle that in our TeX fonts by making + // copies of the glyphs elsewhere, but this may trigger if we are + // unlucky. + if (c == 0x0009 || c == 0x000a || c == 0x000c || c == 0x000d) return false; -#if QT_VERSION < 0x050000 && defined(QT_MAC_USE_COCOA) && (QT_MAC_USE_COCOA > 0) - // bug 7954, see also comment in GuiPainter::text() - if (c == 0x00ad) - return false; -#endif return true; } diff --git a/src/frontends/qt/GuiFontMetrics.cpp b/src/frontends/qt/GuiFontMetrics.cpp index 93a428db6a..b00816d912 100644 --- a/src/frontends/qt/GuiFontMetrics.cpp +++ b/src/frontends/qt/GuiFontMetrics.cpp @@ -53,14 +53,6 @@ using namespace lyx::support; #endif -#if QT_VERSION < 0x050000 -inline uint qHash(double key) -{ - return qHash(QByteArray(reinterpret_cast(&key), sizeof(key))); -} -#endif - - namespace std { /* @@ -91,7 +83,9 @@ int const strwidth_cache_max_cost = 1024 * 1024; int const breakstr_cache_max_cost = 10 * 1024 * 1024; // Qt 5.x already has its own caching of QTextLayout objects // but it does not seem to work well on MacOS X. -#if (QT_VERSION < 0x050000) || defined(Q_OS_MAC) +#if defined(Q_OS_MAC) +// For some reason, the built-in cache of QTextLayout does not work or +// exist on macOS. // Limit qtextlayout_cache_ size to 500 elements (we do not know the // size of the QTextLayout objects anyway). int const qtextlayout_cache_max_size = 500; @@ -146,11 +140,6 @@ GuiFontMetrics::GuiFontMetrics(QFont const & font) slope_ = defaultSlope; LYXERR(Debug::FONT, "Italic slope: " << slope_); } - // If those characters have a non-zero width, we need to avoid them. - // This happens with Qt4 with monospace fonts - needs_naked_ = width(QString() + QChar(0x2060) + QChar(0x202d) + QChar(0x202e)) > 0; - // if (needs_naked_) - // LYXERR0("Font " << font.family() << " needs naked text layouts!"); } @@ -291,11 +280,7 @@ int GuiFontMetrics::width(docstring const & s) const */ int w = 0; // is the string a single character from a math font ? -#if QT_VERSION >= 0x040800 bool const math_char = s.length() == 1 && font_.styleName() == "LyX"; -#else - bool const math_char = s.length() == 1; -#endif if (math_char) { QString const qs = toqstr(s); int br_width = metrics_.boundingRect(qs).width(); @@ -353,9 +338,7 @@ struct TextLayoutHelper /// Create the helper /// \c s is the original string /// \c isrtl is true if the string is right-to-left - /// \c naked is true to disable the insertion of zero width annotations - /// FIXME: remove \c naked argument when Qt4 support goes away. - TextLayoutHelper(docstring const & s, bool isrtl, bool naked = false); + TextLayoutHelper(docstring const & s, bool isrtl); /// translate QString index to docstring index docstring::size_type qpos2pos(int qpos) const @@ -379,7 +362,7 @@ private: }; -TextLayoutHelper::TextLayoutHelper(docstring const & s, bool isrtl, bool naked) +TextLayoutHelper::TextLayoutHelper(docstring const & s, bool isrtl) : docstr(s), rtl(isrtl) { // Reserve memory for performance purpose @@ -395,16 +378,14 @@ TextLayoutHelper::TextLayoutHelper(docstring const & s, bool isrtl, bool naked) */ // Unicode character WORD JOINER QChar const word_joiner(0x2060); - if (!naked) - qstr += word_joiner; + qstr += word_joiner; #ifdef BIDI_USE_OVERRIDE /* Unicode override characters enforce drawing direction * Source: http://www.iamcal.com/understanding-bidirectional-text/ * Left-to-right override is 0x202d and right-to-left override is 0x202e. */ - if (!naked) - qstr += QChar(rtl ? 0x202e : 0x202d); + qstr += QChar(rtl ? 0x202e : 0x202d); #endif // Now translate the string character-by-character. @@ -412,7 +393,7 @@ TextLayoutHelper::TextLayoutHelper(docstring const & s, bool isrtl, bool naked) for (char_type const c : s) { // insert a word joiner character between consecutive spaces bool const is_space = isSpace(c); - if (!naked && is_space && was_space) + if (is_space && was_space) qstr += word_joiner; was_space = is_space; // Remember the QString index at this point @@ -425,8 +406,7 @@ TextLayoutHelper::TextLayoutHelper(docstring const & s, bool isrtl, bool naked) } // Final word joiner (see above) - if (!naked) - qstr += word_joiner; + qstr += word_joiner; // Add virtual position at the end of the string pos2qpos_.push_back(qstr.size()); @@ -487,7 +467,7 @@ GuiFontMetrics::getTextLayout(docstring const & s, bool const rtl, if (auto ptl = qtextlayout_cache_[key]) return ptl; PROFILE_CACHE_MISS(getTextLayout); - TextLayoutHelper tlh(s, rtl, needs_naked_); + TextLayoutHelper tlh(s, rtl); auto const ptl = getTextLayout_helper(tlh, wordspacing, font_); qtextlayout_cache_.insert(key, ptl); return ptl; @@ -497,7 +477,7 @@ GuiFontMetrics::getTextLayout(docstring const & s, bool const rtl, int GuiFontMetrics::pos2x(docstring const & s, int pos, bool const rtl, double const wordspacing) const { - TextLayoutHelper tlh(s, rtl, needs_naked_); + TextLayoutHelper tlh(s, rtl); auto ptl = getTextLayout(tlh, wordspacing); // pos can be negative, see #10506. int const qpos = tlh.pos2qpos(max(pos, 0)); @@ -508,7 +488,7 @@ int GuiFontMetrics::pos2x(docstring const & s, int pos, bool const rtl, int GuiFontMetrics::x2pos(docstring const & s, int & x, bool const rtl, double const wordspacing) const { - TextLayoutHelper tlh(s, rtl, needs_naked_); + TextLayoutHelper tlh(s, rtl); auto ptl = getTextLayout(tlh, wordspacing); QTextLine const & tline = ptl->lineForTextPosition(0); int qpos = tline.xToCursor(x); @@ -546,7 +526,7 @@ FontMetrics::Breaks GuiFontMetrics::breakString_helper(docstring const & s, int first_wid, int wid, bool rtl, bool force) const { - TextLayoutHelper const tlh(s, rtl, needs_naked_); + TextLayoutHelper const tlh(s, rtl); QTextLayout tl; #ifdef BIDI_USE_FLAG diff --git a/src/frontends/qt/GuiFontMetrics.h b/src/frontends/qt/GuiFontMetrics.h index 0187c5c85f..5c32ea9de8 100644 --- a/src/frontends/qt/GuiFontMetrics.h +++ b/src/frontends/qt/GuiFontMetrics.h @@ -119,10 +119,6 @@ private: /// Slope of italic font double slope_; - /// If true, avoid extra annotation in string for QTextLayout - // FIXME: remove wen Qt4 suport goes away - bool needs_naked_ = false; - /// Cache of char widths mutable QHash width_cache_; /// Cache of string widths diff --git a/src/frontends/qt/GuiImage.cpp b/src/frontends/qt/GuiImage.cpp index 6e4c0723a3..e73a7985c5 100644 --- a/src/frontends/qt/GuiImage.cpp +++ b/src/frontends/qt/GuiImage.cpp @@ -64,25 +64,17 @@ QImage const & GuiImage::image() const unsigned int GuiImage::width() const { -#if QT_VERSION >= 0x050000 return static_cast(ceil(is_transformed_ ? (transformed_.width() / transformed_.devicePixelRatio()) : (original_.width() / original_.devicePixelRatio()))); -#else - return is_transformed_ ? transformed_.width() : original_.width(); -#endif } unsigned int GuiImage::height() const { -#if QT_VERSION >= 0x050000 return static_cast(ceil(is_transformed_ ? (transformed_.height() / transformed_.devicePixelRatio()) : (original_.height() / original_.devicePixelRatio()))); -#else - return is_transformed_ ? transformed_.height() : original_.height(); -#endif } @@ -117,9 +109,7 @@ bool GuiImage::setPixmap(Params const & params) return false; } -#if QT_VERSION >= 0x050000 original_.setDevicePixelRatio(params.pixel_ratio); -#endif is_transformed_ = clip(params); is_transformed_ |= rotate(params); @@ -141,14 +131,9 @@ bool GuiImage::clip(Params const & params) // No clipping is necessary. return false; -#if QT_VERSION >= 0x050000 double const pixelRatio = is_transformed_ ? transformed_.devicePixelRatio() : original_.devicePixelRatio(); int const new_width = static_cast((params.bb.xr.inBP() - params.bb.xl.inBP()) * pixelRatio); int const new_height = static_cast((params.bb.yt.inBP() - params.bb.yb.inBP()) * pixelRatio); -#else - int const new_width = static_cast((params.bb.xr.inBP() - params.bb.xl.inBP())); - int const new_height = static_cast((params.bb.yt.inBP() - params.bb.yb.inBP())); -#endif QImage const & image = is_transformed_ ? transformed_ : original_; @@ -191,19 +176,8 @@ bool GuiImage::scale(Params const & params) if (params.scale == 100) return false; -#if QT_VERSION >= 0x050000 double const pixelRatio = is_transformed_ ? transformed_.devicePixelRatio() : original_.devicePixelRatio(); - qreal scale = qreal(params.scale) / 100.0 * pixelRatio; -#else - qreal scale = qreal(params.scale) / 100.0; -#endif - -#if (QT_VERSION >= 0x040500) && (QT_VERSION <= 0x040502) - // Due to a bug in Qt, LyX will crash for certain - // scaling factors and sizes of the image. - // see bug #5957: http://www.lyx.org/trac/ticket/5957 - scale += 0.0001; -#endif + qreal const scale = qreal(params.scale) / 100.0 * pixelRatio; QTransform m; m.scale(scale, scale); diff --git a/src/frontends/qt/GuiKeySymbol.cpp b/src/frontends/qt/GuiKeySymbol.cpp index 551ea8dc6d..47cadeae57 100644 --- a/src/frontends/qt/GuiKeySymbol.cpp +++ b/src/frontends/qt/GuiKeySymbol.cpp @@ -11,7 +11,7 @@ #include #include "GuiKeySymbol.h" -#if defined(Q_OS_MAC) && QT_VERSION > 0x050000 +#if defined(Q_OS_MAC) #include "GuiApplication.h" #endif #include "qt_helpers.h" @@ -867,7 +867,7 @@ bool KeySymbol::operator==(KeySymbol const & ks) const KeyModifier q_key_state(Qt::KeyboardModifiers state) { KeyModifier k = NoModifier; -#if defined(Q_OS_MAC) && (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) && (QT_VERSION < QT_VERSION_CHECK(5, 12, 0)) +#if defined(Q_OS_MAC) && (QT_VERSION < QT_VERSION_CHECK(5, 12, 0)) /// Additional check for Control and Meta modifier swap state. /// Starting with Qt 5 the modifiers aren't reported correctly. /// Until this is fixed a correction is required. diff --git a/src/frontends/qt/GuiLyXFiles.cpp b/src/frontends/qt/GuiLyXFiles.cpp index 2c97f2baa2..1bfbdbb5ce 100644 --- a/src/frontends/qt/GuiLyXFiles.cpp +++ b/src/frontends/qt/GuiLyXFiles.cpp @@ -189,13 +189,8 @@ GuiLyXFiles::GuiLyXFiles(GuiView & lv) filter_->setClearButton(true); filter_->setPlaceholderText(qt_("All available files")); filter_->setToolTip(qt_("Enter string to filter the list of available files")); -#if (QT_VERSION < 0x050000) - connect(filter_, SIGNAL(downPressed()), - filesLW, SLOT(setFocus())); -#else connect(filter_, &FancyLineEdit::downPressed, filesLW, [this](){ focusAndHighlight(filesLW); }); -#endif filterBarL->addWidget(filter_, 0); findKeysLA->setBuddy(filter_); diff --git a/src/frontends/qt/GuiPainter.cpp b/src/frontends/qt/GuiPainter.cpp index b243c6e648..a64d006ac2 100644 --- a/src/frontends/qt/GuiPainter.cpp +++ b/src/frontends/qt/GuiPainter.cpp @@ -315,13 +315,6 @@ void GuiPainter::text(int x, int y, docstring const & s, */ QString str = toqstr(s); -#if 0 - // HACK: QT3 refuses to show single compose characters - // Still needed with Qt4? - if (ls == 1 && str[0].unicode() >= 0x05b0 && str[0].unicode() <= 0x05c2) - str = ' ' + str; -#endif - QFont ff = getFont(f); ff.setWordSpacing(wordspacing); GuiFontMetrics const & fm = getFontMetrics(f); diff --git a/src/frontends/qt/GuiPrefs.cpp b/src/frontends/qt/GuiPrefs.cpp index 03d630d397..c72baee337 100644 --- a/src/frontends/qt/GuiPrefs.cpp +++ b/src/frontends/qt/GuiPrefs.cpp @@ -438,13 +438,11 @@ PrefInput::PrefInput(GuiPreferences * form) this, SIGNAL(changed())); // reveal checkbox for switching Ctrl and Meta on Mac: - bool swapcb = false; #ifdef Q_OS_MAC -#if QT_VERSION > 0x040600 - swapcb = true; + dontswapCB->setVisible(true); +#else + dontswapCB->setVisible(false); #endif -#endif - dontswapCB->setVisible(swapcb); } @@ -2635,11 +2633,8 @@ PrefUserInterface::PrefUserInterface(GuiPreferences * form) iconSetCO->addItem(qt_("Classic"), "classic"); iconSetCO->addItem(qt_("Oxygen"), "oxygen"); -#if QT_VERSION >= 0x040600 - if (guiApp->platformName() != "qt4x11" - && guiApp->platformName() != "xcb" + if (guiApp->platformName() != "xcb" && !guiApp->platformName().contains("wayland")) -#endif useSystemThemeIconsCB->hide(); } @@ -3573,11 +3568,6 @@ GuiPreferences::GuiPreferences(GuiView & lv) addModule(formats); prefsPS->setCurrentPanel("User Interface"); -// FIXME: hack to work around resizing bug in Qt >= 4.2 -// bug verified with Qt 4.2.{0-3} (JSpitzm) -#if QT_VERSION >= 0x040200 - prefsPS->updateGeometry(); -#endif bc().setPolicy(ButtonPolicy::PreferencesPolicy); bc().setOK(buttonBox->button(QDialogButtonBox::Ok)); diff --git a/src/frontends/qt/GuiRef.cpp b/src/frontends/qt/GuiRef.cpp index 9cb9d81c91..ad4d7107a9 100644 --- a/src/frontends/qt/GuiRef.cpp +++ b/src/frontends/qt/GuiRef.cpp @@ -59,13 +59,8 @@ GuiRef::GuiRef(GuiView & lv) filter_->setClearButton(true); filter_->setPlaceholderText(qt_("All available labels")); filter_->setToolTip(qt_("Enter string to filter the list of available labels")); -#if (QT_VERSION < 0x050000) - connect(filter_, SIGNAL(downPressed()), - refsTW, SLOT(setFocus())); -#else connect(filter_, &FancyLineEdit::downPressed, refsTW, [this](){ focusAndHighlight(refsTW); }); -#endif filterBarL->addWidget(filter_, 0); findKeysLA->setBuddy(filter_); diff --git a/src/frontends/qt/GuiSearch.cpp b/src/frontends/qt/GuiSearch.cpp index f12d42c11d..8ac62c68a7 100644 --- a/src/frontends/qt/GuiSearch.cpp +++ b/src/frontends/qt/GuiSearch.cpp @@ -42,9 +42,7 @@ #include #include #include "QSizePolicy" -#if QT_VERSION >= 0x050000 #include -#endif using namespace std; using namespace lyx::support; @@ -233,11 +231,9 @@ void GuiSearchWidget::handleIndicators() bool const dark_mode = guiApp && guiApp->isInDarkMode(); qreal dpr = 1.0; -#if QT_VERSION >= 0x050000 // Consider device/pixel ratio (HiDPI) if (guiApp && guiApp->currentView()) dpr = guiApp->currentView()->devicePixelRatio(); -#endif QString imagedir = "images/"; QPixmap bpixmap = getPixmap("images/", "search-options", "svgz,png"); QPixmap pm = bpixmap; @@ -250,16 +246,13 @@ void GuiSearchWidget::handleIndicators() pm.fill(Qt::transparent); QPainter painter(&pm); int x = 0; - + tip = qt_("Active options:"); tip += "
    "; if (caseCB->isChecked()) { tip += "
  • " + qt_("Case sensitive search"); QPixmap spixmap = getPixmap("images/", "search-case-sensitive", "svgz,png"); -#if QT_VERSION < 0x050000 - painter.drawPixmap(x, 0, spixmap); -#else - // With Qt5, we render SVG directly for HiDPI scalability + // We render SVG directly for HiDPI scalability FileName fname = imageLibFileSearch(imagedir, "search-case-sensitive", "svgz,png"); QString fpath = toqstr(fname.absFileName()); if (!fpath.isEmpty()) { @@ -268,15 +261,11 @@ void GuiSearchWidget::handleIndicators() svgRenderer.render(&painter, QRectF(0, 0, spixmap.width() * dpr, spixmap.height() * dpr)); } -#endif x += (spixmap.width() * dpr) + gap; } if (wordsCB->isChecked()) { tip += "
  • " + qt_("Whole words only"); QPixmap spixmap = getPixmap("images/", "search-whole-words", "svgz,png"); -#if QT_VERSION < 0x050000 - painter.drawPixmap(x, 0, spixmap); -#else FileName fname = imageLibFileSearch(imagedir, "search-whole-words", "svgz,png"); QString fpath = toqstr(fname.absFileName()); if (!fpath.isEmpty()) { @@ -285,15 +274,11 @@ void GuiSearchWidget::handleIndicators() svgRenderer.render(&painter, QRectF(x, 0, spixmap.width() * dpr, spixmap.height() * dpr)); } -#endif x += (spixmap.width() * dpr) + gap; } if (selectionCB->isChecked()) { tip += "
  • " + qt_("Search only in selection"); QPixmap spixmap = getPixmap("images/", "search-selection", "svgz,png"); -#if QT_VERSION < 0x050000 - painter.drawPixmap(x, 0, spixmap); -#else FileName fname = imageLibFileSearch(imagedir, "search-selection", "svgz,png"); QString fpath = toqstr(fname.absFileName()); if (!fpath.isEmpty()) { @@ -302,15 +287,11 @@ void GuiSearchWidget::handleIndicators() svgRenderer.render(&painter, QRectF(x, 0, spixmap.width() * dpr, spixmap.height() * dpr)); } -#endif x += (spixmap.width() * dpr) + gap; } if (instantSearchCB->isChecked()) { tip += "
  • " + qt_("Search as you type"); QPixmap spixmap = getPixmap("images/", "search-instant", "svgz,png"); -#if QT_VERSION < 0x050000 - painter.drawPixmap(x, 0, spixmap); -#else FileName fname = imageLibFileSearch(imagedir, "search-instant", "svgz,png"); QString fpath = toqstr(fname.absFileName()); if (!fpath.isEmpty()) { @@ -319,15 +300,11 @@ void GuiSearchWidget::handleIndicators() svgRenderer.render(&painter, QRectF(x, 0, spixmap.width() * dpr, spixmap.height() * dpr)); } -#endif x += (spixmap.width() * dpr) + gap; } if (wrapCB->isChecked()) { tip += "
  • " + qt_("Wrap search"); QPixmap spixmap = getPixmap("images/", "search-wrap", "svgz,png"); -#if QT_VERSION < 0x050000 - painter.drawPixmap(x, 0, spixmap); -#else FileName fname = imageLibFileSearch(imagedir, "search-wrap", "svgz,png"); QString fpath = toqstr(fname.absFileName()); if (!fpath.isEmpty()) { @@ -336,18 +313,14 @@ void GuiSearchWidget::handleIndicators() svgRenderer.render(&painter, QRectF(x, 0, spixmap.width() * dpr, spixmap.height() * dpr)); } -#endif x += (spixmap.width() * dpr) + gap; } tip += "
"; -#if QT_VERSION >= 0x050000 pm.setDevicePixelRatio(dpr); -#endif painter.end(); } else { tip = qt_("Click here to change search options"); -#if QT_VERSION >= 0x050000 - // With Qt5, we render SVG directly for HiDPI scalability + // We render SVG directly for HiDPI scalability FileName fname = imageLibFileSearch(imagedir, "search-options", "svgz,png"); QString fpath = toqstr(fname.absFileName()); if (!fpath.isEmpty()) { @@ -360,7 +333,6 @@ void GuiSearchWidget::handleIndicators() pm.setDevicePixelRatio(dpr); } } -#endif } if (dark_mode) { QImage img = pm.toImage(); diff --git a/src/frontends/qt/GuiToolbar.cpp b/src/frontends/qt/GuiToolbar.cpp index 51699c98a8..ed8dd0af58 100644 --- a/src/frontends/qt/GuiToolbar.cpp +++ b/src/frontends/qt/GuiToolbar.cpp @@ -521,7 +521,7 @@ void GuiToolbar::add(ToolbarItem const & item) case ToolbarItem::MINIBUFFER: command_buffer_ = new GuiCommandBuffer(&owner_); addWidget(command_buffer_); - /// \todo find a Qt4 equivalent to setHorizontalStretchable(true); + /// \todo find a Qt5 equivalent to setHorizontalStretchable(true); //setHorizontalStretchable(true); break; case ToolbarItem::TABLEINSERT: { diff --git a/src/frontends/qt/GuiView.cpp b/src/frontends/qt/GuiView.cpp index ccc2b8e59c..1f4567d4e6 100644 --- a/src/frontends/qt/GuiView.cpp +++ b/src/frontends/qt/GuiView.cpp @@ -161,7 +161,6 @@ public: /// The text to be written on top of the pixmap QString const text = lyx_version ? qt_("version ") + lyx_version : qt_("unknown version"); -#if QT_VERSION >= 0x050000 QString imagedir = "images/"; FileName fname = imageLibFileSearch(imagedir, "banner", "svgz"); QSvgRenderer svgRenderer(toqstr(fname.absFileName())); @@ -173,9 +172,6 @@ public: } else { splash_ = getPixmap("images/", "banner", "png"); } -#else - splash_ = getPixmap("images/", "banner", "svgz,png"); -#endif QPainter pain(&splash_); pain.setPen(QColor(0, 0, 0)); @@ -264,11 +260,7 @@ private: /// Current ratio between physical pixels and device-independent pixels double pixelRatio() const { -#if QT_VERSION >= 0x050000 return qt_scale_factor * devicePixelRatio(); -#else - return 1.0; -#endif } qreal fontSize() const { @@ -288,11 +280,7 @@ private: /// Ratio between physical pixels and device-independent pixels of splash image double splashPixelRatio() const { -#if QT_VERSION >= 0x050000 return splash_.devicePixelRatio(); -#else - return 1.0; -#endif } }; @@ -608,15 +596,10 @@ GuiView::GuiView(int id) setAttribute(Qt::WA_DeleteOnClose, true); #if !(defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN)) && !defined(Q_OS_MAC) - // QIcon::fromTheme was introduced in Qt 4.6 -#if (QT_VERSION >= 0x040600) // assign an icon to main form. We do not do it under Qt/Win or Qt/Mac, // since the icon is provided in the application bundle. We use a themed // version when available and use the bundled one as fallback. setWindowIcon(QIcon::fromTheme("lyx", getPixmap("images/", "lyx", "svg,png"))); -#else - setWindowIcon(getPixmap("images/", "lyx", "svg,png")); -#endif #endif resetWindowTitle(); @@ -1001,7 +984,7 @@ void GuiView::saveLayout() const settings.setValue("devel_mode", devel_mode_); settings.beginGroup("views"); settings.beginGroup(QString::number(id_)); - if (guiApp->platformName() == "qt4x11" || guiApp->platformName() == "xcb") { + if (guiApp->platformName() == "xcb") { settings.setValue("pos", pos()); settings.setValue("size", size()); } else @@ -1067,7 +1050,7 @@ bool GuiView::restoreLayout() char_nb_count_enabled_ = settings.value("char_nb_count_enabled", true).toBool(); stat_counts_->setVisible(word_count_enabled_ || char_count_enabled_ || char_nb_count_enabled_); - if (guiApp->platformName() == "qt4x11" || guiApp->platformName() == "xcb") { + if (guiApp->platformName() == "xcb") { QPoint pos = settings.value("pos", QPoint(50, 50)).toPoint(); QSize size = settings.value("size", QSize(690, 510)).toSize(); resize(size); @@ -1525,9 +1508,7 @@ void GuiView::updateWindowTitle(GuiWorkArea * wa) // buffer-save has changed too. updateToolbars(); } -#ifndef Q_WS_MAC title += from_ascii(" - LyX"); -#endif setWindowTitle(toqstr(title)); // Sets the path for the window: this is used by OSX to // allow a context click on the title bar showing a menu @@ -1835,11 +1816,7 @@ void GuiView::resetCommandExecute() double GuiView::pixelRatio() const { -#if QT_VERSION >= 0x050000 return qt_scale_factor * devicePixelRatio(); -#else - return 1.0; -#endif } @@ -5276,11 +5253,9 @@ Dialog * GuiView::findOrBuild(string const & name, bool hide_it) dialog = build(name); d.dialogs_[name].reset(dialog); -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) // Force a uniform style for group boxes // On Mac non-flat works better, on Linux flat is standard flatGroupBoxes(dialog->asQWidget(), guiApp->platformName() != "cocoa"); -#endif if (lyxrc.allow_geometry_session) dialog->restoreSession(); if (hide_it) diff --git a/src/frontends/qt/GuiWorkArea.cpp b/src/frontends/qt/GuiWorkArea.cpp index 802fbc71b7..31cfec18f8 100644 --- a/src/frontends/qt/GuiWorkArea.cpp +++ b/src/frontends/qt/GuiWorkArea.cpp @@ -53,9 +53,6 @@ #include "frontends/WorkAreaManager.h" #include -#if (QT_VERSION < 0x050000) -#include -#endif #include #include #ifdef Q_OS_MAC @@ -182,11 +179,7 @@ GuiWorkArea::GuiWorkArea(Buffer & buffer, GuiView & gv) double GuiWorkArea::pixelRatio() const { -#if QT_VERSION >= 0x050000 return qt_scale_factor * devicePixelRatio(); -#else - return 1.0; -#endif } @@ -202,7 +195,7 @@ void GuiWorkArea::init() }); d->resetScreen(); - // With Qt4.5 a mouse event will happen before the first paint event + // A mouse event will happen before the first paint event, // so make sure that the buffer view has an up to date metrics. d->buffer_view_->resize(viewport()->width(), viewport()->height()); @@ -591,10 +584,6 @@ void GuiWorkArea::scrollTo(int value) } // Show the caret immediately after any operation. startBlinkingCaret(); - // FIXME QT5 -#ifdef Q_WS_X11 - QApplication::syncX(); -#endif } @@ -724,10 +713,6 @@ void GuiWorkArea::mousePressEvent(QMouseEvent * e) return; } -#if (QT_VERSION < 0x050000) && !defined(__HAIKU__) - inputContext()->reset(); -#endif - #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) FuncRequest const cmd(LFUN_MOUSE_PRESS, e->position().x(), e->position().y(), #else @@ -860,13 +845,6 @@ void GuiWorkArea::wheelEvent(QWheelEvent * ev) // Wheel rotation by one notch results in a delta() of 120 (see // documentation of QWheelEvent) // But first we have to ignore horizontal scroll events. -#if QT_VERSION < 0x050000 - if (ev->orientation() == Qt::Horizontal) { - ev->accept(); - return; - } - double const delta = ev->delta() / 120.0; -#else QPoint const aDelta = ev->angleDelta(); // skip horizontal wheel event if (abs(aDelta.x()) > abs(aDelta.y())) { @@ -874,7 +852,6 @@ void GuiWorkArea::wheelEvent(QWheelEvent * ev) return; } double const delta = aDelta.y() / 120.0; -#endif bool zoom = false; switch (lyxrc.scroll_wheel_zoom) { @@ -1232,9 +1209,7 @@ void GuiWorkArea::Private::resetScreen() screen_ = QImage(pr * p->viewport()->width(), pr * p->viewport()->height(), QImage::Format_ARGB32_Premultiplied); -# if QT_VERSION >= 0x050000 screen_.setDevicePixelRatio(pr); -# endif } } @@ -1378,11 +1353,7 @@ QVariant GuiWorkArea::inputMethodQuery(Qt::InputMethodQuery query) const switch (query) { // this is the CJK-specific composition window position and // the context menu position when the menu key is pressed. -#if (QT_VERSION < 0x050000) - case Qt::ImMicroFocus: { -#else case Qt::ImCursorRectangle: { -#endif CaretGeometry const & cg = bufferView().caretGeometry(); return QRect(cg.left - 10 * (d->preedit_lines_ != 1), cg.top + cg.height() * d->preedit_lines_, @@ -1595,11 +1566,7 @@ void TabWorkArea::paintEvent(QPaintEvent * event) // painting of the frame of the tab widget. // This is needed for gtk style in Qt. QStylePainter p(this); -#if QT_VERSION < 0x050000 - QStyleOptionTabWidgetFrameV2 opt; -#else QStyleOptionTabWidgetFrame opt; -#endif initStyleOption(&opt); opt.rect = style()->subElementRect(QStyle::SE_TabWidgetTabPane, &opt, this); diff --git a/src/frontends/qt/Menus.cpp b/src/frontends/qt/Menus.cpp index 6b0c12b821..5ea7133665 100644 --- a/src/frontends/qt/Menus.cpp +++ b/src/frontends/qt/Menus.cpp @@ -76,10 +76,8 @@ #include #include #include -#include -#if QT_VERSION >= 0x040600 #include -#endif +#include #include #include @@ -2146,7 +2144,7 @@ void Menu::Impl::populate(QMenu * qMenu, MenuDefinition const & menu) } } -#if (defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN)) && (QT_VERSION >= 0x040600) +#if (defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN)) class AlwaysMnemonicStyle : public QProxyStyle { public: int styleHint(StyleHint hint, const QStyleOption *opt = 0, const QWidget *widget = 0, @@ -2166,7 +2164,7 @@ public: Menu::Menu(GuiView * gv, QString const & name, bool top_level, bool keyboard) : QMenu(gv), d(new Menu::Impl) { -#if (defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN)) && (QT_VERSION >= 0x040600) +#if (defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN)) if (keyboard) setStyle(new AlwaysMnemonicStyle); #else @@ -2280,11 +2278,10 @@ MenuDefinition Menus::Impl::mac_special_menu_; */ void Menus::Impl::macxMenuBarInit(QMenuBar * qmb) { - /* Since Qt 4.2, the qt/mac menu code has special code for - specifying the role of a menu entry. However, it does not - work very well with our scheme of creating menus on demand, - and therefore we need to put these entries in a special - invisible menu. (JMarc) + /* The qt/mac menu code has special code for specifying the role + of a menu entry. However, it does not work very well with our + scheme of creating menus on demand, and therefore we need to + put these entries in a special invisible menu. (JMarc) */ /* The entries of our special mac menu. If we add support for @@ -2306,11 +2303,6 @@ void Menus::Impl::macxMenuBarInit(QMenuBar * qmb) QAction::AboutRole}, {LFUN_DIALOG_SHOW, "prefs", "Preferences", QAction::PreferencesRole}, -#if !(defined(QT_MAC_USE_COCOA) || (QT_VERSION >= 0x050000)) - /* This doesn't work with Cocoa. */ - {LFUN_RECONFIGURE, "", "Reconfigure", - QAction::ApplicationSpecificRole}, -#endif {LFUN_LYX_QUIT, "", "Quit LyX", QAction::QuitRole} }; const size_t num_entries = sizeof(entries) / sizeof(entries[0]); @@ -2641,7 +2633,7 @@ void Menus::fillMenuBar(QMenuBar * qmb, GuiView * view, bool initial) } else { // Clear all menubar contents before filling it. qmb->clear(); -#if (QT_VERSION >= 0x050000 && defined(Q_OS_MAC)) +#if (defined(Q_OS_MAC)) d->macxMenuBarInit(qmb); #endif } @@ -2684,8 +2676,8 @@ void Menus::fillMenuBar(QMenuBar * qmb, GuiView * view, bool initial) Menu * menuptr = new Menu(view, m->submenuname(), true); menuptr->setTitle(label(*m)); -#if defined(Q_OS_MAC) && (defined(QT_MAC_USE_COCOA) || (QT_VERSION >= 0x050000)) - // On Mac OS with QT/cocoa, the menu is not displayed if there is no action +#if defined(Q_OS_MAC) + // On Mac OS with Qt/Cocoa, the menu is not displayed if there is no action // so we create a temporary one here QAction * action = new QAction(menuptr); menuptr->addAction(action); diff --git a/src/frontends/qt/PanelStack.cpp b/src/frontends/qt/PanelStack.cpp index 745442b653..c70c7ae543 100644 --- a/src/frontends/qt/PanelStack.cpp +++ b/src/frontends/qt/PanelStack.cpp @@ -61,7 +61,7 @@ PanelStack::PanelStack(QWidget * parent) list_->setRootIsDecorated(false); list_->setColumnCount(1); list_->header()->hide(); - setSectionResizeMode(list_->header(), QHeaderView::ResizeToContents); + list_->header()->setSectionResizeMode(QHeaderView::ResizeToContents); list_->header()->setStretchLastSection(false); list_->setMinimumSize(list_->viewport()->size()); diff --git a/src/frontends/qt/TocWidget.cpp b/src/frontends/qt/TocWidget.cpp index 573e232993..fcbd605848 100644 --- a/src/frontends/qt/TocWidget.cpp +++ b/src/frontends/qt/TocWidget.cpp @@ -102,13 +102,8 @@ TocWidget::TocWidget(GuiView & gui_view, QWidget * parent) this, SLOT(showContextMenu(const QPoint &))); connect(filter_, SIGNAL(textEdited(QString)), this, SLOT(filterContents())); -#if (QT_VERSION < 0x050000) - connect(filter_, SIGNAL(downPressed()), - tocTV, SLOT(setFocus())); -#else connect(filter_, &FancyLineEdit::downPressed, tocTV, [this](){ focusAndHighlight(tocTV); }); -#endif connect(activeFilterCO, SIGNAL(activated(int)), this, SLOT(filterContents())); diff --git a/src/frontends/qt/qt_helpers.cpp b/src/frontends/qt/qt_helpers.cpp index 0431c042ad..6891c3088a 100644 --- a/src/frontends/qt/qt_helpers.cpp +++ b/src/frontends/qt/qt_helpers.cpp @@ -269,24 +269,6 @@ void setMessageColour(list highlighted, list plain) } -/// wrapper to hide the change of method name to setSectionResizeMode -void setSectionResizeMode(QHeaderView * view, - int logicalIndex, QHeaderView::ResizeMode mode) { -#if (QT_VERSION >= 0x050000) - view->setSectionResizeMode(logicalIndex, mode); -#else - view->setResizeMode(logicalIndex, mode); -#endif -} - -void setSectionResizeMode(QHeaderView * view, QHeaderView::ResizeMode mode) { -#if (QT_VERSION >= 0x050000) - view->setSectionResizeMode(mode); -#else - view->setResizeMode(mode); -#endif -} - void showDirectory(FileName const & directory) { if (!directory.exists()) diff --git a/src/frontends/qt/qt_helpers.h b/src/frontends/qt/qt_helpers.h index 08d50fa582..77c14b8c88 100644 --- a/src/frontends/qt/qt_helpers.h +++ b/src/frontends/qt/qt_helpers.h @@ -89,12 +89,6 @@ void focusAndHighlight(QAbstractItemView * w); void setMessageColour(std::list highlighted, std::list plain); -/// Qt5 changed setSectionMode to setSectionResizeMode -/// These wrappers work for Qt4 and Qt5 -void setSectionResizeMode(QHeaderView * view, - int logicalIndex, QHeaderView::ResizeMode mode); -void setSectionResizeMode(QHeaderView * view, - QHeaderView::ResizeMode mode); /// Shows a directory in OSs file browser void showDirectory(support::FileName const & directory); /// handle request for showing citation content - shows pdf/ps or diff --git a/src/lyxfind.cpp b/src/lyxfind.cpp index 0ba2acec90..39543fa5ad 100644 --- a/src/lyxfind.cpp +++ b/src/lyxfind.cpp @@ -57,13 +57,8 @@ //#define ResultsDebug #define USE_QT_FOR_SEARCH #if defined(USE_QT_FOR_SEARCH) - #include // sets QT_VERSION - #if (QT_VERSION >= 0x050000) - #include - #define QTSEARCH 1 - #else - #define QTSEARCH 0 - #endif + #include + #define QTSEARCH 1 #else #define QTSEARCH 0 #endif diff --git a/src/support/FileMonitor.cpp b/src/support/FileMonitor.cpp index 0af322d9ee..4a81cc2fc8 100644 --- a/src/support/FileMonitor.cpp +++ b/src/support/FileMonitor.cpp @@ -126,15 +126,7 @@ void FileMonitorGuard::refresh(bool const emit) if (!qwatcher_->files().contains(qfilename)) { bool const existed = exists_; exists_ = QFile(qfilename).exists(); -#if (QT_VERSION >= 0x050000) if (exists_ && !qwatcher_->addPath(qfilename)) -#else - auto add_path = [&]() { - qwatcher_->addPath(qfilename); - return qwatcher_->files().contains(qfilename); - }; - if (exists_ && !add_path()) -#endif { LYXERR(Debug::FILES, "Could not add path to QFileSystemWatcher: " << filename_); diff --git a/src/support/FileName.cpp b/src/support/FileName.cpp index 5b494a5ec9..32a5862fdb 100644 --- a/src/support/FileName.cpp +++ b/src/support/FileName.cpp @@ -778,11 +778,7 @@ docstring FileName::fileContents(string const & encoding) const if (encoding.empty() || encoding == "UTF-8") s = QString::fromUtf8(contents.data()); else if (encoding == "ascii") -#if (QT_VERSION < 0x050000) - s = QString::fromAscii(contents.data()); -#else s = QString::fromLatin1(contents.data()); -#endif else if (encoding == "local8bit") s = QString::fromLocal8Bit(contents.data()); else if (encoding == "latin1") diff --git a/src/support/Package.cpp b/src/support/Package.cpp index a779544f99..400bf15707 100644 --- a/src/support/Package.cpp +++ b/src/support/Package.cpp @@ -420,12 +420,9 @@ FileName const get_document_dir(FileName const & home_dir) (void)home_dir; // Silence warning about unused variable. os::GetFolderPath win32_folder_path; return FileName(win32_folder_path(os::GetFolderPath::PERSONAL)); -#elif defined (USE_MACOSX_PACKAGING) && (QT_VERSION >= 0x050000) - (void)home_dir; // Silence warning about unused variable. - return FileName(fromqstr(QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation))); #elif defined (USE_MACOSX_PACKAGING) (void)home_dir; // Silence warning about unused variable. - return FileName(fromqstr(QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation))); + return FileName(fromqstr(QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation))); #else // Posix-like. return home_dir; #endif @@ -686,13 +683,9 @@ FileName const get_default_user_support_dir(FileName const & home_dir) os::GetFolderPath win32_folder_path; return FileName(addPath(win32_folder_path(os::GetFolderPath::APPDATA), PACKAGE)); -#elif defined (USE_MACOSX_PACKAGING) && (QT_VERSION >= 0x050000) - (void)home_dir; // Silence warning about unused variable. - return FileName(addPath(fromqstr(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)), PACKAGE)); - #elif defined (USE_MACOSX_PACKAGING) (void)home_dir; // Silence warning about unused variable. - return FileName(addPath(fromqstr(QDesktopServices::storageLocation(QDesktopServices::DataLocation)), PACKAGE)); + return FileName(addPath(fromqstr(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)), PACKAGE)); #elif defined (USE_HAIKU_PACKAGING) return FileName(addPath(home_dir.absFileName(), string("/config/settings/") + PACKAGE)); diff --git a/src/support/filetools.cpp b/src/support/filetools.cpp index d554f477eb..e24dcbaf77 100644 --- a/src/support/filetools.cpp +++ b/src/support/filetools.cpp @@ -1314,12 +1314,8 @@ void fileUnlock(int fd, const char * /* lock_file*/) std::string toHexHash(const std::string & str) { - // Use the best available hashing algorithm. Qt 5 proposes SHA-2, but Qt 4 is limited to SHA-1. -#if QT_VERSION >= 0x050000 + // Use the best available hashing algorithm. auto hashAlgo = QCryptographicHash::Sha256; -#else - auto hashAlgo = QCryptographicHash::Sha1; -#endif QByteArray hash = QCryptographicHash::hash(toqstr(str).toLocal8Bit(), hashAlgo); return fromqstr(QString(hash.toHex()));