From 1fa2e22491face77e72de8e30d5688790edf6532 Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 5 Dec 2015 18:48:59 +0100 Subject: [PATCH] Changed: Port some tools to Qt 5 --HG-- branch : develop --- code/CMakeLists.txt | 20 ++++++++++- code/CMakeModules/nel.cmake | 3 +- code/nel/tools/misc/CMakeLists.txt | 8 ++--- .../tools/misc/crash_report/CMakeLists.txt | 26 +++++++++----- .../misc/crash_report/crash_report_data.h | 7 +++- .../misc/crash_report/crash_report_socket.h | 3 +- .../misc/crash_report/crash_report_widget.h | 1 + .../tools/misc/message_box_qt/CMakeLists.txt | 13 ++++--- code/nel/tools/misc/message_box_qt/main.cpp | 6 ++++ .../tools/misc/words_dic_qt/CMakeLists.txt | 35 ++++++++++++------- code/nel/tools/misc/words_dic_qt/main.cpp | 3 +- .../tools/misc/words_dic_qt/words_dicDlg.cpp | 4 ++- .../tools/misc/words_dic_qt/words_dicDlg.h | 7 +++- 13 files changed, 100 insertions(+), 36 deletions(-) diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index c7b7ebd5f..855084abb 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -143,7 +143,25 @@ IF(WITH_SSE2) ENDIF(WITH_SSE3) ENDIF(WITH_SSE2) +IF(WITH_QT5) + CMAKE_MINIMUM_REQUIRED(VERSION 2.8.11 FATAL_ERROR) + + FIND_PACKAGE(Qt5Core QUIET) + + IF(Qt5Core_FOUND) + FIND_PACKAGE(Qt5Gui) + FIND_PACKAGE(Qt5Widgets) + FIND_PACKAGE(Qt5OpenGL) + FIND_PACKAGE(Qt5Xml) + FIND_PACKAGE(Qt5LinguistTools) + FIND_PACKAGE(Qt5Network) + ELSE() + MESSAGE(WARNING "Unable to find Qt 5") + ENDIF() +ENDIF() + IF(WITH_QT) + # Use Qt 4 FIND_PACKAGE(Qt4 COMPONENTS QtCore QtGui QtXml QtOpenGL REQUIRED) ENDIF(WITH_QT) @@ -182,7 +200,7 @@ IF(WITH_NEL) IF(IDN_LIBRARY) SET(CURL_LIBRARIES ${CURL_LIBRARIES} ${IDN_LIBRARY}) ENDIF() - + # CURL Macports version depends on libidn, libintl and libiconv too IF(APPLE) FIND_LIBRARY(INTL_LIBRARY intl) diff --git a/code/CMakeModules/nel.cmake b/code/CMakeModules/nel.cmake index aad4a245a..dd575ecc2 100644 --- a/code/CMakeModules/nel.cmake +++ b/code/CMakeModules/nel.cmake @@ -226,7 +226,8 @@ MACRO(NL_SETUP_DEFAULT_OPTIONS) # GUI toolkits ### OPTION(WITH_GTK "With GTK Support" OFF) - OPTION(WITH_QT "With QT Support" OFF) + OPTION(WITH_QT "With Qt 4 Support" OFF) + OPTION(WITH_QT5 "With Qt 5 Support" OFF) IF(WIN32 AND MFC_FOUND) OPTION(WITH_MFC "With MFC Support" ON ) diff --git a/code/nel/tools/misc/CMakeLists.txt b/code/nel/tools/misc/CMakeLists.txt index c9bbcd058..22328af82 100644 --- a/code/nel/tools/misc/CMakeLists.txt +++ b/code/nel/tools/misc/CMakeLists.txt @@ -1,10 +1,10 @@ SUBDIRS(bnp_make disp_sheet_id extract_filename lock make_sheet_id xml_packer) -IF(WITH_QT) +IF(WITH_QT OR WITH_QT5) ADD_SUBDIRECTORY(words_dic_qt) ADD_SUBDIRECTORY(message_box_qt) ADD_SUBDIRECTORY(crash_report) -ENDIF(WITH_QT) +ENDIF() IF(WIN32) ADD_SUBDIRECTORY(exec_timeout) @@ -17,7 +17,7 @@ IF(WIN32) ADD_SUBDIRECTORY(log_analyser) ADD_SUBDIRECTORY(log_analyser_plug_ins) ADD_SUBDIRECTORY(words_dic) - ENDIF(MFC_FOUND) -ENDIF(WIN32) + ENDIF() +ENDIF() ADD_SUBDIRECTORY(probe_timers) diff --git a/code/nel/tools/misc/crash_report/CMakeLists.txt b/code/nel/tools/misc/crash_report/CMakeLists.txt index 0e2d2a9bc..a67b2be5e 100644 --- a/code/nel/tools/misc/crash_report/CMakeLists.txt +++ b/code/nel/tools/misc/crash_report/CMakeLists.txt @@ -1,6 +1,6 @@ -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SRC_DIR} ${QT_INCLUDES}) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SRC_DIR}) FILE(GLOB CRASHREPORT_SRC *.cpp) -FILE(GLOB CRASHREPORT_HDR *h) +FILE(GLOB CRASHREPORT_HDR *.h) SET(CRASHREPORT_MOC_HDR crash_report_socket.h @@ -17,11 +17,21 @@ SET(QT_USE_QTMAIN TRUE) SET(QT_USE_QTOPENGL FALSE) SET(QT_USE_QTXML FALSE) -INCLUDE(${QT_USE_FILE}) -ADD_DEFINITIONS(${QT_DEFINITIONS}) +IF(WITH_QT) + INCLUDE_DIRECTORIES(${QT_INCLUDES}) + INCLUDE(${QT_USE_FILE}) + ADD_DEFINITIONS(${QT_DEFINITIONS}) -QT4_WRAP_CPP(CRASHREPORT_MOC_SRC ${CRASHREPORT_MOC_HDR}) -QT4_WRAP_UI(CRASHREPORT_UI_HDR ${CRASHREPORT_UI}) + QT4_WRAP_CPP(CRASHREPORT_MOC_SRC ${CRASHREPORT_MOC_HDR}) + QT4_WRAP_UI(CRASHREPORT_UI_HDR ${CRASHREPORT_UI}) + + SET(QT_LIBRARIES ${QT_LIBRARIES} ${QT_QTMAIN_LIBRARY}) +ELSE() + QT5_WRAP_CPP(CRASHREPORT_MOC_SRC ${CRASHREPORT_MOC_HDR}) + QT5_WRAP_UI(CRASHREPORT_UI_HDR ${CRASHREPORT_UI}) + + SET(QT_LIBRARIES Qt5::Widgets Qt5::Core Qt5::Gui Qt5::Network) +ENDIF() SOURCE_GROUP(QtResources FILES ${CRASHREPORT_UI}) SOURCE_GROUP(QtGeneratedUiHdr FILES ${CRASHREPORT_UI_HDR}) @@ -29,8 +39,8 @@ SOURCE_GROUP(QtGeneratedMocQrcSrc FILES ${CRASHREPORT_MOC_SRC}) SOURCE_GROUP("source files" FILES ${CRASHREPORT_SRC}) SOURCE_GROUP("header files" FILES ${CRASHREPORT_HDR}) -ADD_EXECUTABLE(crash_report WIN32 MACOSX_BUNDLE ${CRASHREPORT_SRC} ${CRASHREPORT_MOC_HDR} ${CRASHREPORT_MOC_SRC} ${CRASHREPORT_UI_HDR}) -TARGET_LINK_LIBRARIES(crash_report ${QT_LIBRARIES} ${QT_QTMAIN_LIBRARY}) +ADD_EXECUTABLE(crash_report WIN32 MACOSX_BUNDLE ${CRASHREPORT_SRC} ${CRASHREPORT_HDR} ${CRASHREPORT_MOC_SRC} ${CRASHREPORT_UI_HDR}) +TARGET_LINK_LIBRARIES(crash_report ${QT_LIBRARIES}) NL_DEFAULT_PROPS(crash_report "NeL, Tools, Misc: Crash Report") NL_ADD_RUNTIME_FLAGS(crash_report) diff --git a/code/nel/tools/misc/crash_report/crash_report_data.h b/code/nel/tools/misc/crash_report/crash_report_data.h index 5884e7eb4..8a7f2ffcb 100644 --- a/code/nel/tools/misc/crash_report/crash_report_data.h +++ b/code/nel/tools/misc/crash_report/crash_report_data.h @@ -20,8 +20,13 @@ #ifndef RCERROR_DATA #define RCERROR_DATA -#include +#include +#ifdef Q_COMPILER_RVALUE_REFS +#undef Q_COMPILER_RVALUE_REFS +#endif + +#include struct SCrashReportData { diff --git a/code/nel/tools/misc/crash_report/crash_report_socket.h b/code/nel/tools/misc/crash_report/crash_report_socket.h index 32ccc5da0..23965bf5d 100644 --- a/code/nel/tools/misc/crash_report/crash_report_socket.h +++ b/code/nel/tools/misc/crash_report/crash_report_socket.h @@ -20,9 +20,10 @@ #ifndef RCERROR_SOCKET #define RCERROR_SOCKET -#include #include "crash_report_data.h" +#include + class CCrashReportSocketPvt; class QNetworkReply; diff --git a/code/nel/tools/misc/crash_report/crash_report_widget.h b/code/nel/tools/misc/crash_report/crash_report_widget.h index f40e40854..fc5eae070 100644 --- a/code/nel/tools/misc/crash_report/crash_report_widget.h +++ b/code/nel/tools/misc/crash_report/crash_report_widget.h @@ -20,6 +20,7 @@ #ifndef RCERROR_WIDGET #define RCERROR_WIDGET +#include "crash_report_data.h" #include "ui_crash_report_widget.h" #include diff --git a/code/nel/tools/misc/message_box_qt/CMakeLists.txt b/code/nel/tools/misc/message_box_qt/CMakeLists.txt index 408bf867e..708e86cf7 100644 --- a/code/nel/tools/misc/message_box_qt/CMakeLists.txt +++ b/code/nel/tools/misc/message_box_qt/CMakeLists.txt @@ -1,13 +1,18 @@ -INCLUDE_DIRECTORIES(${QT_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) -INCLUDE( ${QT_USE_FILE} ) +IF(WITH_QT) + INCLUDE_DIRECTORIES(${QT_INCLUDES}) + INCLUDE(${QT_USE_FILE}) +ELSE() + SET(QT_LIBRARIES Qt5::Widgets Qt5::Core Qt5::Gui) +ENDIF() + +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) FILE(GLOB MESSAGE_BOX_SRC *.cpp) SET( QT_USE_QT3SUPPORT TRUE) SET( QT_USE_QTXML TRUE) -ADD_EXECUTABLE(message_box_qt ${MESSAGE_BOX_SRC}) - +ADD_EXECUTABLE(message_box_qt WIN32 ${MESSAGE_BOX_SRC}) TARGET_LINK_LIBRARIES(message_box_qt ${QT_LIBRARIES} nelmisc) NL_DEFAULT_PROPS(message_box_qt "NeL, Tools, Misc: Qt Message Box") NL_ADD_RUNTIME_FLAGS(message_box_qt) diff --git a/code/nel/tools/misc/message_box_qt/main.cpp b/code/nel/tools/misc/message_box_qt/main.cpp index 5090bc951..cab992ef6 100644 --- a/code/nel/tools/misc/message_box_qt/main.cpp +++ b/code/nel/tools/misc/message_box_qt/main.cpp @@ -1,3 +1,9 @@ +#include + +#ifdef Q_COMPILER_RVALUE_REFS +#undef Q_COMPILER_RVALUE_REFS +#endif + #include #include #include diff --git a/code/nel/tools/misc/words_dic_qt/CMakeLists.txt b/code/nel/tools/misc/words_dic_qt/CMakeLists.txt index 2f755dfc1..55a0a1c66 100644 --- a/code/nel/tools/misc/words_dic_qt/CMakeLists.txt +++ b/code/nel/tools/misc/words_dic_qt/CMakeLists.txt @@ -1,32 +1,41 @@ -INCLUDE_DIRECTORIES(${QT_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) -INCLUDE( ${QT_USE_FILE} ) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) -FILE(GLOB WORDS_DIC_SRC *.cpp) +FILE(GLOB WORDS_DIC_SRC *.cpp *.h) SET(WORDS_DIC_HDR words_dicDlg.h) SET(WORDS_DIC_UIS words_dic_Qt.ui) SET(WORDS_DIC_RCS words_dic_Qt.qrc) IF(WIN32) SET(WORDS_DIC_RC words_dic.rc) -ENDIF(WIN32) +ENDIF() ADD_DEFINITIONS(-DNL_WORDS_DIC_CFG="\\"${NL_ETC_PREFIX}/\\"") -SET( QT_USE_QT3SUPPORT TRUE) -SET( QT_USE_QTXML TRUE) +IF(WITH_QT) + INCLUDE_DIRECTORIES(${QT_INCLUDES}) + INCLUDE(${QT_USE_FILE}) -QT4_ADD_RESOURCES( WORDS_DIC_RC_SRCS ${WORDS_DIC_RCS} ) -QT4_WRAP_UI( WORDS_DIC_UI_HDRS ${WORDS_DIC_UIS} ) -QT4_WRAP_CPP( WORDS_DIC_MOC_SRCS ${WORDS_DIC_HDR}) + SET(QT_USE_QT3SUPPORT TRUE) + SET(QT_USE_QTXML TRUE) -ADD_EXECUTABLE(words_dic_qt ${WORDS_DIC_SRC} ${WORDS_DIC_MOC_SRCS} ${WORDS_DIC_RC_SRCS} ${WORDS_DIC_UI_HDRS} ${WORDS_DIC_RC}) + QT4_ADD_RESOURCES(WORDS_DIC_RC_SRCS ${WORDS_DIC_RCS}) + QT4_WRAP_UI(WORDS_DIC_UI_HDRS ${WORDS_DIC_UIS}) + QT4_WRAP_CPP(WORDS_DIC_MOC_SRCS ${WORDS_DIC_HDR}) + + ADD_DEFINITIONS(${QT_DEFINITIONS}) +ELSE() + SET(QT_LIBRARIES Qt5::Widgets Qt5::Core Qt5::Gui) + + QT5_ADD_RESOURCES(WORDS_DIC_RC_SRCS ${WORDS_DIC_RCS}) + QT5_WRAP_UI(WORDS_DIC_UI_HDRS ${WORDS_DIC_UIS}) + QT5_WRAP_CPP(WORDS_DIC_MOC_SRCS ${WORDS_DIC_HDR}) +ENDIF() + +ADD_EXECUTABLE(words_dic_qt WIN32 ${WORDS_DIC_SRC} ${WORDS_DIC_MOC_SRCS} ${WORDS_DIC_RC_SRCS} ${WORDS_DIC_UI_HDRS} ${WORDS_DIC_RC}) TARGET_LINK_LIBRARIES(words_dic_qt ${QT_LIBRARIES} nelmisc) NL_DEFAULT_PROPS(words_dic_qt "NeL, Tools, Misc: Qt Words Dic") NL_ADD_RUNTIME_FLAGS(words_dic_qt) -ADD_DEFINITIONS(${QT_DEFINITIONS}) - INSTALL(TARGETS words_dic_qt RUNTIME DESTINATION ${NL_BIN_PREFIX} COMPONENT toolsmisc) INSTALL(FILES words_dic.cfg DESTINATION ${NL_ETC_PREFIX} COMPONENT toolsmisc) - diff --git a/code/nel/tools/misc/words_dic_qt/main.cpp b/code/nel/tools/misc/words_dic_qt/main.cpp index 6799511bb..31429289c 100644 --- a/code/nel/tools/misc/words_dic_qt/main.cpp +++ b/code/nel/tools/misc/words_dic_qt/main.cpp @@ -1,7 +1,8 @@ +#include "words_dicDlg.h" + #include #include "nel/misc/app_context.h" #include "nel/misc/path.h" -#include "words_dicDlg.h" #ifdef NL_OS_UNIX #include diff --git a/code/nel/tools/misc/words_dic_qt/words_dicDlg.cpp b/code/nel/tools/misc/words_dic_qt/words_dicDlg.cpp index 683755ae6..8fd4a432b 100644 --- a/code/nel/tools/misc/words_dic_qt/words_dicDlg.cpp +++ b/code/nel/tools/misc/words_dic_qt/words_dicDlg.cpp @@ -1,10 +1,12 @@ +#include "words_dicDlg.h" + #include #include #include #include #include +#include #include -#include "words_dicDlg.h" using namespace std; using namespace NLMISC; diff --git a/code/nel/tools/misc/words_dic_qt/words_dicDlg.h b/code/nel/tools/misc/words_dic_qt/words_dicDlg.h index 22e8dbdd0..707eaaa44 100644 --- a/code/nel/tools/misc/words_dic_qt/words_dicDlg.h +++ b/code/nel/tools/misc/words_dic_qt/words_dicDlg.h @@ -1,7 +1,12 @@ - #ifndef WORDS_DICDLG_H #define WORDS_DICDLG_H +#include + +#ifdef Q_COMPILER_RVALUE_REFS +#undef Q_COMPILER_RVALUE_REFS +#endif + #include #include "ui_words_dic_Qt.h"