diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index a05b0e17..2326b54c 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -4,16 +4,6 @@ Cockatrice is written in C++-03, so do not use C++11 constructs such as `auto`. -Cockatrice support both Qt 4 and Qt 5, so make sure that your code compiles -with both. If there have been breaking changes between Qt 4 and 5, use a -statement such as - - #if QT_VERSION >= 0x500000 - doSomethingWithQt5(); - #else - doSomethingWithQt4(); - #endif - For consistency, use Qt data structures where possible, such as `QString` over `std::string` or `QList` over `std::vector`. diff --git a/.travis.yml b/.travis.yml index b8a00074..0f5536b5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,26 +2,20 @@ language: cpp matrix: fast_finish: true include: - # linux precise debug build, precise + gcc + qt4 - - os: linux - env: QT4=1 BUILDTYPE=Debug DIST=precise # linux debug build, trusty + gcc + qt5 - os: linux dist: trusty - env: QT4=0 BUILDTYPE=Debug DIST=trusty + env: BUILDTYPE=Debug DIST=trusty # osx debug build, osx + clang + qt5 - os: osx - env: QT4=0 BUILDTYPE=Debug - # linux precise release build, precise + gcc + qt4 - - os: linux - env: QT4=1 BUILDTYPE=Release DIST=precise + env: BUILDTYPE=Debug # linux trusty release build, precise + gcc + qt5 - os: linux dist: trusty - env: QT4=0 BUILDTYPE=Release DIST=trusty + env: BUILDTYPE=Release DIST=trusty # osx release build, osx + gcc + qt5 - os: osx - env: QT4=0 BUILDTYPE=Release + env: BUILDTYPE=Release script: ./travis-compile.sh install: ./travis-dependencies.sh cache: apt diff --git a/CMakeLists.txt b/CMakeLists.txt index 894bcb8a..416bedd7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -110,17 +110,11 @@ IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") ADD_DEFINITIONS("-DSFMT_MEXP=19937") ENDIF() -# Find Qt and enable the needed features -# Default is Qt5 unless WITH_QT4 option is enabled -option(WITH_QT4 "Force the use of Qt4 libraries" OFF) +# Find Qt5 OPTION(UPDATE_TRANSLATIONS "Update translations on compile" OFF) MESSAGE(STATUS "UPDATE TRANSLATIONS: ${UPDATE_TRANSLATIONS}") -IF(NOT WITH_QT4) - # First known not-broken Qt5 version (5.0.2 available on old ubuntus is buggy). - FIND_PACKAGE(Qt5Widgets 5.0.3) -ENDIF() - +FIND_PACKAGE(Qt5Widgets 5.0.3 REQUIRED) IF(Qt5Widgets_FOUND) MESSAGE(STATUS "Found Qt ${Qt5Widgets_VERSION_STRING}") @@ -141,27 +135,7 @@ IF(Qt5Widgets_FOUND) ENDIF() ELSE() - FIND_PACKAGE(Qt4 4.8.0 REQUIRED) - IF(QT4_FOUND) - # Old FindQt4.cmake modules used the same flag with different case - SET(Qt4_FOUND TRUE) - ENDIF() - IF(Qt4_FOUND) - MESSAGE(STATUS "Found Qt ${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH}") - - IF(UPDATE_TRANSLATIONS) - IF(NOT QT_LUPDATE_EXECUTABLE) - MESSAGE(WARNING "Qt's lupdate not found.") - ENDIF() - ENDIF() - - IF(NOT QT_LRELEASE_EXECUTABLE) - MESSAGE(WARNING "Qt's lrelease not found.") - ENDIF() - - ELSE() - MESSAGE(FATAL_ERROR "No Qt4 or Qt5 found!") - ENDIF() + MESSAGE(FATAL_ERROR "No Qt5 found!") ENDIF() set(CMAKE_AUTOMOC TRUE) @@ -200,9 +174,7 @@ if(UNIX) set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) set(CPACK_DEBIAN_PACKAGE_SECTION "games") set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "http://github.com/Cockatrice/Cockatrice") - IF(Qt5Widgets_FOUND) - set(CPACK_DEBIAN_PACKAGE_DEPENDS "libqt5multimedia5-plugins, libqt5svg5") - ENDIF() + set(CPACK_DEBIAN_PACKAGE_DEPENDS "libqt5multimedia5-plugins, libqt5svg5") endif() elseif(WIN32) set(CPACK_GENERATOR NSIS ${CPACK_GENERATOR}) diff --git a/Dockerfile b/Dockerfile index ad0352b0..d0af357a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,7 +27,7 @@ COPY servatrice/ servatrice/ COPY README.md README.md WORKDIR build -RUN cmake .. -DWITH_QT4=0 -DWITH_SERVER=1 -DWITH_CLIENT=0 -DWITH_ORACLE=0 &&\ +RUN cmake .. -DWITH_SERVER=1 -DWITH_CLIENT=0 -DWITH_ORACLE=0 &&\ make &&\ make install diff --git a/README.md b/README.md index 4c9e3355..9a8ff92e 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ # Cockatrice -Cockatrice is an open-source multiplatform supported program for playing tabletop card games over a network. The program's server design prevents any kind of client modifications to gain an unfair advantage in a game. The client also has a built in single-player mode where you can brew without being connected to a server. This project is written in C++/Qt with support for both Qt4 and Qt5.
+Cockatrice is an open-source multiplatform supported program for playing tabletop card games over a network. The program's server design prevents any kind of client modifications to gain an unfair advantage in a game. The client also has a built in single-player mode where you can brew without being connected to a server. This project is written in C++ and is using the Qt5 libraries.
# Downloads @@ -60,10 +60,6 @@ Dependencies: Oracle can optionally use zlib to load zipped files: - [zlib](http://www.zlib.net/) (no https!) -The server requires an additional dependency when compiled under Qt4: -- [libgcrypt](https://www.gnu.org/software/libgcrypt/) - - To compile: mkdir build @@ -87,7 +83,6 @@ The following flags can be passed to `cmake`: - `-DWITH_CLIENT=0` Whether to build the client (default 1 = yes). - `-DWITH_ORACLE=0` Whether to build oracle (default 1 = yes). - `-DPORTABLE=1` Build portable versions of client & oracle (default 0 = no). -- `-DWITH_QT4=1` Force compilation to use Qt4 instead of Qt5 (default 0 = no). - `-DCMAKE_BUILD_TYPE=Debug` Compile in debug mode. Enables extra logging output, debug symbols, and much more verbose compiler warnings (default `Release`). - `-DUPDATE_TRANSLATIONS=1` Configure `make` to update the translation .ts files for new strings in the source code. Note: Running `make clean` will remove the .ts files (default 0 = no). - `-DTEST=1` Enable regression tests (default 0 = no). Note: needs googletest, will be downloaded on the fly if unavailable. To run tests: ```make test```. diff --git a/cmake/FindLibgcrypt.cmake b/cmake/FindLibgcrypt.cmake deleted file mode 100644 index 880a5d69..00000000 --- a/cmake/FindLibgcrypt.cmake +++ /dev/null @@ -1,46 +0,0 @@ -# -*- cmake -*- - -# Copied from http://code.google.com/p/emeraldviewer/ - -# - Find libgcrypt -# Find the libgcrypt includes and library -# This module defines -# LIBGCRYPT_INCLUDE_DIR, where to find gcrypt.h, etc. -# LIBGCRYPT_LIBRARIES, the libraries needed to use libgcrypt. -# LIBGCRYPT_FOUND, If false, do not try to use libgcrypt. -# also defined, but not for general use are -# LIBGCRYPT_LIBRARY, where to find the libgcrypt library. - -FIND_PATH(LIBGCRYPT_INCLUDE_DIR gcrypt.h) - -SET(LIBGCRYPT_NAMES ${LIBGCRYPT_NAMES} gcrypt) -FIND_LIBRARY(LIBGCRYPT_LIBRARY - NAMES ${LIBGCRYPT_NAMES} - ) - -IF (LIBGCRYPT_LIBRARY AND LIBGCRYPT_INCLUDE_DIR) - SET(LIBGCRYPT_LIBRARIES ${LIBGCRYPT_LIBRARY}) - SET(LIBGCRYPT_FOUND "YES") -ELSE (LIBGCRYPT_LIBRARY AND LIBGCRYPT_INCLUDE_DIR) - SET(LIBGCRYPT_FOUND "NO") -ENDIF (LIBGCRYPT_LIBRARY AND LIBGCRYPT_INCLUDE_DIR) - - -IF (LIBGCRYPT_FOUND) - IF (NOT LIBGCRYPT_FIND_QUIETLY) - MESSAGE(STATUS "Found libgcrypt: '${LIBGCRYPT_LIBRARIES}' and header in '${LIBGCRYPT_INCLUDE_DIR}'") - ENDIF (NOT LIBGCRYPT_FIND_QUIETLY) -ELSE (LIBGCRYPT_FOUND) - IF (LIBGCRYPT_FIND_REQUIRED) - MESSAGE(FATAL_ERROR "Could not find libgcrypt library") - ENDIF (LIBGCRYPT_FIND_REQUIRED) -ENDIF (LIBGCRYPT_FOUND) - -# Deprecated declarations. -SET (NATIVE_LIBGCRYPT_INCLUDE_PATH ${LIBGCRYPT_INCLUDE_DIR} ) -GET_FILENAME_COMPONENT (NATIVE_LIBGCRYPT_LIB_PATH ${LIBGCRYPT_LIBRARY} PATH) - -MARK_AS_ADVANCED( - LIBGCRYPT_LIBRARY - LIBGCRYPT_INCLUDE_DIR - ) diff --git a/cmake/FindQtMobility.cmake b/cmake/FindQtMobility.cmake deleted file mode 100644 index 8e7edf5e..00000000 --- a/cmake/FindQtMobility.cmake +++ /dev/null @@ -1,158 +0,0 @@ -INCLUDE(FindQt4) - -set(MOBILITY_CONFIG_MKSPECS_FILE "") -IF(EXISTS "${QT_MKSPECS_DIR}/features/mobilityconfig.prf") - set(MOBILITY_CONFIG_MKSPECS_FILE "${QT_MKSPECS_DIR}/features/mobilityconfig.prf") -ELSEIF(EXISTS "${QT_MKSPECS_DIR}/features/mobility.prf") - set(MOBILITY_CONFIG_MKSPECS_FILE "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/mobilityconfig.prf") -ENDIF() - -macro(export_component component) - IF(NOT ${MOBILITY_CONFIG_MKSPECS_FILE} STREQUAL "") - FILE(READ ${MOBILITY_CONFIG_MKSPECS_FILE} MOBILITY_FILE_CONTENTS) - STRING(TOLOWER ${component} _COMPONENT) - IF(${MOBILITY_FILE_CONTENTS} MATCHES "MOBILITY_CONFIG=.*${_COMPONENT}.*") - STRING(TOUPPER ${component} _COMPONENT) - SET(QT_MOBILITY_${_COMPONENT}_FOUND 1) - SET(QT_MOBILITY_${_COMPONENT}_INCLUDE_DIR ${QT_MOBILITY_PARENT_INCLUDE_DIR}/Qt${component}) - SET(QT_MOBILITY_${_COMPONENT}_LIBRARY Qt${component}) - ENDIF() - ENDIF() -endmacro() - -set(VERSION_INFO "") -set(FEATURE_FILE_PREFIX "${QT_MKSPECS_DIR}/features/mobility") - -if(DEFINED MOBILITY_VERSION) - if(MOBILITY_VERSION STREQUAL "1.1" AND EXISTS "${FEATURE_FILE_PREFIX}11.prf") - set(MOBILITY_PRF_FILE "${FEATURE_FILE_PREFIX}11.prf") - set(VERSION_INFO "1.1") - elseif(MOBILITY_VERSION STREQUAL "1.2" AND EXISTS "${FEATURE_FILE_PREFIX}12.prf") - set(MOBILITY_PRF_FILE "${FEATURE_FILE_PREFIX}12.prf") - set(VERSION_INFO "1.2") - elseif(MOBILITY_VERSION STREQUAL "default" AND EXISTS "${FEATURE_FILE_PREFIX}.prf") - set(MOBILITY_PRF_FILE "${FEATURE_FILE_PREFIX}.prf") - set(VERSION_INFO "system's default") - else() - message(STATUS "Couldn't find QtMobility version: ${MOBILITY_VERSION}") - endif() -endif() - -if(NOT DEFINED MOBILITY_PRF_FILE) - if(EXISTS "${FEATURE_FILE_PREFIX}.prf") - set(MOBILITY_PRF_FILE "${FEATURE_FILE_PREFIX}.prf") - set(VERSION_INFO "system's default") - elseif(EXISTS "${FEATURE_FILE_PREFIX}12.prf") - set(MOBILITY_PRF_FILE "${FEATURE_FILE_PREFIX}12.prf") - set(VERSION_INFO "1.2") - elseif(EXISTS "${FEATURE_FILE_PREFIX}11.prf") - set(MOBILITY_PRF_FILE "${FEATURE_FILE_PREFIX}11.prf") - set(VERSION_INFO "1.1") - else() - message(FATAL_ERROR "Couldn't find any version of QtMobility.") - endif() -endif() - -message(STATUS "Using QtMobility version: ${VERSION_INFO}") - -IF(DEFINED MOBILITY_PRF_FILE) - FILE(READ ${MOBILITY_PRF_FILE} MOBILITY_FILE_CONTENTS) - - STRING(REGEX MATCH "MOBILITY_PREFIX=([^\n]+)" QT_MOBILITY_PREFIX "${MOBILITY_FILE_CONTENTS}") - SET(QT_MOBILITY_PREFIX ${CMAKE_MATCH_1}) - - STRING(REGEX MATCH "MOBILITY_INCLUDE=([^\n]+)" QT_MOBILITY_INCLUDE_DIR "${MOBILITY_FILE_CONTENTS}") - SET(QT_MOBILITY_INCLUDE_DIR ${CMAKE_MATCH_1}) - - STRING(REGEX MATCH "MOBILITY_LIB=([^\n]+)" "\\1" QT_MOBILITY_LIBRARY "${MOBILITY_FILE_CONTENTS}") - SET(QT_MOBILITY_LIBRARY_DIR ${CMAKE_MATCH_1}) - - #VERSION - IF(NOT ${MOBILITY_CONFIG_MKSPECS_FILE} STREQUAL "") - FILE(READ ${MOBILITY_CONFIG_MKSPECS_FILE} MOBILITY_CONFIG_FILE_CONTENTS) - STRING(REGEX MATCH "MOBILITY_VERSION = ([^\n]+)" QT_MOBILITY_VERSION "${MOBILITY_CONFIG_FILE_CONTENTS}") - SET(QT_MOBILITY_VERSION ${CMAKE_MATCH_1}) - - STRING(REGEX MATCH "MOBILITY_MAJOR_VERSION = ([^\n]+)" QT_MOBILITY_MAJOR_VERSION "${MOBILITY_CONFIG_FILE_CONTENTS}") - SET(QT_MOBILITY_MAJOR_VERSION ${CMAKE_MATCH_1}) - - STRING(REGEX MATCH "MOBILITY_MINOR_VERSION = ([^\n]+)" QT_MOBILITY_MINOR_VERSION "${MOBILITY_CONFIG_FILE_CONTENTS}") - SET(QT_MOBILITY_MINOR_VERSION ${CMAKE_MATCH_1}) - - STRING(REGEX MATCH "MOBILITY_PATCH_VERSION = ([^\n]+)" QT_MOBILITY_PATCH_VERSION "${MOBILITY_CONFIG_FILE_CONTENTS}") - SET(QT_MOBILITY_PATCH_VERSION ${CMAKE_MATCH_1}) - ELSE() - SET(QT_MOBILITY_VERSION 1.0.0) - SET(QT_MOBILITY_MAJOR_VERSION 1) - SET(QT_MOBILITY_MINOR_VERSION 0) - SET(QT_MOBILITY_PATCH_VERSION 0) - ENDIF() - - SET(QT_MOBILITY_PARENT_INCLUDE_DIR ${QT_MOBILITY_INCLUDE_DIR}) - SET(QT_MOBILITY_INCLUDE_DIR ${QT_MOBILITY_INCLUDE_DIR}/QtMobility) - - IF(QtMobility_FIND_VERSION_EXACT) - IF(QT_MOBILITY_VERSION VERSION_EQUAL QtMobility_FIND_VERSION) - SET(QT_MOBILITY_FOUND TRUE) - ELSE() - SET(QT_MOBILITY_FOUND FALSE) - IF(QT_MOBILITY_VERSION VERSION_LESS QtMobility_FIND_VERSION) - SET(QT_MOBILITY_TOO_OLD TRUE) - ELSE() - SET(QT_MOBILITY_TOO_NEW TRUE) - ENDIF() - ENDIF() - ELSE() - IF(QT_MOBILITY_VERSION VERSION_LESS QtMobility_FIND_VERSION) - SET(QT_MOBILITY_FOUND FALSE) - SET(QT_MOBILITY_TOO_OLD TRUE) - ELSE() - SET(QT_MOBILITY_FOUND TRUE) - ENDIF() - ENDIF() -ELSE() - SET(QT_MOBILITY_FOUND NOTFOUND) - SET(QT_MOBILITY_PREFIX NOTFOUND) - SET(QT_MOBILITY_INCLUDE NOTFOUND) - SET(QT_MOBILITY_LIB NOTFOUND) -ENDIF() - -IF(NOT QT_MOBILITY_FOUND) - if(QT_MOBILITY_TOO_OLD) - MESSAGE(FATAL_ERROR "The installed QtMobility version ${QT_MOBILITY_VERSION} it too old, version ${QtMobility_FIND_VERSION} is required.") - ELSEIF(QT_MOBILITY_TOO_NEW) - MESSAGE(FATAL_ERROR "The installed QtMobility version ${QT_MOBILITY_VERSION} it too new, version ${QtMobility_FIND_VERSION} is required.") - ELSE() - MESSAGE(FATAL_ERROR "QtMobility not found.") - ENDIF() -ELSE() - export_component(Bearer) - export_component(Feedback) - export_component(Gallery) - export_component(PublishSubscribe) - export_component(Location) - export_component(Organizer) - export_component(ServiceFramework) - export_component(SystemInfo) - export_component(Contacts) - export_component(Messaging) - export_component(Versit) - export_component(Sensors) - # VersitOrganizer - if(${QT_MOBILITY_CONTACTS_FOUND} AND ${QT_MOBILITY_VERSIT_FOUND}) - SET(QT_MOBILITY_VERSITORGANIZER_FOUND 1) - SET(QT_MOBILITY_VERSITORGANIZER_INCLUDE_DIR ${QT_MOBILITY_PARENT_INCLUDE_DIR}/QtVersitOrganizer) - SET(QT_MOBILITY_VERSITORGANIZER_LIBRARY QtVersitOrganizer) - endif() - - # MultimediaKit - it's just 'multimedia' in the .prf file. - IF(NOT ${MOBILITY_CONFIG_MKSPECS_FILE} STREQUAL "") - FILE(READ ${MOBILITY_CONFIG_MKSPECS_FILE} MOBILITY_FILE_CONTENTS) - IF(${MOBILITY_FILE_CONTENTS} MATCHES "MOBILITY_CONFIG=.*multimedia.*") - SET(QT_MOBILITY_MULTIMEDIAKIT_FOUND 1) - SET(QT_MOBILITY_MULTIMEDIAKIT_INCLUDE_DIR ${QT_MOBILITY_PARENT_INCLUDE_DIR}/QtMultimediaKit) - SET(QT_MOBILITY_MULTIMEDIAKIT_LIBRARY QtMultimediaKit) - ENDIF() - ENDIF() - -ENDIF() diff --git a/cockatrice/CMakeLists.txt b/cockatrice/CMakeLists.txt index 1de79b78..17398e4b 100644 --- a/cockatrice/CMakeLists.txt +++ b/cockatrice/CMakeLists.txt @@ -139,36 +139,6 @@ ENDIF(APPLE) set(COCKATRICE_LIBS) -# Qt4 stuff -if(Qt4_FOUND) - if (NOT QT_QTMULTIMEDIA_FOUND) - FIND_PACKAGE(QtMobility REQUIRED) - endif() - - SET(QT_USE_QTNETWORK TRUE) - SET(QT_USE_QTMULTIMEDIA TRUE) - SET(QT_USE_QTSVG TRUE) - - # Include directories - INCLUDE(${QT_USE_FILE}) - INCLUDE_DIRECTORIES(${QT_INCLUDES}) - INCLUDE_DIRECTORIES(${QT_MOBILITY_INCLUDE_DIR}) - INCLUDE_DIRECTORIES(${QT_MOBILITY_MULTIMEDIAKIT_INCLUDE_DIR}) - LIST(APPEND COCKATRICE_LIBS ${QT_LIBRARIES}) - LIST(APPEND COCKATRICE_LIBS ${QT_QTMAIN_LIBRARY}) - LIST(APPEND COCKATRICE_LIBS ${QT_MOBILITY_MULTIMEDIAKIT_LIBRARY}) - - # Let cmake chew Qt4's translations and resource files - # Note: header files are MOC-ed automatically by cmake - IF(UPDATE_TRANSLATIONS) - QT4_CREATE_TRANSLATION(cockatrice_QM ${translate_SRCS} ${cockatrice_TS}) - ELSE(UPDATE_TRANSLATIONS) - QT4_ADD_TRANSLATION(cockatrice_QM ${cockatrice_TS}) - ENDIF(UPDATE_TRANSLATIONS) - - QT4_ADD_RESOURCES(cockatrice_RESOURCES_RCC ${cockatrice_RESOURCES}) -endif() - # qt5 stuff if(Qt5Widgets_FOUND) include_directories(${Qt5Widgets_INCLUDE_DIRS}) @@ -245,20 +215,12 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) # Build cockatrice binary and link it ADD_EXECUTABLE(cockatrice WIN32 MACOSX_BUNDLE ${cockatrice_SOURCES} ${cockatrice_QM} ${cockatrice_RESOURCES_RCC} ${cockatrice_MOC_SRCS}) -if(Qt4_FOUND) - if(MSVC) - set(QT_USE_QTMAIN true) - endif() - TARGET_LINK_LIBRARIES(cockatrice cockatrice_common ${COCKATRICE_LIBS}) -endif() -if(Qt5Widgets_FOUND) - if(MSVC) - TARGET_LINK_LIBRARIES(cockatrice cockatrice_common Qt5::WinMain) - else() - TARGET_LINK_LIBRARIES(cockatrice cockatrice_common) - endif() - qt5_use_modules(cockatrice ${COCKATRICE_LIBS}) +if(MSVC) + TARGET_LINK_LIBRARIES(cockatrice cockatrice_common Qt5::WinMain) +else() + TARGET_LINK_LIBRARIES(cockatrice cockatrice_common) endif() +qt5_use_modules(cockatrice ${COCKATRICE_LIBS}) if(UNIX) if(APPLE) @@ -291,11 +253,9 @@ if(APPLE) set(qtconf_dest_dir cockatrice.app/Contents/Resources) get_filename_component(QT_LIBRARY_DIR "${QT_LIBRARY_DIR}/.." ABSOLUTE) - # qt4: codecs, iconengines, imageformats - # qt5: audio, iconengines, imageformats, platforms, printsupport - + # qt5 plugins: audio, iconengines, imageformats, platforms, printsupport install(DIRECTORY "${QT_PLUGINS_DIR}/" DESTINATION ${plugin_dest_dir} COMPONENT Runtime - FILES_MATCHING REGEX "(audio|codecs|iconengines|imageformats|platforms|printsupport)/.*\\.dylib" + FILES_MATCHING REGEX "(audio|iconengines|imageformats|platforms|printsupport)/.*\\.dylib" REGEX ".*_debug\\.dylib" EXCLUDE) install(CODE " @@ -319,11 +279,9 @@ if(WIN32) set(plugin_dest_dir Plugins) set(qtconf_dest_dir .) - # qt4: codecs, iconengines, imageformats - # qt5: audio, iconengines, imageformats, platforms, printsupport - + # qt5 plugins: audio, iconengines, imageformats, platforms, printsupport install(DIRECTORY "${QT_PLUGINS_DIR}/" DESTINATION ${plugin_dest_dir} COMPONENT Runtime - FILES_MATCHING REGEX "(audio|codecs|iconengines|imageformats|platforms|printsupport)/.*[^d]\\.dll") + FILES_MATCHING REGEX "(audio|iconengines|imageformats|platforms|printsupport)/.*[^d]\\.dll") install(CODE " file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${qtconf_dest_dir}/qt.conf\" \"[Paths] diff --git a/cockatrice/src/abstractcounter.cpp b/cockatrice/src/abstractcounter.cpp index 0b07d980..1ff3bcce 100644 --- a/cockatrice/src/abstractcounter.cpp +++ b/cockatrice/src/abstractcounter.cpp @@ -12,11 +12,7 @@ AbstractCounter::AbstractCounter(Player *_player, int _id, const QString &_name, bool _shownInCounterArea, int _value, QGraphicsItem *parent) : QGraphicsItem(parent), player(_player), id(_id), name(_name), value(_value), hovered(false), aDec(0), aInc(0), dialogSemaphore(false), deleteAfterDialog(false), shownInCounterArea(_shownInCounterArea) { -#if QT_VERSION < 0x050000 - setAcceptsHoverEvents(true); -#else setAcceptHoverEvents(true); -#endif shortcutActive = false; @@ -149,12 +145,7 @@ void AbstractCounter::setCounter() bool ok; dialogSemaphore = true; int newValue = -#if QT_VERSION < 0x050000 - QInputDialog::getInteger( -#else - QInputDialog::getInt( -#endif - 0, tr("Set counter"), tr("New value for counter '%1':").arg(name), value, -2000000000, 2000000000, 1, &ok); + QInputDialog::getInt(0, tr("Set counter"), tr("New value for counter '%1':").arg(name), value, -2000000000, 2000000000, 1, &ok); if (deleteAfterDialog) { deleteLater(); return; diff --git a/cockatrice/src/deckstats_interface.cpp b/cockatrice/src/deckstats_interface.cpp index 6e73396d..a5884669 100644 --- a/cockatrice/src/deckstats_interface.cpp +++ b/cockatrice/src/deckstats_interface.cpp @@ -6,10 +6,7 @@ #include #include #include - -#if QT_VERSION >= 0x050000 #include -#endif DeckStatsInterface::DeckStatsInterface( CardDatabase &_cardDatabase, @@ -50,19 +47,12 @@ void DeckStatsInterface::getAnalyzeRequestData(DeckList *deck, QByteArray *data) DeckList deckWithoutTokens; copyDeckWithoutTokens(*deck, deckWithoutTokens); -#if QT_VERSION < 0x050000 - QUrl params; - params.addQueryItem("deck", deckWithoutTokens.writeToString_Plain()); - params.addQueryItem("decktitle", deck->getName()); - data->append(params.encodedQuery()); -#else QUrl params; QUrlQuery urlQuery; urlQuery.addQueryItem("deck", deckWithoutTokens.writeToString_Plain()); urlQuery.addQueryItem("decktitle", deck->getName()); params.setQuery(urlQuery); data->append(params.query(QUrl::EncodeReserved)); -#endif } void DeckStatsInterface::analyzeDeck(DeckList *deck) diff --git a/cockatrice/src/deckview.cpp b/cockatrice/src/deckview.cpp index db0e3aba..5b68a687 100644 --- a/cockatrice/src/deckview.cpp +++ b/cockatrice/src/deckview.cpp @@ -65,11 +65,7 @@ void DeckViewCardDragItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) DeckViewCard::DeckViewCard(const QString &_name, const QString &_originZone, QGraphicsItem *parent) : AbstractCardItem(_name, 0, -1, parent), originZone(_originZone), dragItem(0) { -#if QT_VERSION < 0x050000 - setAcceptsHoverEvents(true); -#else setAcceptHoverEvents(true); -#endif } DeckViewCard::~DeckViewCard() diff --git a/cockatrice/src/dlg_create_token.cpp b/cockatrice/src/dlg_create_token.cpp index 02c867bb..311df360 100644 --- a/cockatrice/src/dlg_create_token.cpp +++ b/cockatrice/src/dlg_create_token.cpp @@ -83,11 +83,8 @@ DlgCreateToken::DlgCreateToken(const QStringList &_predefinedTokens, QWidget *pa chooseTokenView->setWordWrap(true); chooseTokenView->setColumnWidth(0, 130); chooseTokenView->setColumnWidth(3, 178); -#if QT_VERSION < 0x050000 - chooseTokenView->header()->setResizeMode(4, QHeaderView::ResizeToContents); -#else chooseTokenView->header()->setSectionResizeMode(4, QHeaderView::ResizeToContents); -#endif + connect(chooseTokenView->selectionModel(), SIGNAL(currentRowChanged(QModelIndex, QModelIndex)), this, SLOT(tokenSelectionChanged(QModelIndex, QModelIndex))); if (predefinedTokens.isEmpty()) diff --git a/cockatrice/src/dlg_edit_tokens.cpp b/cockatrice/src/dlg_edit_tokens.cpp index 89cf3e01..7293bc3a 100644 --- a/cockatrice/src/dlg_edit_tokens.cpp +++ b/cockatrice/src/dlg_edit_tokens.cpp @@ -77,13 +77,9 @@ DlgEditTokens::DlgEditTokens(QWidget *parent) chooseTokenView->header()->setStretchLastSection(false); chooseTokenView->header()->hideSection(1); chooseTokenView->header()->hideSection(2); -#if QT_VERSION < 0x050000 - chooseTokenView->header()->setResizeMode(3, QHeaderView::ResizeToContents); - chooseTokenView->header()->setResizeMode(4, QHeaderView::ResizeToContents); -#else chooseTokenView->header()->setSectionResizeMode(3, QHeaderView::ResizeToContents); chooseTokenView->header()->setSectionResizeMode(4, QHeaderView::ResizeToContents); -#endif + connect(chooseTokenView->selectionModel(), SIGNAL(currentRowChanged(QModelIndex, QModelIndex)), this, SLOT(tokenSelectionChanged(QModelIndex, QModelIndex))); QAction *aAddToken = new QAction(tr("Add token"), this); diff --git a/cockatrice/src/dlg_settings.cpp b/cockatrice/src/dlg_settings.cpp index fe1676d9..e7d46679 100644 --- a/cockatrice/src/dlg_settings.cpp +++ b/cockatrice/src/dlg_settings.cpp @@ -697,11 +697,6 @@ SoundSettingsPage::SoundSettingsPage() connect(masterVolumeSlider, SIGNAL(valueChanged(int)), masterVolumeSpinBox, SLOT(setValue(int))); connect(masterVolumeSpinBox, SIGNAL(valueChanged(int)), masterVolumeSlider, SLOT(setValue(int))); -#if QT_VERSION < 0x050000 - masterVolumeSlider->setEnabled(false); - masterVolumeSpinBox->setEnabled(false); -#endif - QGridLayout *soundGrid = new QGridLayout; soundGrid->addWidget(&soundEnabledCheckBox, 0, 0, 1, 3); soundGrid->addWidget(&masterVolumeLabel, 1, 0); @@ -736,12 +731,7 @@ void SoundSettingsPage::retranslateUi() { themeLabel.setText(tr("Current sounds theme:")); soundTestButton.setText(tr("Test system sound engine")); soundGroupBox->setTitle(tr("Sound settings")); - #if QT_VERSION < 0x050000 - masterVolumeLabel.setText(tr("Master volume requires QT5")); -#else - masterVolumeLabel.setText(tr("Master volume")); -#endif - + masterVolumeLabel.setText(tr("Master volume")); } DlgSettings::DlgSettings(QWidget *parent) diff --git a/cockatrice/src/gameselector.cpp b/cockatrice/src/gameselector.cpp index b471317e..802812b5 100644 --- a/cockatrice/src/gameselector.cpp +++ b/cockatrice/src/gameselector.cpp @@ -54,11 +54,8 @@ GameSelector::GameSelector(AbstractClient *_client, const TabSupervisor *_tabSup if (showfilters && restoresettings) gameListProxyModel->loadFilterParameters(gameTypeMap); -#if QT_VERSION < 0x050000 - gameListView->header()->setResizeMode(0, QHeaderView::ResizeToContents); -#else gameListView->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents); -#endif + filterButton = new QPushButton; filterButton->setIcon(QPixmap("theme:icons/search")); connect(filterButton, SIGNAL(clicked()), this, SLOT(actSetFilter())); diff --git a/cockatrice/src/handcounter.cpp b/cockatrice/src/handcounter.cpp index c2e4ad6f..8b58b6a1 100644 --- a/cockatrice/src/handcounter.cpp +++ b/cockatrice/src/handcounter.cpp @@ -30,11 +30,7 @@ void HandCounter::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*op painter->save(); QSize translatedSize = painter->combinedTransform().mapRect(boundingRect()).size().toSize(); QPixmap cachedPixmap; -#if QT_VERSION >= 0x040600 if (!QPixmapCache::find("handCounter" + QString::number(translatedSize.width()), &cachedPixmap)) { -#else - if (!QPixmapCache::find("handCounter" + QString::number(translatedSize.width()), cachedPixmap)) { -#endif cachedPixmap = QPixmap("theme:hand").scaled(translatedSize, Qt::KeepAspectRatio, Qt::SmoothTransformation); QPixmapCache::insert("handCounter" + QString::number(translatedSize.width()), cachedPixmap); } diff --git a/cockatrice/src/main.cpp b/cockatrice/src/main.cpp index 03a9d37e..793a008a 100644 --- a/cockatrice/src/main.cpp +++ b/cockatrice/src/main.cpp @@ -55,16 +55,6 @@ ThemeManager *themeManager; const QString translationPrefix = "cockatrice"; QString translationPath; -#if QT_VERSION < 0x050000 -static void myMessageOutput(QtMsgType /*type*/, const char *msg) -{ - QFile file("qdebug.txt"); - file.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text); - QTextStream out(&file); - out << msg << endl; - file.close(); -} -#else static void myMessageOutput(QtMsgType /*type*/, const QMessageLogContext &, const QString &msg) { QFile file("qdebug.txt"); @@ -73,7 +63,6 @@ static void myMessageOutput(QtMsgType /*type*/, const QMessageLogContext &, cons out << msg << endl; file.close(); } -#endif void installNewTranslator() { @@ -103,22 +92,12 @@ int main(int argc, char *argv[]) QApplication app(argc, argv); if (app.arguments().contains("--debug-output")) - { -#if QT_VERSION < 0x050000 - qInstallMsgHandler(myMessageOutput); -#else qInstallMessageHandler(myMessageOutput); -#endif - } + #ifdef Q_OS_WIN app.addLibraryPath(app.applicationDirPath() + "/plugins"); #endif -#if QT_VERSION < 0x050000 - // gone in Qt5, all source files _MUST_ be utf8-encoded - QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); -#endif - QCoreApplication::setOrganizationName("Cockatrice"); QCoreApplication::setOrganizationDomain("cockatrice.de"); QCoreApplication::setApplicationName("Cockatrice"); @@ -158,9 +137,8 @@ int main(int argc, char *argv[]) ui.show(); qDebug("main(): ui.show() finished"); -#if QT_VERSION > 0x050000 + app.setAttribute(Qt::AA_UseHighDpiPixmaps); -#endif app.exec(); qDebug("Event loop finished, terminating..."); diff --git a/cockatrice/src/pilezone.cpp b/cockatrice/src/pilezone.cpp index ed9daa88..a2ff1d14 100644 --- a/cockatrice/src/pilezone.cpp +++ b/cockatrice/src/pilezone.cpp @@ -13,11 +13,7 @@ PileZone::PileZone(Player *_p, const QString &_name, bool _isShufflable, bool _c : CardZone(_p, _name, false, _isShufflable, _contentsKnown, parent) { setCacheMode(DeviceCoordinateCache); // Do not move this line to the parent constructor! -#if QT_VERSION < 0x050000 - setAcceptsHoverEvents(true); -#else setAcceptHoverEvents(true); -#endif setCursor(Qt::OpenHandCursor); setTransform(QTransform().translate((float) CARD_WIDTH / 2, (float) CARD_HEIGHT / 2).rotate(90).translate((float) -CARD_WIDTH / 2, (float) -CARD_HEIGHT / 2)); diff --git a/cockatrice/src/player.cpp b/cockatrice/src/player.cpp index 336cc542..790ec116 100644 --- a/cockatrice/src/player.cpp +++ b/cockatrice/src/player.cpp @@ -516,13 +516,7 @@ void Player::playerListActionTriggered() } else if (menu == mRevealTopCard) { int decksize = zones.value("deck")->getCards().size(); bool ok; - int number = -#if QT_VERSION < 0x050000 - QInputDialog::getInteger( -#else - QInputDialog::getInt( -#endif - 0, tr("Reveal top cards of library"), tr("Number of cards: (max. %1)").arg(decksize), defaultNumberTopCards, 1, decksize, 1, &ok); + int number = QInputDialog::getInt(0, tr("Reveal top cards of library"), tr("Number of cards: (max. %1)").arg(decksize), defaultNumberTopCards, 1, decksize, 1, &ok); if (ok) { cmd.set_zone_name("deck"); cmd.set_top_cards(number); @@ -867,13 +861,7 @@ void Player::actViewLibrary() void Player::actViewTopCards() { bool ok; - int number = -#if QT_VERSION < 0x050000 - QInputDialog::getInteger( -#else - QInputDialog::getInt( -#endif - 0, tr("View top cards of library"), tr("Number of cards:"), defaultNumberTopCards, 1, 2000000000, 1, &ok); + int number = QInputDialog::getInt(0, tr("View top cards of library"), tr("Number of cards:"), defaultNumberTopCards, 1, 2000000000, 1, &ok); if (ok) { defaultNumberTopCards = number; static_cast(scene())->toggleZoneView(this, "deck", number); @@ -928,14 +916,8 @@ void Player::actMulligan() void Player::actDrawCards() { - int number = -#if QT_VERSION < 0x050000 - QInputDialog::getInteger( -#else - QInputDialog::getInt( -#endif - 0, tr("Draw cards"), tr("Number:")); - if (number) { + int number = QInputDialog::getInt(0, tr("Draw cards"), tr("Number:")); + if (number) { Command_DrawCards cmd; cmd.set_number(number); sendGameCommand(cmd); @@ -949,13 +931,7 @@ void Player::actUndoDraw() void Player::actMoveTopCardsToGrave() { - int number = -#if QT_VERSION < 0x050000 - QInputDialog::getInteger( -#else - QInputDialog::getInt( -#endif - 0, tr("Move top cards to grave"), tr("Number:")); + int number = QInputDialog::getInt(0, tr("Move top cards to grave"), tr("Number:")); if (!number) return; @@ -978,13 +954,7 @@ void Player::actMoveTopCardsToGrave() void Player::actMoveTopCardsToExile() { - int number = -#if QT_VERSION < 0x050000 - QInputDialog::getInteger( -#else - QInputDialog::getInt( -#endif - 0, tr("Move top cards to exile"), tr("Number:")); + int number = QInputDialog::getInt(0, tr("Move top cards to exile"), tr("Number:")); if (!number) return; @@ -1059,13 +1029,7 @@ void Player::actUntapAll() void Player::actRollDie() { bool ok; - int sides = -#if QT_VERSION < 0x050000 - QInputDialog::getInteger( -#else - QInputDialog::getInt( -#endif - static_cast(parent()), tr("Roll die"), tr("Number of sides:"), 20, 2, 1000, 1, &ok); + int sides = QInputDialog::getInt(static_cast(parent()), tr("Roll die"), tr("Number of sides:"), 20, 2, 1000, 1, &ok); if (ok) { Command_RollDie cmd; cmd.set_sides(sides); @@ -2269,13 +2233,7 @@ void Player::actCardCounterTrigger() case 11: { bool ok; dialogSemaphore = true; - int number = -#if QT_VERSION < 0x050000 - QInputDialog::getInteger( -#else - QInputDialog::getInt( -#endif - 0, tr("Set counters"), tr("Number:"), 0, 0, MAX_COUNTERS_ON_CARD, 1, &ok); + int number = QInputDialog::getInt(0, tr("Set counters"), tr("Number:"), 0, 0, MAX_COUNTERS_ON_CARD, 1, &ok); dialogSemaphore = false; if (clearCardsToDelete()) return; diff --git a/cockatrice/src/playertarget.cpp b/cockatrice/src/playertarget.cpp index 775c4bdd..22da4087 100644 --- a/cockatrice/src/playertarget.cpp +++ b/cockatrice/src/playertarget.cpp @@ -81,11 +81,7 @@ void PlayerTarget::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*o QSize translatedSize = translatedRect.size().toSize(); QPixmap cachedPixmap; const QString cacheKey = "avatar" + QString::number(translatedSize.width()) + "_" + QString::number(info->user_level()) + "_" + QString::number(fullPixmap.cacheKey()); -#if QT_VERSION >= 0x040600 if (!QPixmapCache::find(cacheKey, &cachedPixmap)) { -#else - if (!QPixmapCache::find(cacheKey, cachedPixmap)) { -#endif cachedPixmap = QPixmap(translatedSize.width(), translatedSize.height()); QPainter tempPainter(&cachedPixmap); diff --git a/cockatrice/src/priceupdater.cpp b/cockatrice/src/priceupdater.cpp index 307cd26f..649becc6 100644 --- a/cockatrice/src/priceupdater.cpp +++ b/cockatrice/src/priceupdater.cpp @@ -12,11 +12,6 @@ #include "main.h" #include "carddatabase.h" -#if QT_VERSION < 0x050000 - // for Qt::escape() - #include -#endif - /** * Constructor. * @@ -137,12 +132,7 @@ void DBPriceUpdater::downloadFinished() if(resultMap.contains("errors")) { QMessageBox::critical(this, tr("Error"), tr("A problem has occured while fetching card prices:") + - "
" + -#if QT_VERSION < 0x050000 - Qt::escape(resultMap["errors"].toList().first().toString()) -#else - resultMap["errors"].toList().first().toString().toHtmlEscaped() -#endif + "
" + resultMap["errors"].toList().first().toString().toHtmlEscaped() ); reply->deleteLater(); if(urls.isEmpty()) diff --git a/cockatrice/src/remotedecklist_treewidget.cpp b/cockatrice/src/remotedecklist_treewidget.cpp index cb96ef7f..d2f048f5 100644 --- a/cockatrice/src/remotedecklist_treewidget.cpp +++ b/cockatrice/src/remotedecklist_treewidget.cpp @@ -283,11 +283,7 @@ RemoteDeckList_TreeWidget::RemoteDeckList_TreeWidget(AbstractClient *_client, QW setModel(proxyModel); connect(treeModel, SIGNAL(treeRefreshed()), this, SLOT(expandAll())); -#if QT_VERSION < 0x050000 - header()->setResizeMode(QHeaderView::ResizeToContents); -#else header()->setSectionResizeMode(QHeaderView::ResizeToContents); -#endif setUniformRowHeights(true); setSortingEnabled(true); proxyModel->sort(0, Qt::AscendingOrder); diff --git a/cockatrice/src/remotereplaylist_treewidget.cpp b/cockatrice/src/remotereplaylist_treewidget.cpp index 680529dc..44807efc 100644 --- a/cockatrice/src/remotereplaylist_treewidget.cpp +++ b/cockatrice/src/remotereplaylist_treewidget.cpp @@ -278,11 +278,7 @@ RemoteReplayList_TreeWidget::RemoteReplayList_TreeWidget(AbstractClient *_client proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive); setModel(proxyModel); -#if QT_VERSION < 0x050000 - header()->setResizeMode(QHeaderView::ResizeToContents); -#else header()->setSectionResizeMode(QHeaderView::ResizeToContents); -#endif header()->setStretchLastSection(false); setUniformRowHeights(true); setSortingEnabled(true); diff --git a/cockatrice/src/settingscache.cpp b/cockatrice/src/settingscache.cpp index 7c43134c..2d7022c2 100644 --- a/cockatrice/src/settingscache.cpp +++ b/cockatrice/src/settingscache.cpp @@ -4,22 +4,15 @@ #include #include #include - -#if QT_VERSION >= 0x050000 - #include -#else - #include -#endif +#include QString SettingsCache::getDataPath() { return #ifdef PORTABLE_BUILD qApp->applicationDirPath() + "/data/"; -#elif QT_VERSION >= 0x050000 - QStandardPaths::writableLocation(QStandardPaths::DataLocation); #else - QDesktopServices::storageLocation(QDesktopServices::DataLocation); + QStandardPaths::writableLocation(QStandardPaths::DataLocation); #endif } diff --git a/cockatrice/src/soundengine.cpp b/cockatrice/src/soundengine.cpp index 1cdf1454..a1569238 100644 --- a/cockatrice/src/soundengine.cpp +++ b/cockatrice/src/soundengine.cpp @@ -7,11 +7,7 @@ #include #include #include -#if QT_VERSION < 0x050000 - #include -#else - #include -#endif +#include #define DEFAULT_THEME_NAME "Default" #define TEST_SOUND_FILENAME "player_join" @@ -47,13 +43,8 @@ void SoundEngine::soundEnabledChanged() if(!player) { QAudioFormat format; -#if QT_VERSION < 0x050000 - format.setFrequency(44100); - format.setChannels(1); - #else format.setSampleRate(44100); format.setChannelCount(1); - #endif format.setSampleSize(16); format.setCodec("audio/pcm"); format.setByteOrder(QAudioFormat::LittleEndian); @@ -88,9 +79,8 @@ void SoundEngine::playSound(QString fileName) inputBuffer->close(); inputBuffer->setData(audioData[fileName]); inputBuffer->open(QIODevice::ReadOnly); -#if QT_VERSION >= 0x050000 + player->setVolume(settingsCache->getMasterVolume() / 100.0); -#endif player->stop(); player->start(inputBuffer); } @@ -119,8 +109,6 @@ QStringMap & SoundEngine::getAvailableThemes() dir = #ifdef PORTABLE_BUILD qApp->applicationDirPath() + -#elif QT_VERSION < 0x050000 - QDesktopServices::storageLocation(QDesktopServices::DataLocation) + #else QStandardPaths::standardLocations(QStandardPaths::DataLocation).first() + #endif diff --git a/cockatrice/src/tab_deck_editor.cpp b/cockatrice/src/tab_deck_editor.cpp index dfba8c03..d06fb531 100644 --- a/cockatrice/src/tab_deck_editor.cpp +++ b/cockatrice/src/tab_deck_editor.cpp @@ -60,11 +60,7 @@ void TabDeckEditor::createDeckDock() deckView->setUniformRowHeights(true); deckView->setSortingEnabled(true); deckView->sortByColumn(1, Qt::AscendingOrder); -#if QT_VERSION < 0x050000 - deckView->header()->setResizeMode(QHeaderView::ResizeToContents); -#else deckView->header()->setSectionResizeMode(QHeaderView::ResizeToContents); -#endif deckView->installEventFilter(&deckViewKeySignals); connect(deckView->selectionModel(), SIGNAL(currentRowChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(updateCardInfoRight(const QModelIndex &, const QModelIndex &))); connect(deckView, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(actSwapCard())); diff --git a/cockatrice/src/tab_deck_storage.cpp b/cockatrice/src/tab_deck_storage.cpp index 90986b12..be0f39bd 100644 --- a/cockatrice/src/tab_deck_storage.cpp +++ b/cockatrice/src/tab_deck_storage.cpp @@ -38,11 +38,7 @@ TabDeckStorage::TabDeckStorage(TabSupervisor *_tabSupervisor, AbstractClient *_c localDirView->setColumnHidden(1, true); localDirView->setRootIndex(localDirModel->index(localDirModel->rootPath(), 0)); localDirView->setSortingEnabled(true); -#if QT_VERSION < 0x050000 - localDirView->header()->setResizeMode(QHeaderView::ResizeToContents); -#else localDirView->header()->setSectionResizeMode(QHeaderView::ResizeToContents); -#endif localDirView->header()->setSortIndicator(0, Qt::AscendingOrder); leftToolBar = new QToolBar; diff --git a/cockatrice/src/tab_game.cpp b/cockatrice/src/tab_game.cpp index 075f9880..7a47e4c2 100644 --- a/cockatrice/src/tab_game.cpp +++ b/cockatrice/src/tab_game.cpp @@ -1581,10 +1581,7 @@ void TabGame::createMessageDock(bool bReplay) completer = new QCompleter(autocompleteUserList, sayEdit); completer->setCaseSensitivity(Qt::CaseInsensitive); completer->setMaxVisibleItems(5); - - #if QT_VERSION >= 0x050000 completer->setFilterMode(Qt::MatchStartsWith); - #endif sayEdit->setCompleter(completer); actCompleterChanged(); diff --git a/cockatrice/src/tab_logs.cpp b/cockatrice/src/tab_logs.cpp index f1b6563a..8add93a8 100644 --- a/cockatrice/src/tab_logs.cpp +++ b/cockatrice/src/tab_logs.cpp @@ -17,9 +17,7 @@ #include "pb/response_viewlog_history.pb.h" #include -#if QT_VERSION >= 0x050000 #include -#endif TabLog::TabLog(TabSupervisor *_tabSupervisor, AbstractClient *_client, QWidget *parent) : Tab(_tabSupervisor, parent), client(_client) diff --git a/cockatrice/src/tab_replays.cpp b/cockatrice/src/tab_replays.cpp index 0860a5ea..a0fa6764 100644 --- a/cockatrice/src/tab_replays.cpp +++ b/cockatrice/src/tab_replays.cpp @@ -36,11 +36,7 @@ TabReplays::TabReplays(TabSupervisor *_tabSupervisor, AbstractClient *_client) localDirView->setColumnHidden(1, true); localDirView->setRootIndex(localDirModel->index(localDirModel->rootPath(), 0)); localDirView->setSortingEnabled(true); -#if QT_VERSION < 0x050000 - localDirView->header()->setResizeMode(QHeaderView::ResizeToContents); -#else localDirView->header()->setSectionResizeMode(QHeaderView::ResizeToContents); -#endif localDirView->header()->setSortIndicator(0, Qt::AscendingOrder); leftToolBar = new QToolBar; diff --git a/cockatrice/src/tab_room.cpp b/cockatrice/src/tab_room.cpp index b455befd..95356a57 100644 --- a/cockatrice/src/tab_room.cpp +++ b/cockatrice/src/tab_room.cpp @@ -118,10 +118,7 @@ TabRoom::TabRoom(TabSupervisor *_tabSupervisor, AbstractClient *_client, ServerI completer = new QCompleter(autocompleteUserList, sayEdit); completer->setCaseSensitivity(Qt::CaseInsensitive); completer->setMaxVisibleItems(5); - - #if QT_VERSION >= 0x050000 - completer->setFilterMode(Qt::MatchStartsWith); - #endif + completer->setFilterMode(Qt::MatchStartsWith); sayEdit->setCompleter(completer); actCompleterChanged(); diff --git a/cockatrice/src/tab_server.cpp b/cockatrice/src/tab_server.cpp index 0abd12c5..c203d363 100644 --- a/cockatrice/src/tab_server.cpp +++ b/cockatrice/src/tab_server.cpp @@ -28,17 +28,11 @@ RoomSelector::RoomSelector(AbstractClient *_client, QWidget *parent) roomList->setRootIsDecorated(false); roomList->setColumnCount(5); roomList->header()->setStretchLastSection(false); -#if QT_VERSION < 0x050000 - roomList->header()->setResizeMode(0, QHeaderView::ResizeToContents); - roomList->header()->setResizeMode(1, QHeaderView::Stretch); - roomList->header()->setResizeMode(2, QHeaderView::ResizeToContents); - roomList->header()->setResizeMode(3, QHeaderView::ResizeToContents); -#else roomList->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents); roomList->header()->setSectionResizeMode(1, QHeaderView::Stretch); roomList->header()->setSectionResizeMode(2, QHeaderView::ResizeToContents); roomList->header()->setSectionResizeMode(3, QHeaderView::ResizeToContents); -#endif + joinButton = new QPushButton; connect(joinButton, SIGNAL(clicked()), this, SLOT(joinClicked())); QHBoxLayout *buttonLayout = new QHBoxLayout; diff --git a/cockatrice/src/tablezone.cpp b/cockatrice/src/tablezone.cpp index a38a5eb4..532f492d 100644 --- a/cockatrice/src/tablezone.cpp +++ b/cockatrice/src/tablezone.cpp @@ -35,11 +35,7 @@ TableZone::TableZone(Player *_p, QGraphicsItem *parent) currentMinimumWidth = width; setCacheMode(DeviceCoordinateCache); -#if QT_VERSION < 0x050000 - setAcceptsHoverEvents(true); -#else setAcceptHoverEvents(true); -#endif } diff --git a/cockatrice/src/thememanager.cpp b/cockatrice/src/thememanager.cpp index 390d859a..4f99674d 100644 --- a/cockatrice/src/thememanager.cpp +++ b/cockatrice/src/thememanager.cpp @@ -5,11 +5,7 @@ #include #include #include -#if QT_VERSION < 0x050000 - #include -#else - #include -#endif +#include #define DEFAULT_THEME_NAME "Default" #define STYLE_CSS_NAME "style.css" @@ -45,8 +41,6 @@ QStringMap & ThemeManager::getAvailableThemes() dir = #ifdef PORTABLE_BUILD qApp->applicationDirPath() + -#elif QT_VERSION < 0x050000 - QDesktopServices::storageLocation(QDesktopServices::DataLocation) + #else QStandardPaths::standardLocations(QStandardPaths::DataLocation).first() + #endif diff --git a/cockatrice/src/user_context_menu.cpp b/cockatrice/src/user_context_menu.cpp index 95761929..c7c9957e 100644 --- a/cockatrice/src/user_context_menu.cpp +++ b/cockatrice/src/user_context_menu.cpp @@ -12,10 +12,8 @@ #include "pending_command.h" #include -#if QT_VERSION >= 0x050000 #include #include -#endif #include "pb/commands.pb.h" #include "pb/session_commands.pb.h" diff --git a/cockatrice/src/userlist.cpp b/cockatrice/src/userlist.cpp index 25868505..e7821ca7 100644 --- a/cockatrice/src/userlist.cpp +++ b/cockatrice/src/userlist.cpp @@ -311,11 +311,7 @@ UserList::UserList(TabSupervisor *_tabSupervisor, AbstractClient *_client, UserL userTree = new QTreeWidget; userTree->setColumnCount(3); -#if QT_VERSION < 0x050000 - userTree->header()->setResizeMode(QHeaderView::ResizeToContents); -#else userTree->header()->setSectionResizeMode(QHeaderView::ResizeToContents); -#endif userTree->setHeaderHidden(true); userTree->setRootIsDecorated(false); userTree->setIconSize(QSize(20, 12)); diff --git a/cockatrice/src/window_main.cpp b/cockatrice/src/window_main.cpp index a6a752b4..6b1ceb5b 100644 --- a/cockatrice/src/window_main.cpp +++ b/cockatrice/src/window_main.cpp @@ -31,12 +31,7 @@ #include #include #include - -#if QT_VERSION < 0x050000 - #include // for Qt::escape() -#else - #include -#endif +#include #include "main.h" #include "window_main.h" @@ -397,15 +392,7 @@ QString MainWindow::extractInvalidUsernameMessage(QString & in) out += "
  • " + tr("can %1 contain numeric characters").arg((rules.at(4).toInt() > 0) ? "" : tr("NOT")) + "
  • "; if (rules.at(6).size() > 0) - { - out += "
  • " + tr("can contain the following punctuation: %1").arg( - #if QT_VERSION < 0x050000 - Qt::escape(rules.at(6)) - #else - rules.at(6).toHtmlEscaped() - #endif - ) + "
  • "; - } + out += "
  • " + tr("can contain the following punctuation: %1").arg(rules.at(6).toHtmlEscaped()) + "
  • "; out += "
  • " + tr("first character can %1 be a punctuation mark").arg((rules.at(5).toInt() > 0) ? "" : tr("NOT")) + "
  • "; out += ""; diff --git a/cockatrice/src/window_sets.cpp b/cockatrice/src/window_sets.cpp index 5e0a49e2..e62ae30b 100644 --- a/cockatrice/src/window_sets.cpp +++ b/cockatrice/src/window_sets.cpp @@ -70,13 +70,8 @@ WndSets::WndSets(QWidget *parent) view->setDropIndicatorShown(true); view->setDragDropMode(QAbstractItemView::InternalMove); -#if QT_VERSION < 0x050000 - view->header()->setResizeMode(QHeaderView::Stretch); - view->header()->setResizeMode(SetsModel::LongNameCol, QHeaderView::ResizeToContents); -#else view->header()->setSectionResizeMode(QHeaderView::Stretch); view->header()->setSectionResizeMode(SetsModel::LongNameCol, QHeaderView::ResizeToContents); -#endif view->sortByColumn(SetsModel::SortKeyCol, Qt::AscendingOrder); view->setColumnHidden(SetsModel::SortKeyCol, true); diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 0aabfbd5..10797924 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -30,21 +30,10 @@ SET(common_SOURCES set(ORACLE_LIBS) -# Qt4 stuff -if(Qt4_FOUND) - # Include directories - INCLUDE(${QT_USE_FILE}) - include_directories(${QT_INCLUDES}) -endif() - -# qt5 stuff -if(Qt5Widgets_FOUND) - include_directories(${Qt5Widgets_INCLUDE_DIRS}) -endif() - INCLUDE_DIRECTORIES(pb) INCLUDE_DIRECTORIES(sfmt) INCLUDE_DIRECTORIES(${PROTOBUF_INCLUDE_DIR}) +include_directories(${Qt5Widgets_INCLUDE_DIRS}) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) add_library(cockatrice_common ${common_SOURCES} ${common_MOC_SRCS}) diff --git a/oracle/CMakeLists.txt b/oracle/CMakeLists.txt index 1011fa83..70fc2ec5 100644 --- a/oracle/CMakeLists.txt +++ b/oracle/CMakeLists.txt @@ -47,28 +47,6 @@ ENDIF(APPLE) set(ORACLE_LIBS) -# Qt4 stuff -if(Qt4_FOUND) - SET(QT_USE_QTNETWORK TRUE) - SET(QT_USE_QTSVG TRUE) - - # Include directories - INCLUDE(${QT_USE_FILE}) - include_directories(${QT_INCLUDES}) - LIST(APPEND ORACLE_LIBS ${QT_QTMAIN_LIBRARY}) - LIST(APPEND ORACLE_LIBS ${QT_LIBRARIES}) - - # Let cmake chew Qt4's translations and resource files - # Note: header files are MOC-ed automatically by cmake - IF(UPDATE_TRANSLATIONS) - QT4_CREATE_TRANSLATION(oracle_QM ${translate_SRCS} ${oracle_TS}) - ELSE(UPDATE_TRANSLATIONS) - QT4_ADD_TRANSLATION(oracle_QM ${oracle_TS}) - ENDIF(UPDATE_TRANSLATIONS) - - QT4_ADD_RESOURCES(oracle_RESOURCES_RCC ${oracle_RESOURCES}) -endif() - # qt5 stuff if(Qt5Widgets_FOUND) include_directories(${Qt5Widgets_INCLUDE_DIRS}) @@ -131,18 +109,10 @@ ENDIF() # Build oracle binary and link it ADD_EXECUTABLE(oracle WIN32 MACOSX_BUNDLE ${oracle_SOURCES} ${oracle_QM} ${oracle_RESOURCES_RCC} ${oracle_MOC_SRCS}) -if(Qt4_FOUND) - if(MSVC) - set(QT_USE_QTMAIN true) - endif() - TARGET_LINK_LIBRARIES(oracle ${ORACLE_LIBS}) -endif() -if(Qt5Widgets_FOUND) - if(MSVC) - TARGET_LINK_LIBRARIES(oracle Qt5::WinMain) - endif() - qt5_use_modules(oracle ${ORACLE_LIBS}) +if(MSVC) + TARGET_LINK_LIBRARIES(oracle Qt5::WinMain) endif() +qt5_use_modules(oracle ${ORACLE_LIBS}) IF(ZLIB_FOUND) TARGET_LINK_LIBRARIES(oracle ${ZLIB_LIBRARIES}) @@ -182,11 +152,9 @@ if(APPLE) set(qtconf_dest_dir oracle.app/Contents/Resources) get_filename_component(QT_LIBRARY_DIR "${QT_LIBRARY_DIR}/.." ABSOLUTE) - # qt4: codecs, iconengines, imageformats - # qt5: iconengines, platforms - + # qt5 plugins: iconengines, platforms install(DIRECTORY "${QT_PLUGINS_DIR}/" DESTINATION ${plugin_dest_dir} COMPONENT Runtime - FILES_MATCHING REGEX "(codecs|iconengines|platforms)/.*\\.dylib" + FILES_MATCHING REGEX "(iconengines|platforms)/.*\\.dylib" REGEX ".*_debug\\.dylib" EXCLUDE) install(CODE " @@ -218,11 +186,10 @@ IF(WIN32) list(APPEND libSearchDirs ${ZLIB_DLL_DIR}) ENDIF() - # qt4: codecs, iconengines, imageformats - # qt5: iconengines, imageformats, platforms + # qt5 plugins: iconengines, platforms install(DIRECTORY "${QT_PLUGINS_DIR}/" DESTINATION ${plugin_dest_dir} COMPONENT Runtime - FILES_MATCHING REGEX "(codecs|iconengines|platforms)/.*[^d]\\.dll") + FILES_MATCHING REGEX "(iconengines|platforms)/.*[^d]\\.dll") install(CODE " file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${qtconf_dest_dir}/qt.conf\" \"[Paths] diff --git a/oracle/src/main.cpp b/oracle/src/main.cpp index 5a6e0367..8d272328 100644 --- a/oracle/src/main.cpp +++ b/oracle/src/main.cpp @@ -30,11 +30,6 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); -#if QT_VERSION < 0x050000 - // gone in Qt5, all source files _MUST_ be utf8-encoded - QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); -#endif - QCoreApplication::setOrganizationName("Cockatrice"); QCoreApplication::setOrganizationDomain("cockatrice"); // this can't be changed, as it influences the default savepath for cards.xml diff --git a/oracle/src/oracleimporter.cpp b/oracle/src/oracleimporter.cpp index e39bcc06..92f22c16 100644 --- a/oracle/src/oracleimporter.cpp +++ b/oracle/src/oracleimporter.cpp @@ -1,9 +1,6 @@ #include "oracleimporter.h" -#if QT_VERSION < 0x050000 - #include -#else - #include -#endif + +#include #include #include "qt-json/json.h" diff --git a/oracle/src/oraclewizard.cpp b/oracle/src/oraclewizard.cpp index 394c2835..47805850 100644 --- a/oracle/src/oraclewizard.cpp +++ b/oracle/src/oraclewizard.cpp @@ -1,10 +1,6 @@ #include -#if QT_VERSION < 0x050000 - #include -#else - #include - #include -#endif +#include +#include #include #include #include diff --git a/servatrice/CMakeLists.txt b/servatrice/CMakeLists.txt index 7c2bcb0e..0f717390 100644 --- a/servatrice/CMakeLists.txt +++ b/servatrice/CMakeLists.txt @@ -38,22 +38,6 @@ ENDIF(APPLE) set(SERVATRICE_LIBS) -# Qt4 stuff -if(Qt4_FOUND) - SET(QT_USE_QTNETWORK TRUE) - SET(QT_USE_QTSQL TRUE) - - # Include directories - INCLUDE(${QT_USE_FILE}) - include_directories(${QT_INCLUDES}) - LIST(APPEND SERVATRICE_LIBS ${QT_LIBRARIES}) - - # Libgcrypt is required only with Qt4 to support SHA512 hashing - FIND_PACKAGE(Libgcrypt REQUIRED) - INCLUDE_DIRECTORIES(${LIBGCRYPT_INCLUDE_DIR}) - QT4_ADD_RESOURCES(servatrice_RESOURCES_RCC ${servatrice_RESOURCES}) -endif() - # qt5 stuff if(Qt5Widgets_FOUND) include_directories(${Qt5Widgets_INCLUDE_DIRS}) @@ -118,20 +102,12 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) # Build servatrice binary and link it ADD_EXECUTABLE(servatrice MACOSX_BUNDLE ${servatrice_SOURCES} ${servatrice_RESOURCES_RCC} ${servatrice_MOC_SRCS}) -if(Qt4_FOUND) - if(MSVC) - set(QT_USE_QTMAIN true) - endif() - TARGET_LINK_LIBRARIES(servatrice cockatrice_common ${SERVATRICE_LIBS} ${LIBGCRYPT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT}) -endif() -if(Qt5Widgets_FOUND) - if(MSVC) - TARGET_LINK_LIBRARIES(servatrice cockatrice_common ${LIBGCRYPT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} Qt5::WinMain) - else() - TARGET_LINK_LIBRARIES(servatrice cockatrice_common ${LIBGCRYPT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT}) - endif() - qt5_use_modules(servatrice ${SERVATRICE_LIBS}) +if(MSVC) + TARGET_LINK_LIBRARIES(servatrice cockatrice_common ${CMAKE_THREAD_LIBS_INIT} Qt5::WinMain) +else() + TARGET_LINK_LIBRARIES(servatrice cockatrice_common ${CMAKE_THREAD_LIBS_INIT}) endif() +qt5_use_modules(servatrice ${SERVATRICE_LIBS}) # install rules if(UNIX) @@ -168,11 +144,9 @@ if(APPLE) set(qtconf_dest_dir servatrice.app/Contents/Resources) get_filename_component(QT_LIBRARY_DIR "${QT_LIBRARY_DIR}/.." ABSOLUTE) - # qt4: codecs, sqldrivers - # qt5: platforms, sqldrivers - + # qt5 plugins: platforms, sqldrivers/mysql install(DIRECTORY "${QT_PLUGINS_DIR}/" DESTINATION ${plugin_dest_dir} COMPONENT Runtime - FILES_MATCHING REGEX "(codecs/.*|platforms/.*|sqldrivers/libqsqlmysql)\\.dylib" + FILES_MATCHING REGEX "(platforms/.*|sqldrivers/libqsqlmysql)\\.dylib" REGEX ".*_debug\\.dylib" EXCLUDE) install(CODE " @@ -195,11 +169,9 @@ if(WIN32) set(plugin_dest_dir Plugins) set(qtconf_dest_dir .) - # qt4: codecs, sqldrivers - # qt5: platforms, sqldrivers - + # qt5 plugins: platforms, sqldrivers/mysql install(DIRECTORY "${QT_PLUGINS_DIR}/" DESTINATION ${plugin_dest_dir} COMPONENT Runtime - FILES_MATCHING REGEX "(codecs/.*|platforms/.*|sqldrivers/qsqlmysql)\\.dll" + FILES_MATCHING REGEX "(platforms/.*|sqldrivers/qsqlmysql)\\.dll" REGEX ".*d\\.dll" EXCLUDE) install(CODE " diff --git a/servatrice/src/main.cpp b/servatrice/src/main.cpp index d19ebb66..eb630f76 100644 --- a/servatrice/src/main.cpp +++ b/servatrice/src/main.cpp @@ -45,13 +45,8 @@ SmtpClient *smtpClient; void testRNG(); void testHash(); -#if QT_VERSION < 0x050000 -void myMessageOutput(QtMsgType type, const char *msg); -void myMessageOutput2(QtMsgType type, const char *msg); -#else void myMessageOutput(QtMsgType type, const QMessageLogContext &, const QString &msg); void myMessageOutput2(QtMsgType type, const QMessageLogContext &, const QString &msg); -#endif /* Implementations */ @@ -100,18 +95,6 @@ void testHash() std::cerr << startTime.secsTo(endTime) << "secs" << std::endl; } -#if QT_VERSION < 0x050000 -void myMessageOutput(QtMsgType /*type*/, const char *msg) -{ - logger->logMessage(msg); -} - -void myMessageOutput2(QtMsgType /*type*/, const char *msg) -{ - logger->logMessage(msg); - std::cerr << msg << std::endl; -} -#else void myMessageOutput(QtMsgType /*type*/, const QMessageLogContext &, const QString &msg) { logger->logMessage(msg); @@ -122,7 +105,6 @@ void myMessageOutput2(QtMsgType /*type*/, const QMessageLogContext &, const QStr logger->logMessage(msg); std::cerr << msg.toStdString() << std::endl; } -#endif int main(int argc, char *argv[]) { @@ -141,11 +123,6 @@ int main(int argc, char *argv[]) qRegisterMetaType >("QList"); -#if QT_VERSION < 0x050000 - // gone in Qt5, all source files _MUST_ be utf8-encoded - QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); -#endif - configPath = SettingsCache::guessConfigurationPath(configPath); qWarning() << "Using configuration file: " << configPath; settingsCache = new SettingsCache(configPath); @@ -158,17 +135,10 @@ int main(int argc, char *argv[]) loggerThread->start(); QMetaObject::invokeMethod(logger, "startLog", Qt::BlockingQueuedConnection, Q_ARG(QString, settingsCache->value("server/logfile", QString("server.log")).toString())); -#if QT_VERSION < 0x050000 - if (logToConsole) - qInstallMsgHandler(myMessageOutput); - else - qInstallMsgHandler(myMessageOutput2); -#else if (logToConsole) qInstallMessageHandler(myMessageOutput); else qInstallMessageHandler(myMessageOutput2); -#endif signalhandler = new SignalHandler(); @@ -193,11 +163,7 @@ int main(int argc, char *argv[]) std::cerr << "-------------------------" << std::endl; std::cerr << "Server initialized." << std::endl; -#if QT_VERSION < 0x050000 - qInstallMsgHandler(myMessageOutput); -#else qInstallMessageHandler(myMessageOutput); -#endif retval = app.exec(); diff --git a/servatrice/src/passwordhasher.cpp b/servatrice/src/passwordhasher.cpp index 41e73b9e..ff9536e5 100644 --- a/servatrice/src/passwordhasher.cpp +++ b/servatrice/src/passwordhasher.cpp @@ -1,44 +1,13 @@ #include "passwordhasher.h" -#if QT_VERSION < 0x050000 - #include - #include - #include -#endif - #include #include "rng_sfmt.h" void PasswordHasher::initialize() { -#if QT_VERSION < 0x050000 - // These calls are required by libgcrypt before we use any of its functions. - gcry_check_version(0); - gcry_control(GCRYCTL_DISABLE_SECMEM, 0); - gcry_control(GCRYCTL_INITIALIZATION_FINISHED, 0); -#endif + // dummy } -#if QT_VERSION < 0x050000 -QString PasswordHasher::computeHash(const QString &password, const QString &salt) -{ - const int algo = GCRY_MD_SHA512; - const int rounds = 1000; - - QByteArray passwordBuffer = (salt + password).toUtf8(); - int hashLen = gcry_md_get_algo_dlen(algo); - char *hash = new char[hashLen], *tmp = new char[hashLen]; - gcry_md_hash_buffer(algo, hash, passwordBuffer.data(), passwordBuffer.size()); - for (int i = 1; i < rounds; ++i) { - memcpy(tmp, hash, hashLen); - gcry_md_hash_buffer(algo, hash, tmp, hashLen); - } - QString hashedPass = salt + QString(QByteArray(hash, hashLen).toBase64()); - delete[] tmp; - delete[] hash; - return hashedPass; -} -#else QString PasswordHasher::computeHash(const QString &password, const QString &salt) { QCryptographicHash::Algorithm algo = QCryptographicHash::Sha512; @@ -51,7 +20,6 @@ QString PasswordHasher::computeHash(const QString &password, const QString &salt QString hashedPass = salt + QString(hash.toBase64()); return hashedPass; } -#endif QString PasswordHasher::generateRandomSalt(const int len) { diff --git a/servatrice/src/servatrice.cpp b/servatrice/src/servatrice.cpp index dfd3967f..5f693c89 100644 --- a/servatrice/src/servatrice.cpp +++ b/servatrice/src/servatrice.cpp @@ -81,11 +81,7 @@ Servatrice_GameServer::~Servatrice_GameServer() } } -#if QT_VERSION < 0x050000 -void Servatrice_GameServer::incomingConnection(int socketDescriptor) -#else void Servatrice_GameServer::incomingConnection(qintptr socketDescriptor) -#endif { // Determine connection pool with smallest client count int minClientCount = -1; @@ -110,11 +106,7 @@ void Servatrice_GameServer::incomingConnection(qintptr socketDescriptor) QMetaObject::invokeMethod(ssi, "initConnection", Qt::QueuedConnection, Q_ARG(int, socketDescriptor)); } -#if QT_VERSION < 0x050000 -void Servatrice_IslServer::incomingConnection(int socketDescriptor) -#else void Servatrice_IslServer::incomingConnection(qintptr socketDescriptor) -#endif { QThread *thread = new QThread; connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater())); @@ -317,16 +309,13 @@ bool Servatrice::initServer() if (!certFile.open(QIODevice::ReadOnly)) throw QString("Error opening certificate file: %1").arg(certFileName); QSslCertificate cert(&certFile); -#if QT_VERSION < 0x050000 - if (!cert.isValid()) - throw(QString("Invalid certificate.")); -#else + const QDateTime currentTime = QDateTime::currentDateTime(); if(currentTime < cert.effectiveDate() || currentTime > cert.expiryDate() || cert.isBlacklisted()) throw(QString("Invalid certificate.")); -#endif + qDebug() << "Loading private key..."; QFile keyFile(keyFileName); if (!keyFile.open(QIODevice::ReadOnly)) diff --git a/servatrice/src/servatrice.h b/servatrice/src/servatrice.h index e89cfdef..477cd459 100644 --- a/servatrice/src/servatrice.h +++ b/servatrice/src/servatrice.h @@ -53,11 +53,7 @@ public: Servatrice_GameServer(Servatrice *_server, int _numberPools, const QSqlDatabase &_sqlDatabase, QObject *parent = 0); ~Servatrice_GameServer(); protected: -#if QT_VERSION < 0x050000 - void incomingConnection(int socketDescriptor); -#else void incomingConnection(qintptr socketDescriptor); -#endif }; class Servatrice_IslServer : public QTcpServer { @@ -70,11 +66,7 @@ public: Servatrice_IslServer(Servatrice *_server, const QSslCertificate &_cert, const QSslKey &_privateKey, QObject *parent = 0) : QTcpServer(parent), server(_server), cert(_cert), privateKey(_privateKey) { } protected: -#if QT_VERSION < 0x050000 - void incomingConnection(int socketDescriptor); -#else void incomingConnection(qintptr socketDescriptor); -#endif }; class ServerProperties { diff --git a/servatrice/src/settingscache.cpp b/servatrice/src/settingscache.cpp index 1adad629..190be452 100644 --- a/servatrice/src/settingscache.cpp +++ b/servatrice/src/settingscache.cpp @@ -1,11 +1,7 @@ #include "settingscache.h" #include #include -#if QT_VERSION >= 0x050000 - #include -#else - #include -#endif +#include SettingsCache::SettingsCache(const QString & fileName, QSettings::Format format, QObject * parent) :QSettings(fileName, format, parent) @@ -36,10 +32,6 @@ QString SettingsCache::guessConfigurationPath(QString & specificPath) return guessFileName; #endif -#if QT_VERSION >= 0x050000 guessFileName = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/" + fileName; -#else - guessFileName = QDesktopServices::storageLocation(QDesktopServices::DataLocation) + "/" + fileName; -#endif return guessFileName; } diff --git a/servatrice/src/smtp/qxthmac.cpp b/servatrice/src/smtp/qxthmac.cpp index 12c6ae74..0cbca1c5 100644 --- a/servatrice/src/smtp/qxthmac.cpp +++ b/servatrice/src/smtp/qxthmac.cpp @@ -26,9 +26,6 @@ #include "qxthmac.h" #include -#if QT_VERSION >= 0x040300 - - /* \class QxtHmac @@ -207,5 +204,3 @@ bool QxtHmac::verify(const QByteArray& key, const QByteArray& hmac, const QByteA d->ohash->addData(inner); return hmac == d->ohash->result(); } - -#endif diff --git a/servatrice/src/smtp/qxthmac.h b/servatrice/src/smtp/qxthmac.h index 8e0d3d4a..e4d133b0 100644 --- a/servatrice/src/smtp/qxthmac.h +++ b/servatrice/src/smtp/qxthmac.h @@ -27,11 +27,6 @@ #define QXTHMAC_H #include - -#if QT_VERSION < 0x040300 -# warning QxtHmac requires Qt 4.3.0 or greater -#else - #include #include "qxtglobal.h" @@ -61,4 +56,3 @@ private: }; #endif -#endif diff --git a/tests/carddatabase/CMakeLists.txt b/tests/carddatabase/CMakeLists.txt index 4f0e1e57..e1b48b7b 100644 --- a/tests/carddatabase/CMakeLists.txt +++ b/tests/carddatabase/CMakeLists.txt @@ -10,35 +10,22 @@ endif() target_link_libraries(carddatabase_test ${GTEST_BOTH_LIBRARIES}) add_test(NAME carddatabase_test COMMAND carddatabase_test) -# Qt4 stuff -if(Qt4_FOUND) - SET(QT_USE_QTNETWORK TRUE) - SET(QT_USE_QTMULTIMEDIA TRUE) +# qt5 stuff +include_directories(${Qt5Widgets_INCLUDE_DIRS}) +list(APPEND COCKATRICE_LIBS Widgets) - # Include directories - INCLUDE(${QT_USE_FILE}) - INCLUDE_DIRECTORIES(${QT_INCLUDES}) - TARGET_LINK_LIBRARIES(carddatabase_test ${QT_LIBRARIES}) +# QtConcurrent +find_package(Qt5Concurrent) +if(Qt5Concurrent_FOUND) + include_directories(${Qt5Concurrent_INCLUDE_DIRS}) + list(APPEND ORACLE_LIBS Concurrent) endif() -# qt5 stuff -if(Qt5Widgets_FOUND) - include_directories(${Qt5Widgets_INCLUDE_DIRS}) - list(APPEND COCKATRICE_LIBS Widgets) +# QtNetwork +find_package(Qt5Network) +if(Qt5Network_FOUND) + include_directories(${Qt5Network_INCLUDE_DIRS}) + list(APPEND COCKATRICE_LIBS Network) +endif() - # QtConcurrent - find_package(Qt5Concurrent) - if(Qt5Concurrent_FOUND) - include_directories(${Qt5Concurrent_INCLUDE_DIRS}) - list(APPEND ORACLE_LIBS Concurrent) - endif() - - # QtNetwork - find_package(Qt5Network) - if(Qt5Network_FOUND) - include_directories(${Qt5Network_INCLUDE_DIRS}) - list(APPEND COCKATRICE_LIBS Network) - endif() - - qt5_use_modules(carddatabase_test ${COCKATRICE_LIBS}) -endif() \ No newline at end of file +qt5_use_modules(carddatabase_test ${COCKATRICE_LIBS}) diff --git a/travis-compile.sh b/travis-compile.sh index 0d26c5e4..f0d72ff8 100755 --- a/travis-compile.sh +++ b/travis-compile.sh @@ -7,19 +7,19 @@ set -e mkdir build cd build prefix="" -if [[ $TRAVIS_OS_NAME == "osx" && $QT4 == 0 ]]; then +if [[ $TRAVIS_OS_NAME == "osx" ]]; then prefix="-DCMAKE_PREFIX_PATH=$(echo /usr/local/Cellar/qt5/5.*/)" fi -if [[ $TRAVIS_OS_NAME == "linux" && $QT4 == 0 ]]; then +if [[ $TRAVIS_OS_NAME == "linux" ]]; then prefix="-DCMAKE_PREFIX_PATH=$(echo /opt/qt5*/lib/cmake/)" export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$(echo /opt/qt5*/lib/)" fi if [[ $BUILDTYPE == "Debug" ]]; then - cmake .. -DWITH_SERVER=1 -DTEST=1 -DCMAKE_BUILD_TYPE=$BUILDTYPE -DWITH_QT4=$QT4 $prefix + cmake .. -DWITH_SERVER=1 -DTEST=1 -DCMAKE_BUILD_TYPE=$BUILDTYPE $prefix make -j2 make test else - cmake .. -DWITH_SERVER=1 -DCMAKE_BUILD_TYPE=$BUILDTYPE -DWITH_QT4=$QT4 $prefix + cmake .. -DWITH_SERVER=1 -DCMAKE_BUILD_TYPE=$BUILDTYPE $prefix make package -j2 fi diff --git a/travis-dependencies.sh b/travis-dependencies.sh index 4409885d..cd63a416 100755 --- a/travis-dependencies.sh +++ b/travis-dependencies.sh @@ -2,30 +2,20 @@ if [[ $TRAVIS_OS_NAME == "osx" ]] ; then brew update > /dev/null - if (( QT4 )); then - brew install qt protobuf libgcrypt > /dev/null - else - brew install qt5 protobuf libgcrypt > /dev/null - fi + brew install qt5 protobuf > /dev/null brew unlink cmake brew upgrade cmake - else # common prerequisites sudo add-apt-repository -y ppa:smspillaz/cmake-master sudo apt-get update -qq sudo apt-get -y purge cmake - sudo apt-get install -y libprotobuf-dev protobuf-compiler cmake bc - - if (( QT4 )); then - # qt4 prerequisites - sudo apt-get install -y qtmobility-dev libqt4-dev - else - # qt5 prerequisites - sudo apt-get install -y libprotobuf-dev protobuf-compiler \ - qt5-default qttools5-dev qttools5-dev-tools \ - qtmultimedia5-dev libqt5multimedia5-plugins libqt5svg5-dev libqt5sql5-mysql - fi + sudo apt-get install -y \ + libprotobuf-dev protobuf-compiler \ + cmake \ + bc \ + qt5-default qttools5-dev qttools5-dev-tools \ + qtmultimedia5-dev libqt5multimedia5-plugins libqt5svg5-dev libqt5sql5-mysql # prerequisites for tests if [[ $BUILDTYPE == "Debug" ]]; then @@ -39,4 +29,4 @@ else sudo ln -s /usr/src/gtest/build/libgtest_main.so /usr/lib/libgtest_main.so cd - fi -fi +fi \ No newline at end of file