Qt5 support (step 1)
authorAlexander Sokolov <sokoloff.a@gmail.com>
Wed, 6 Nov 2013 17:59:17 +0000 (21:59 +0400)
committerAlexander Sokolov <sokoloff.a@gmail.com>
Wed, 6 Nov 2013 17:59:17 +0000 (21:59 +0400)
17 files changed:
CMakeLists.txt
aboutdialog/technicalinfo.cpp
addplugindialog/lxqtaddplugindialog.cpp
cmake/lxqt-config.cmake.in
cmake/lxqtX-config.cmake.in [new file with mode: 0644]
cmake/lxqt_use.cmake
configdialog/lxqtconfigdialog.cpp
lxqtapplication.cpp
lxqtautostartentry.cpp
lxqtautostartentry.h
lxqtplugininfo.h
lxqtpowermanager.cpp
lxqtscreensaver.cpp
lxqtsettings.cpp
lxqttranslator.cpp
lxqtxfitman.cpp
translatorsinfo/translatorsinfo.cpp

index c934468..1751145 100644 (file)
@@ -117,25 +117,81 @@ file(GLOB TS_FILES
 # additional cmake files
 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
 
-find_package(Qt4 REQUIRED QUIET)
-include(${QT_USE_FILE})
 
-QT4_ADD_DBUS_INTERFACE(SRCS
-    dbus/org.freedesktop.Notifications.xml
-    notifications_interface
-)
+option(USE_QT5 "Force use the Qt5." $ENV{USE_QT5})
+option(USE_QT4 "Force use the Qt4." $ENV{USE_QT4})
+message("Qt4:${USE_QT4}|Qt5:${USE_QT5}")
+
+if((USE_QT4 AND USE_QT5) OR
+   (NOT USE_QT4 AND NOT USE_QT5))
+
+    # Autodetect Qt version
+    find_package(Qt5Core QUIET)
+    if (Qt5Core_FOUND)
+        set(USE_QT4 OFF)
+        set(USE_QT5 ON)
+    else()
+        set(USE_QT4 ON)
+        set(USE_QT5 OFF)
+    endif()
+endif()
 
-find_package(X11 REQUIRED QUIET)
 
-find_package(QTXDG REQUIRED QUIET)
-include(${QTXDG_USE_FILE})
+if(USE_QT5)
+    cmake_minimum_required(VERSION 2.8.3)
+
+    set(CMAKE_INCLUDE_CURRENT_DIR ON)
+    set(CMAKE_AUTOMOC ON)
+    set(CMAKE_POSITION_INDEPENDENT_CODE ON)
+
+    find_package(Qt5Widgets REQUIRED QUIET)
+    message(STATUS "Building with Qt ${Qt5Core_VERSION_STRING}")
+    find_package(Qt5X11Extras REQUIRED QUIET)
+    find_package(Qt5LinguistTools REQUIRED QUIET)
+
+    set(LXQT_QT_VERSION "5")
+    set(LXQT_PKG_CONFIG_REQUIRES "Qt5Widgets Qt5Xml")
+
+    include_directories(${Qt5Widgets_INCLUDE_DIRS})
+    add_definitions(${Qt5Widgets_DEFINITIONS})
+
+    QT5_WRAP_UI(UIS ${FORMS})
+    QT5_ADD_TRANSLATION(QM_FILES ${TS_FILES})
+    #set(CMAKE_CXX_FLAGS
+    #    "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}"
+    #)
 
+    set(QT_LIBRARIES ${Qt5Widgets_LIBRARIES})
+
+    find_package(XDGQT5 REQUIRED QUIET)
+else()
+    find_package(Qt4 REQUIRED QUIET)
+    message(STATUS "Building with Qt ${QTVERSION}")
+
+    include(${QT_USE_FILE})
+
+    QT4_WRAP_CPP(MOCS ${MOCS})
+    QT4_WRAP_UI(UIS ${FORMS})
+    QT4_ADD_TRANSLATION(QM_FILES ${TS_FILES})
+    QT4_ADD_DBUS_INTERFACE(SRCS
+        dbus/org.freedesktop.Notifications.xml
+        notifications_interface
+    )
+
+    set(LXQT_QT_VERSION "4")
+    find_package(XDGQT4 REQUIRED QUIET)
+
+
+endif()
+
+include(${XDGQT_USE_FILE})
+find_package(X11 REQUIRED QUIET)
 
 include_directories (
     ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}
     ${QT_QTCORE_INCLUDE_DIR} ${QT_QTGUI_INCLUDE_DIR} ${QT_QTDBUS_INCLUDE_DIR}
     ${X11_INCLUDE_DIR}
-    ${QTXDG_INCLUDE_DIRS}
+    ${XDGQT_INCLUDE_DIRS}
 )
 
 set(LXQT_VERSION ${LXQT_MAJOR_VERSION}.${LXQT_MINOR_VERSION}.${LXQT_PATCH_VERSION})
@@ -178,8 +234,15 @@ if(INTREE_ROOT_DIR)
     )
 
     configure_file(
+        ${CMAKE_CURRENT_SOURCE_DIR}/cmake/lxqtX-config.cmake.in
+        ${INTREE_ROOT_DIR}/cmake/lxqt${LXQT_QT_VERSION}-config.cmake
+        @ONLY
+    )
+
+
+    configure_file(
         ${CMAKE_CURRENT_SOURCE_DIR}/cmake/lxqt_use.cmake
-        ${INTREE_ROOT_DIR}/cmake/lxqt_use.cmake
+        ${INTREE_ROOT_DIR}/cmake/lxqt${LXQT_QT_VERSION}_use.cmake
         @ONLY
     )
 endif()
@@ -203,17 +266,20 @@ configure_file(
 )
 
 configure_file(
+    ${CMAKE_CURRENT_SOURCE_DIR}/cmake/lxqtX-config.cmake.in
+    ${CMAKE_CURRENT_BINARY_DIR}/cmake/lxqt{LXQT_QT_VERSION}-config.cmake
+    @ONLY
+)
+
+
+configure_file(
     ${CMAKE_CURRENT_SOURCE_DIR}/cmake/lxqt_use.cmake
-    ${CMAKE_CURRENT_BINARY_DIR}/cmake/lxqt_use.cmake
+    ${CMAKE_CURRENT_BINARY_DIR}/cmake/lxqt{LXQT_QT_VERSION}_use.cmake
     @ONLY
 )
 
 #************************************************
 
-
-qt4_wrap_cpp(MOCS ${MOCS})
-qt4_wrap_ui(UIS ${FORMS})
-qt4_add_translation(QM_FILES ${TS_FILES})
 include(cmake/lxqt_use.cmake)
 
 
@@ -234,7 +300,7 @@ target_link_libraries(lxqt
     ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY}
     ${QT_QTDBUS_LIBRARY}
     ${X11_X11_LIB}
-    ${QTXDG_LIBRARIES}
+    ${XDGQT_LIBRARIES}
 )
 
 set_target_properties(lxqt PROPERTIES
index 5570194..5e54e1e 100644 (file)
@@ -27,7 +27,7 @@
 
 
 #include "technicalinfo.h"
-#include <qtxdg/xdgdirs.h>
+#include <xdgqt/XdgDirs>
 #include "lxqttranslator.h"
 
 using namespace LxQt;
index b817c9a..ced09aa 100644 (file)
@@ -28,7 +28,7 @@
 
 #include "lxqtaddplugindialog.h"
 #include "ui_lxqtaddplugindialog.h"
-#include <qtxdg/xdgicon.h>
+#include <xdgqt/XdgIcon>
 #include <QtGui/QListWidgetItem>
 #include <QtGui/QItemDelegate>
 #include <QtGui/QTextDocument>
index 7f1a3a3..4caff7a 100644 (file)
 #   add_executable(myexe main.cpp)
 #   target_link_libraries(myexe $LXQT_LIBRARIES})
 
-set(LXQT_MAJOR_VERSION @LXQT_MAJOR_VERSION@)
-set(LXQT_MINOR_VERSION @LXQT_MINOR_VERSION@)
-set(LXQT_PATCH_VERSION @LXQT_PATCH_VERSION@)
-set(LXQT_VERSION       @LXQT_VERSION@)
+option(USE_QT5 "Force use the Qt5." $ENV{USE_QT5})
+option(USE_QT4 "Force use the Qt4." $ENV{USE_QT4})
 
-set(LXQT_SHARE_DIR     @LXQT_SHARE_DIR@)
-set(LXQT_TRANSLATIONS_DIR @LXQT_TRANSLATIONS_DIR@)
-set(LXQT_ETC_XDG_DIR   @LXQT_ETC_XDG_DIR@)
-set(LXQT_INCLUDE_DIR   @LXQT_INCLUDE_DIR@)
-set(LXQT_LIBRARY       lxqt)
+if((USE_QT4 AND USE_QT5) OR
+   (NOT USE_QT4 AND NOT USE_QT5))
+    # Autodetect Qt version
+    find_package(LxQt5 QUIET)
+    if (LXQT5_FOUND)
+        set(USE_QT4 OFF)
+        set(USE_QT5 ON)
+    else()
+        set(USE_QT4 ON)
+        set(USE_QT5 OFF)
+    endif()
+endif()
 
-set(LXQT_LIBRARIES     ${LXQT_LIBRARY} )
-set(LXQT_INCLUDE_DIRS  ${LXQT_INCLUDE_DIR} )
-set(LXQT_USE_FILE      ${CMAKE_CURRENT_LIST_DIR}/lxqt_use.cmake)
-set(LXQT_FOUND         1)
+if(LXQT_FIND_REQUIRED)
+  set(REQUIRED_OPT "REQUIRED")
+endif()
 
-mark_as_advanced(LXQT_LIBRARY LXQT_INCLUDE_DIR)
+if(LXQT_FIND_QUIETLY)
+  set(QUIET_OPT "QUIET")
+endif()
 
+
+if(USE_QT5)
+  find_package(LxQt5 ${REQUIRED_OPT} ${QUIET_OPT})
+else()
+  find_package(LxQt4 ${REQUIRED_OPT} ${QUIET_OPT})
+endif()
\ No newline at end of file
diff --git a/cmake/lxqtX-config.cmake.in b/cmake/lxqtX-config.cmake.in
new file mode 100644 (file)
index 0000000..dd48254
--- /dev/null
@@ -0,0 +1,73 @@
+# - Find the lxqt include and library dirs and define a some macros
+#
+# The module defines the following variables
+#
+#  LXQT_FOUND         - Set to TRUE if all of the above has been found
+#
+#  LXQT_INCLUDE_DIR   - The lxqt include directory
+#
+#  LXQT_INCLUDE_DIRS  - The lxqt and the Qt include directory, for use with INCLUDE_DIRECTORIES()
+#
+#  LXQT_LIBRARIES     - The libraries needed to use lxqt
+#
+#  LXQT_SHARE_DIR     - This allows to install and read the configs from non-standard locations
+#
+#  LXQT_TRANSLATIONS_DIR - The default translations directory
+#
+#  LXQT_ETC_XDG_DIR   - XDG standards expects system-wide configuration files in the
+#                        /etc/xdg/razor location. Unfortunately QSettings we are using internally
+#                        can be overriden in the Qt compilation time to use different path for
+#                        system-wide configs. (for example configure ... -sysconfdir /etc/settings ...)
+#                        This path can be found calling Qt4's qmake:
+#                             qmake -query QT_INSTALL_CONFIGURATION
+#
+# LXQT_USE_FILE       - The variable LXQT_USE_FILE is set which is the path to a CMake file that
+#                        can be included to compile lxqt applications and libraries. It sets up
+#                        the compilation environment for include directories and populates a
+#                        LXQT_LIBRARIES variable.
+#
+# When using the components argument, LXQT_USE_* variables are automatically set
+# for the LXQT_USE_FILE to pick up.  If one wishes to manually set them, the
+# available ones to set include:
+#               LXQT_USE_MOUNT
+#               LXQT_USE_GLOBAL_KEY_CLIENT
+#
+# Typical usage could be something like:
+#   set(LXQT_USE_MOUNT 1)
+#   find_package(LXQT REQUIRED)
+#   include(${LXQT_USE_FILE})
+#
+#   razor_translate_ts(QM_FILES
+#     SOURCES
+#        ${H_FILES}
+#        ${CPP_FILES}
+#        ${UI_FILES}
+#   )
+#   razor_translate_desktop(DESKTOP_FILES
+#     SOURCES
+#        ${DESKTOP_FILES_IN}
+#  )
+#
+#   add_executable(myexe main.cpp)
+#   target_link_libraries(myexe $LXQT_LIBRARIES})
+
+set(LXQT_QT_VERSION         @LXQT_QT_VERSION@)
+set(LXQT_MAJOR_VERSION      @LXQT_MAJOR_VERSION@)
+set(LXQT_MINOR_VERSION      @LXQT_MINOR_VERSION@)
+set(LXQT_PATCH_VERSION      @LXQT_PATCH_VERSION@)
+set(LXQT_VERSION            @LXQT_VERSION@)
+
+set(LXQT_SHARE_DIR          @LXQT_SHARE_DIR@)
+set(LXQT_TRANSLATIONS_DIR   @LXQT_TRANSLATIONS_DIR@)
+set(LXQT_ETC_XDG_DIR        @LXQT_ETC_XDG_DIR@)
+set(LXQT_INCLUDE_DIR        @LXQT_INCLUDE_DIR@)
+set(LXQT_LIBRARY            lxqt@LXQT_QT_VERSION@)
+
+set(LXQT_LIBRARIES          ${LXQT_LIBRARY} )
+set(LXQT_INCLUDE_DIRS       ${LXQT_INCLUDE_DIR} )
+set(LXQT_USE_FILE           ${CMAKE_CURRENT_LIST_DIR}/lxqt@LXQT_QT_VERSION@_use.cmake)
+set(LXQT_FOUND              1)
+set(LXQT@LXQT_QT_VERSION@_FOUND             1)
+
+mark_as_advanced(LXQT_LIBRARY LXQT_INCLUDE_DIR)
+
index 0ea1127..701bc2a 100644 (file)
@@ -49,8 +49,15 @@ add_definitions(-DRAZOR_ETC_XDG_DIR=\"${LXQT_ETC_XDG_DIR}\")
 add_definitions(-DRAZOR_VERSION=\"${LXQT_VERSION}\")
 # for backward compatability <-----
 
-find_package(Qt4 REQUIRED QUIET)
-include(${QT_USE_FILE})
+#if(LXQT_QT_VERSION STREQUAL "5")
+
+
+
+#else()
+#    find_package(Qt4 REQUIRED QUIET)
+#    include(${QT_USE_FILE})
+
+#endif()
 
 #**********************************************************
 # DESKTOP files
index 1dcee92..be35470 100644 (file)
@@ -25,7 +25,7 @@
 #include "lxqtconfigdialog.h"
 #include "ui_lxqtconfigdialog.h"
 
-#include <qtxdg/xdgicon.h>
+#include <xdgqt/XdgIcon>
 #include <QtGui/QPushButton>
 
 using namespace LxQt;
index f454823..6a078ab 100644 (file)
@@ -27,8 +27,8 @@
 
 #include <QtCore/QDir>
 
-#include <qtxdg/xdgicon.h>
-#include <qtxdg/xdgdirs.h>
+#include <xdgqt/XdgIcon>
+#include <xdgqt/XdgDirs>
 
 #include "lxqtapplication.h"
 #include "lxqtsettings.h"
index 8547e88..9533399 100644 (file)
@@ -23,8 +23,8 @@
  * END_COMMON_COPYRIGHT_HEADER */
 
 #include "lxqtautostartentry.h"
-#include <qtxdg/xdgautostart.h>
-#include <qtxdg/xdgdirs.h>
+#include <xdgqt/XdgAutoStart>
+#include <xdgqt/XdgDirs>
 #include <QtCore/QFileInfo>
 
 using namespace LxQt;
index af60c8f..f434729 100644 (file)
@@ -25,7 +25,7 @@
 #ifndef LXQTAUTOSTARTENTRY_H
 #define LXQTAUTOSTARTENTRY_H
 
-#include <qtxdg/xdgdesktopfile.h>
+#include <xdgqt/XdgDesktopFile>
 
 namespace LxQt
 {
index c454c86..1053287 100644 (file)
@@ -29,7 +29,7 @@
 #ifndef LXQTPLUGININFO_H
 #define LXQTPLUGININFO_H
 
-#include <qtxdg/xdgdesktopfile.h>
+#include <xdgqt/XdgDesktopFile>
 #include <QtCore/QString>
 #include <QtCore/QList>
 
index 1e3338f..3439810 100644 (file)
@@ -27,7 +27,7 @@
 
 #include "lxqtpowermanager.h"
 #include "lxqtpower/lxqtpower.h"
-#include <qtxdg/xdgicon.h>
+#include <xdgqt/XdgIcon>
 #include <QDBusInterface>
 #include <QMessageBox>
 #include <QApplication>
index 84a6a36..4a03ce2 100644 (file)
@@ -28,7 +28,7 @@
 #include <QtCore/QProcess>
 #include <QtGui/QMessageBox>
 
-#include <qtxdg/xdgicon.h>
+#include <xdgqt/XdgIcon>
 #include "lxqtscreensaver.h"
 #include "lxqttranslator.h"
 
index b76a190..f0cf2f0 100644 (file)
@@ -27,8 +27,8 @@
  * END_COMMON_COPYRIGHT_HEADER */
 
 #include "lxqtsettings.h"
-#include <qtxdg/xdgicon.h>
-#include <qtxdg/xdgdirs.h>
+#include <xdgqt/XdgIcon>
+#include <xdgqt/XdgDirs>
 #include <QtCore/QDebug>
 #include <QtCore/QEvent>
 #include <QtCore/QDir>
index cf94577..de81a05 100644 (file)
@@ -5,7 +5,7 @@
 #include <QCoreApplication>
 #include <QLibraryInfo>
 #include <QStringList>
-#include <qtxdg/XdgDirs>
+#include <xdgqt/XdgDirs>
 #include <QFileInfo>
 
 using namespace LxQt;
index 13d84c9..dee315d 100644 (file)
@@ -51,7 +51,6 @@
  * @brief implements class Xfitman
  * @author Christopher "VdoP" Regali
  */
-
 /*
  Some requests from Clients include type of the Client, for example the _NET_ACTIVE_WINDOW
  message. Currently the types can be 1 for normal applications, and 2 for pagers.
@@ -394,7 +393,7 @@ int XfitMan::clientMessage(Window _wid, Atom _msg,
     msg.data.l[2] = data2;
     msg.data.l[3] = data3;
     msg.data.l[4] = data4;
-    if (XSendEvent(QX11Info::display(), root, FALSE, (SubstructureRedirectMask | SubstructureNotifyMask) , (XEvent *) &msg) == Success)
+    if (XSendEvent(QX11Info::display(), root, false, (SubstructureRedirectMask | SubstructureNotifyMask) , (XEvent *) &msg) == Success)
         return EXIT_SUCCESS;
     else
         return EXIT_FAILURE;
index 62f0ee4..6ea5ffb 100644 (file)
@@ -411,12 +411,22 @@ TranslatorPerson::TranslatorPerson(const QString &englishName, const QString &na
 
     if (!mContact.isEmpty())
     {
+
+#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
         if (mContact.contains(QRegExp("^(https?|mailto):")))
             mInfo = QString(" <a href='%1'>%2</a>").arg(contact, Qt::escape(mInfo));
         else if (contact.contains("@") || contact.contains("<"))
             mInfo = QString(" <a href='mailto:%1'>%2</a>").arg(contact, Qt::escape(mInfo));
         else
             mInfo = QString(" <a href='http://%1'>%2</a>").arg(contact, Qt::escape(mInfo));
+#else
+        if (mContact.contains(QRegExp("^(https?|mailto):")))
+            mInfo = QString(" <a href='%1'>%2</a>").arg(contact, mInfo.toHtmlEscaped());
+        else if (contact.contains("@") || contact.contains("<"))
+            mInfo = QString(" <a href='mailto:%1'>%2</a>").arg(contact, mInfo.toHtmlEscaped());
+        else
+            mInfo = QString(" <a href='http://%1'>%2</a>").arg(contact, mInfo.toHtmlEscaped());
+#endif
     }
 }