From 648a6a388495a8ecaf427976b5fa5f1c57bcca3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mark=20Morschh=C3=A4user?= Date: Fri, 20 Jun 2014 16:53:45 +0200 Subject: [PATCH 01/32] Qt5: QUrl addQueryItem moved to QUrlQuery --- cockatrice/src/deckstats_interface.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cockatrice/src/deckstats_interface.cpp b/cockatrice/src/deckstats_interface.cpp index eae4caae..d5cb4ba0 100644 --- a/cockatrice/src/deckstats_interface.cpp +++ b/cockatrice/src/deckstats_interface.cpp @@ -7,6 +7,10 @@ #include #include +#if QT_VERSION >= 0x050000 +#include +#endif + DeckStatsInterface::DeckStatsInterface(QObject *parent) : QObject(parent) { @@ -42,7 +46,13 @@ void DeckStatsInterface::queryFinished(QNetworkReply *reply) void DeckStatsInterface::analyzeDeck(DeckList *deck) { QUrl params; +#if QT_VERSION < 0x050000 params.addQueryItem("deck", deck->writeToString_Plain()); +#else + QUrlQuery urlQuery; + urlQuery.addQueryItem("deck", deck->writeToString_Plain()); + params.setUrlQuery(urlQuery); +#endif QByteArray data; data.append(params.encodedQuery()); From a903c231f266a87fa6ef5b49600a9e6dc8df62b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mark=20Morschh=C3=A4user?= Date: Fri, 20 Jun 2014 16:54:46 +0200 Subject: [PATCH 02/32] Qt5: QDesktopServices::storageLocation deprecated --- cockatrice/src/main.cpp | 4 ++++ oracle/src/window_main.cpp | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/cockatrice/src/main.cpp b/cockatrice/src/main.cpp index ef57655a..2de76f9e 100644 --- a/cockatrice/src/main.cpp +++ b/cockatrice/src/main.cpp @@ -120,7 +120,11 @@ int main(int argc, char *argv[]) qsrand(QDateTime::currentDateTime().toTime_t()); bool startMainProgram = true; +#if QT_VERSION < 0x050000 const QString dataDir = QDesktopServices::storageLocation(QDesktopServices::DataLocation); +#else + const QString dataDir = QStandardPaths::standardLocations(QStandardPaths::DataLocation)).toString(); +#endif if (!db->getLoadSuccess()) if (db->loadCardDatabase(dataDir + "/cards.xml")) settingsCache->setCardDatabasePath(dataDir + "/cards.xml"); diff --git a/oracle/src/window_main.cpp b/oracle/src/window_main.cpp index 0283bded..6d4a1be9 100644 --- a/oracle/src/window_main.cpp +++ b/oracle/src/window_main.cpp @@ -24,7 +24,11 @@ const QString WindowMain::defaultSetsUrl = QString("http://www.woogerworks.com/f WindowMain::WindowMain(QWidget *parent) : QMainWindow(parent) { +#if QT_VERSION < 0x050000 importer = new OracleImporter(QDesktopServices::storageLocation(QDesktopServices::DataLocation), this); +#else + importer = new OracleImporter(QStandardPaths::standardLocations(QStandardPaths::DataLocation)).toString(), this); +#endif nam = new QNetworkAccessManager(this); checkBoxLayout = new QVBoxLayout; @@ -176,7 +180,11 @@ void WindowMain::updateTotalProgress(int cardsImported, int setIndex, const QStr if (nextSetName.isEmpty()) { QMessageBox::information(this, tr("Oracle importer"), tr("Import finished: %1 cards.").arg(importer->getCardList().size())); bool ok = false; +#if QT_VERSION < 0x050000 const QString dataDir = QDesktopServices::storageLocation(QDesktopServices::DataLocation); +#else + const QString dataDir = QStandardPaths::standardLocations(QStandardPaths::DataLocation)).toString(); +#endif QDir dir(dataDir); if (!dir.exists()) dir.mkpath(dataDir); From 6fa94dd475a951b393052179ca096ba285e943e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mark=20Morschh=C3=A4user?= Date: Fri, 20 Jun 2014 16:55:26 +0200 Subject: [PATCH 03/32] Qt5: toAscii() and fromAscii() Methods are deprecated --- cockatrice/src/qt-json/json.cpp | 2 +- servatrice/src/passwordhasher.cpp | 2 +- servatrice/src/servatrice.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cockatrice/src/qt-json/json.cpp b/cockatrice/src/qt-json/json.cpp index 1cda4453..faf6601b 100644 --- a/cockatrice/src/qt-json/json.cpp +++ b/cockatrice/src/qt-json/json.cpp @@ -553,7 +553,7 @@ int Json::nextToken(const QString &json, int &index) QChar c = json[index]; index++; - switch(c.toAscii()) + switch(c.toLatin1()) { case '{': return JsonTokenCurlyOpen; case '}': return JsonTokenCurlyClose; diff --git a/servatrice/src/passwordhasher.cpp b/servatrice/src/passwordhasher.cpp index 1cc8528c..073cd9b9 100644 --- a/servatrice/src/passwordhasher.cpp +++ b/servatrice/src/passwordhasher.cpp @@ -16,7 +16,7 @@ QString PasswordHasher::computeHash(const QString &password, const QString &salt const int algo = GCRY_MD_SHA512; const int rounds = 1000; - QByteArray passwordBuffer = (salt + password).toAscii(); + QByteArray passwordBuffer = (salt + password).toLatin1(); int hashLen = gcry_md_get_algo_dlen(algo); char hash[hashLen], tmp[hashLen]; gcry_md_hash_buffer(algo, hash, passwordBuffer.data(), passwordBuffer.size()); diff --git a/servatrice/src/servatrice.cpp b/servatrice/src/servatrice.cpp index ee513339..c4a31205 100644 --- a/servatrice/src/servatrice.cpp +++ b/servatrice/src/servatrice.cpp @@ -319,7 +319,7 @@ void Servatrice::updateServerList() query.prepare("select id, ssl_cert, hostname, address, game_port, control_port from " + dbPrefix + "_servers order by id asc"); servatriceDatabaseInterface->execSqlQuery(query); while (query.next()) { - ServerProperties prop(query.value(0).toInt(), QSslCertificate(query.value(1).toString().toAscii()), query.value(2).toString(), QHostAddress(query.value(3).toString()), query.value(4).toInt(), query.value(5).toInt()); + ServerProperties prop(query.value(0).toInt(), QSslCertificate(query.value(1).toString().toLatin1()), query.value(2).toString(), QHostAddress(query.value(3).toString()), query.value(4).toInt(), query.value(5).toInt()); serverList.append(prop); qDebug() << QString("#%1 CERT=%2 NAME=%3 IP=%4:%5 CPORT=%6").arg(prop.id).arg(QString(prop.cert.digest().toHex())).arg(prop.hostname).arg(prop.address.toString()).arg(prop.gamePort).arg(prop.controlPort); } From 0721f5b41656757e56a0a4a343412c942f63306f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mark=20Morschh=C3=A4user?= Date: Fri, 20 Jun 2014 16:56:15 +0200 Subject: [PATCH 04/32] Qt5: QtWidgets as a Separate Module --- oracle/src/oracleimporter.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/oracle/src/oracleimporter.cpp b/oracle/src/oracleimporter.cpp index c244e56a..f4463455 100644 --- a/oracle/src/oracleimporter.cpp +++ b/oracle/src/oracleimporter.cpp @@ -1,5 +1,10 @@ #include "oracleimporter.h" +#if QT_VERSION < 0x050000 #include +#else +#include +#endif + #include #include #include From 05f46011eb35efff2c90ee4d7fa57c53f4ca2d53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mark=20Morschh=C3=A4user?= Date: Fri, 20 Jun 2014 18:16:46 +0200 Subject: [PATCH 05/32] Fix toLatin1() changes from 6fa94dd to toUtf8(). --- servatrice/src/passwordhasher.cpp | 2 +- servatrice/src/servatrice.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/servatrice/src/passwordhasher.cpp b/servatrice/src/passwordhasher.cpp index 073cd9b9..785034b4 100644 --- a/servatrice/src/passwordhasher.cpp +++ b/servatrice/src/passwordhasher.cpp @@ -16,7 +16,7 @@ QString PasswordHasher::computeHash(const QString &password, const QString &salt const int algo = GCRY_MD_SHA512; const int rounds = 1000; - QByteArray passwordBuffer = (salt + password).toLatin1(); + QByteArray passwordBuffer = (salt + password).toUtf8(); int hashLen = gcry_md_get_algo_dlen(algo); char hash[hashLen], tmp[hashLen]; gcry_md_hash_buffer(algo, hash, passwordBuffer.data(), passwordBuffer.size()); diff --git a/servatrice/src/servatrice.cpp b/servatrice/src/servatrice.cpp index c4a31205..6e0dbeb1 100644 --- a/servatrice/src/servatrice.cpp +++ b/servatrice/src/servatrice.cpp @@ -319,7 +319,7 @@ void Servatrice::updateServerList() query.prepare("select id, ssl_cert, hostname, address, game_port, control_port from " + dbPrefix + "_servers order by id asc"); servatriceDatabaseInterface->execSqlQuery(query); while (query.next()) { - ServerProperties prop(query.value(0).toInt(), QSslCertificate(query.value(1).toString().toLatin1()), query.value(2).toString(), QHostAddress(query.value(3).toString()), query.value(4).toInt(), query.value(5).toInt()); + ServerProperties prop(query.value(0).toInt(), QSslCertificate(query.value(1).toString().toUtf8()), query.value(2).toString(), QHostAddress(query.value(3).toString()), query.value(4).toInt(), query.value(5).toInt()); serverList.append(prop); qDebug() << QString("#%1 CERT=%2 NAME=%3 IP=%4:%5 CPORT=%6").arg(prop.id).arg(QString(prop.cert.digest().toHex())).arg(prop.hostname).arg(prop.address.toString()).arg(prop.gamePort).arg(prop.controlPort); } From d7a962c055a49a85d491dc4562b6805dd9340cb6 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Sat, 21 Jun 2014 14:12:55 +0200 Subject: [PATCH 06/32] CMake: support fir linking against qt5 --- CMakeLists.txt | 14 +++++- cockatrice/CMakeLists.txt | 97 ++++++++++++++++++++++++++++++++------- common/CMakeLists.txt | 15 +++++- oracle/CMakeLists.txt | 54 +++++++++++++++++++--- servatrice/CMakeLists.txt | 49 ++++++++++++++++++-- 5 files changed, 199 insertions(+), 30 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c8756e90..e60540e0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -71,8 +71,18 @@ IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") ADD_DEFINITIONS("-DSFMT_MEXP=19937") ENDIF() -#Find Qt4 and enable the needed features -FIND_PACKAGE(Qt4 REQUIRED) +#Find Qt and enable the needed features +FIND_PACKAGE(Qt5Widgets) +IF(Qt5Widgets_FOUND) + MESSAGE(STATUS "Found Qt ${Qt5Widgets_VERSION_STRING}") +ELSE() + FIND_PACKAGE(Qt4 REQUIRED) + IF(Qt4_FOUND) + MESSAGE(STATUS "Found Qt ${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH}") + ELSE() + MESSAGE(FATAL_ERROR "No Qt4 or Qt5 found!") + ENDIF() +ENDIF() set(CMAKE_AUTOMOC TRUE) diff --git a/cockatrice/CMakeLists.txt b/cockatrice/CMakeLists.txt index 499836dd..8edbf602 100644 --- a/cockatrice/CMakeLists.txt +++ b/cockatrice/CMakeLists.txt @@ -125,36 +125,101 @@ if(APPLE) set(cockatrice_SOURCES ${cockatrice_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/resources/appicon.icns) ENDIF(APPLE) -if (NOT QT_QTMULTIMEDIA_FOUND) - FIND_PACKAGE(QtMobility REQUIRED) -endif (NOT QT_QTMULTIMEDIA_FOUND) +set(COCKATRICE_LIBS) -SET(QT_USE_QTNETWORK TRUE) -SET(QT_USE_QTMULTIMEDIA TRUE) -SET(QT_USE_QTXML TRUE) -SET(QT_USE_QTSVG TRUE) +# Qt4 stuff +if(Qt4_FOUND) + if (NOT QT_QTMULTIMEDIA_FOUND) + FIND_PACKAGE(QtMobility REQUIRED) + endif (NOT QT_QTMULTIMEDIA_FOUND) + + SET(QT_USE_QTNETWORK TRUE) + SET(QT_USE_QTMULTIMEDIA TRUE) + SET(QT_USE_QTXML 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 + QT4_ADD_TRANSLATION(cockatrice_QM ${cockatrice_TS}) + QT4_ADD_RESOURCES(cockatrice_RESOURCES_RCC ${cockatrice_RESOURCES}) +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() + + # QtMultimedia + find_package(Qt5Multimedia) + if(Qt5Multimedia_FOUND) + include_directories(${Qt5Multimedia_INCLUDE_DIRS}) + list(APPEND COCKATRICE_LIBS Multimedia) + endif() + + # QtXml + find_package(Qt5Xml) + if(Qt5Xml_FOUND) + include_directories(${Qt5Xml_INCLUDE_DIRS}) + list(APPEND COCKATRICE_LIBS Xml) + endif() + + # QtSvg + find_package(Qt5Svg) + if(Qt5Svg_FOUND) + include_directories(${Qt5Svg_INCLUDE_DIRS}) + list(APPEND COCKATRICE_LIBS Svg) + endif() + + # Qt5LinguistTools + find_package(Qt5LinguistTools) + if(Qt5LinguistTools_FOUND) + include_directories(${Qt5LinguistTools_INCLUDE_DIRS}) + list(APPEND COCKATRICE_LIBS LinguistTools) + endif() + + # Let cmake chew Qt4's translations and resource files + # Note: header files are MOC-ed automatically by cmake + QT5_ADD_TRANSLATION(cockatrice_QM ${cockatrice_TS}) + QT5_ADD_RESOURCES(cockatrice_RESOURCES_RCC ${cockatrice_RESOURCES}) +endif() # Declare path variables set(ICONDIR share/icons CACHE STRING "icon dir") set(DESKTOPDIR share/applications CACHE STRING "desktop file destination") -# Let cmake chew Qt4's translations and resource files -# Note: header files are MOC-ed automatically by cmake -QT4_ADD_TRANSLATION(cockatrice_QM ${cockatrice_TS}) -QT4_ADD_RESOURCES(cockatrice_RESOURCES_RCC ${cockatrice_RESOURCES}) - # Include directories -INCLUDE(${QT_USE_FILE}) INCLUDE_DIRECTORIES(../common) INCLUDE_DIRECTORIES(${PROTOBUF_INCLUDE_DIR}) INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/common) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) -INCLUDE_DIRECTORIES(${QT_MOBILITY_INCLUDE_DIR}) -INCLUDE_DIRECTORIES(${QT_MOBILITY_MULTIMEDIAKIT_INCLUDE_DIR}) # Build cockatrice binary and link it ADD_EXECUTABLE(cockatrice WIN32 MACOSX_BUNDLE ${cockatrice_SOURCES} ${cockatrice_QM} ${cockatrice_RESOURCES_RCC} ${cockatrice_MOC_SRCS}) -TARGET_LINK_LIBRARIES(cockatrice cockatrice_common ${QT_QTMAIN_LIBRARY} ${QT_LIBRARIES} ${QT_MOBILITY_MULTIMEDIAKIT_LIBRARY}) + +if(Qt4_FOUND) + TARGET_LINK_LIBRARIES(cockatrice cockatrice_common ${COCKATRICE_LIBS}) +endif() +if(Qt5Widgets_FOUND) + TARGET_LINK_LIBRARIES(cockatrice cockatrice_common) + qt5_use_modules(cockatrice ${COCKATRICE_LIBS}) +endif() + if(MSVC) set_target_properties(cockatrice PROPERTIES LINK_FLAGS "/SUBSYSTEM:WINDOWS") diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 3f0d8c6c..47dab1f5 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -28,7 +28,20 @@ SET(common_SOURCES sfmt/SFMT.c ) -INCLUDE(${QT_USE_FILE}) +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}) diff --git a/oracle/CMakeLists.txt b/oracle/CMakeLists.txt index 624d9e96..dd544a1c 100644 --- a/oracle/CMakeLists.txt +++ b/oracle/CMakeLists.txt @@ -15,17 +15,59 @@ SET(oracle_SOURCES ../cockatrice/src/settingscache.cpp ) -SET(QT_USE_QTNETWORK TRUE) -SET(QT_USE_QTXML TRUE) -SET(QT_USE_QTSVG TRUE) +set(ORACLE_LIBS) + +# Qt4 stuff +if(Qt4_FOUND) + SET(QT_USE_QTNETWORK TRUE) + SET(QT_USE_QTXML 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}) +endif() + +# qt5 stuff +if(Qt5Widgets_FOUND) + include_directories(${Qt5Widgets_INCLUDE_DIRS}) + list(APPEND ORACLE_LIBS Widgets) + + # QtNetwork + find_package(Qt5Network) + if(Qt5Network_FOUND) + include_directories(${Qt5Network_INCLUDE_DIRS}) + list(APPEND ORACLE_LIBS Network) + endif() + + # QtXml + find_package(Qt5Xml) + if(Qt5Xml_FOUND) + include_directories(${Qt5Xml_INCLUDE_DIRS}) + list(APPEND ORACLE_LIBS Xml) + endif() + + # QtSvg + find_package(Qt5Svg) + if(Qt5Svg_FOUND) + include_directories(${Qt5Svg_INCLUDE_DIRS}) + list(APPEND ORACLE_LIBS Svg) + endif() +endif() -# Include directories -INCLUDE(${QT_USE_FILE}) INCLUDE_DIRECTORIES(../cockatrice/src) # Build oracle binary and link it ADD_EXECUTABLE(oracle WIN32 MACOSX_BUNDLE ${oracle_SOURCES} ${oracle_MOC_SRCS}) -TARGET_LINK_LIBRARIES(oracle ${QT_QTMAIN_LIBRARY} ${QT_LIBRARIES}) + +if(Qt4_FOUND) + TARGET_LINK_LIBRARIES(oracle ${ORACLE_LIBS}) +endif() +if(Qt5Widgets_FOUND) + qt5_use_modules(oracle ${ORACLE_LIBS}) +endif() if(MSVC) set_target_properties(oracle PROPERTIES LINK_FLAGS "/SUBSYSTEM:WINDOWS") diff --git a/servatrice/CMakeLists.txt b/servatrice/CMakeLists.txt index 799cecbd..ff403e23 100644 --- a/servatrice/CMakeLists.txt +++ b/servatrice/CMakeLists.txt @@ -20,12 +20,42 @@ SET(servatrice_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/version_string.cpp ) -SET(QT_DONTUSE_QTGUI) -SET(QT_USE_QTNETWORK TRUE) -SET(QT_USE_QTSQL TRUE) +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}) +endif() + +# qt5 stuff +if(Qt5Widgets_FOUND) + include_directories(${Qt5Widgets_INCLUDE_DIRS}) + list(APPEND SERVATRICE_LIBS Widgets) + + # QtNetwork + find_package(Qt5Network) + if(Qt5Network_FOUND) + include_directories(${Qt5Network_INCLUDE_DIRS}) + list(APPEND SERVATRICE_LIBS Network) + endif() + + # QtSql + find_package(Qt5Sql) + if(Qt5Sql_FOUND) + include_directories(${Qt5Sql_INCLUDE_DIRS}) + list(APPEND SERVATRICE_LIBS Sql) + endif() +endif() + +SET(QT_DONT_USE_QTGUI TRUE) # Include directories -INCLUDE(${QT_USE_FILE}) INCLUDE_DIRECTORIES(../common) INCLUDE_DIRECTORIES(${LIBGCRYPT_INCLUDE_DIR}) INCLUDE_DIRECTORIES(${PROTOBUF_INCLUDE_DIR}) @@ -34,7 +64,16 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) # Build servatrice binary and link it ADD_EXECUTABLE(servatrice MACOSX_BUNDLE ${servatrice_SOURCES} ${servatrice_MOC_SRCS}) -TARGET_LINK_LIBRARIES(servatrice cockatrice_common ${QT_LIBRARIES} ${LIBGCRYPT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT}) + +if(Qt4_FOUND) + TARGET_LINK_LIBRARIES(servatrice cockatrice_common ${SERVATRICE_LIBS} ${LIBGCRYPT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT}) +endif() +if(Qt5Widgets_FOUND) + TARGET_LINK_LIBRARIES(servatrice cockatrice_common ${LIBGCRYPT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT}) + qt5_use_modules(servatrice ${SERVATRICE_LIBS}) +endif() + + #add_custom_target(versionheader ALL DEPENDS version_header) add_custom_command( From 80f68306b5210d83e7b130b49a82488020606d78 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Tue, 24 Jun 2014 18:28:09 +0200 Subject: [PATCH 07/32] Ported oracle to Qt5 --- common/server_response_containers.h | 1 + oracle/CMakeLists.txt | 7 ++++++ oracle/src/main.cpp | 7 ++++-- oracle/src/oraclewizard.cpp | 35 ++++++++++++++++++++++++++--- 4 files changed, 45 insertions(+), 5 deletions(-) diff --git a/common/server_response_containers.h b/common/server_response_containers.h index 9220cdac..afad1a1e 100644 --- a/common/server_response_containers.h +++ b/common/server_response_containers.h @@ -2,6 +2,7 @@ #define SERVER_RESPONSE_CONTAINERS_H #include +#include #include "pb/server_message.pb.h" namespace google { namespace protobuf { class Message; } } diff --git a/oracle/CMakeLists.txt b/oracle/CMakeLists.txt index fddfe774..12dc6406 100644 --- a/oracle/CMakeLists.txt +++ b/oracle/CMakeLists.txt @@ -36,6 +36,13 @@ if(Qt5Widgets_FOUND) include_directories(${Qt5Widgets_INCLUDE_DIRS}) list(APPEND ORACLE_LIBS Widgets) + # 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) diff --git a/oracle/src/main.cpp b/oracle/src/main.cpp index 44b900f3..d2fb708d 100644 --- a/oracle/src/main.cpp +++ b/oracle/src/main.cpp @@ -8,9 +8,12 @@ SettingsCache *settingsCache; 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/oraclewizard.cpp b/oracle/src/oraclewizard.cpp index 75381b1d..4f0e102a 100644 --- a/oracle/src/oraclewizard.cpp +++ b/oracle/src/oraclewizard.cpp @@ -1,8 +1,25 @@ #include +#if QT_VERSION < 0x050000 + #include +#else + #include +#endif +#include +#include +#include +#include #include -#include +#include +#include +#include #include #include +#include +#include +#include +#include +#include +#include #include "oraclewizard.h" #include "oracleimporter.h" @@ -13,7 +30,14 @@ OracleWizard::OracleWizard(QWidget *parent) : QWizard(parent) { settings = new QSettings(this); - importer = new OracleImporter(QDesktopServices::storageLocation(QDesktopServices::DataLocation), this); + + importer = new OracleImporter( +#if QT_VERSION < 0x050000 + QDesktopServices::storageLocation(QDesktopServices::DataLocation) +#else + QStandardPaths::standardLocations(QStandardPaths::DataLocation).first() +#endif + , this); addPage(new IntroPage); addPage(new LoadSetsPage); @@ -372,7 +396,12 @@ void SaveSetsPage::updateTotalProgress(int cardsImported, int setIndex, const QS bool SaveSetsPage::validatePage() { bool ok = false; - const QString dataDir = QDesktopServices::storageLocation(QDesktopServices::DataLocation); + const QString dataDir = +#if QT_VERSION < 0x050000 + QDesktopServices::storageLocation(QDesktopServices::DataLocation); +#else + QStandardPaths::standardLocations(QStandardPaths::DataLocation).first(); +#endif QDir dir(dataDir); if (!dir.exists()) dir.mkpath(dataDir); From 2953c6ba2a6895cf429db0d3d3a0157db3bf8550 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Tue, 24 Jun 2014 18:42:46 +0200 Subject: [PATCH 08/32] Ported servatrice --- servatrice/src/main.cpp | 34 ++++++++++++++++++++++++++++++---- servatrice/src/servatrice.cpp | 8 ++++++++ 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/servatrice/src/main.cpp b/servatrice/src/main.cpp index 0f7f0112..a37f3bd6 100644 --- a/servatrice/src/main.cpp +++ b/servatrice/src/main.cpp @@ -93,6 +93,17 @@ void myMessageOutput2(QtMsgType /*type*/, const char *msg) std::cerr << msg << std::endl; } +void myMessageOutputQt5(QtMsgType /*type*/, const QMessageLogContext &, const QString &msg) +{ + logger->logMessage(msg); +} + +void myMessageOutput2Qt5(QtMsgType /*type*/, const QMessageLogContext &, const QString &msg) +{ + logger->logMessage(msg); + std::cerr << msg.toStdString() << std::endl; +} + #ifdef Q_OS_UNIX void sigSegvHandler(int sig) { @@ -121,9 +132,12 @@ int main(int argc, char *argv[]) bool logToConsole = args.contains("--log-to-console"); qRegisterMetaType >("QList"); - + +#if QT_VERSION < 0x050000 + // gone in Qt5, all source files _MUST_ be utf8-encoded QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); - +#endif + QSettings *settings = new QSettings("servatrice.ini", QSettings::IniFormat); loggerThread = new QThread; @@ -133,11 +147,19 @@ int main(int argc, char *argv[]) loggerThread->start(); QMetaObject::invokeMethod(logger, "startLog", Qt::BlockingQueuedConnection, Q_ARG(QString, settings->value("server/logfile").toString())); - + +#if QT_VERSION < 0x050000 if (logToConsole) qInstallMsgHandler(myMessageOutput); else qInstallMsgHandler(myMessageOutput2); +#else + if (logToConsole) + qInstallMessageHandler(myMessageOutputQt5); + else + qInstallMessageHandler(myMessageOutput2Qt5); +#endif + #ifdef Q_OS_UNIX struct sigaction hup; hup.sa_handler = ServerLogger::hupSignalHandler; @@ -173,8 +195,12 @@ int main(int argc, char *argv[]) if (server->initServer()) { std::cerr << "-------------------------" << std::endl; std::cerr << "Server initialized." << std::endl; - + +#if QT_VERSION < 0x050000 qInstallMsgHandler(myMessageOutput); +#else + qInstallMessageHandler(myMessageOutputQt5); +#endif retval = app.exec(); std::cerr << "Server quit." << std::endl; diff --git a/servatrice/src/servatrice.cpp b/servatrice/src/servatrice.cpp index 6e0dbeb1..87eada78 100644 --- a/servatrice/src/servatrice.cpp +++ b/servatrice/src/servatrice.cpp @@ -234,8 +234,16 @@ 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)) From bab340f7b708aeb197d51c874f915c0545c61c0d Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Tue, 24 Jun 2014 18:52:04 +0200 Subject: [PATCH 09/32] Reworked a bit message handling from previous commit --- servatrice/src/main.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/servatrice/src/main.cpp b/servatrice/src/main.cpp index a37f3bd6..37b750f4 100644 --- a/servatrice/src/main.cpp +++ b/servatrice/src/main.cpp @@ -82,6 +82,7 @@ void testHash() std::cerr << startTime.secsTo(endTime) << "secs" << std::endl; } +#if QT_VERSION < 0x050000 void myMessageOutput(QtMsgType /*type*/, const char *msg) { logger->logMessage(msg); @@ -92,17 +93,18 @@ void myMessageOutput2(QtMsgType /*type*/, const char *msg) logger->logMessage(msg); std::cerr << msg << std::endl; } - -void myMessageOutputQt5(QtMsgType /*type*/, const QMessageLogContext &, const QString &msg) +#else +void myMessageOutput(QtMsgType /*type*/, const QMessageLogContext &, const QString &msg) { logger->logMessage(msg); } -void myMessageOutput2Qt5(QtMsgType /*type*/, const QMessageLogContext &, const QString &msg) +void myMessageOutput2(QtMsgType /*type*/, const QMessageLogContext &, const QString &msg) { logger->logMessage(msg); std::cerr << msg.toStdString() << std::endl; } +#endif #ifdef Q_OS_UNIX void sigSegvHandler(int sig) @@ -155,9 +157,9 @@ int main(int argc, char *argv[]) qInstallMsgHandler(myMessageOutput2); #else if (logToConsole) - qInstallMessageHandler(myMessageOutputQt5); + qInstallMessageHandler(myMessageOutput); else - qInstallMessageHandler(myMessageOutput2Qt5); + qInstallMessageHandler(myMessageOutput2); #endif #ifdef Q_OS_UNIX @@ -199,7 +201,7 @@ int main(int argc, char *argv[]) #if QT_VERSION < 0x050000 qInstallMsgHandler(myMessageOutput); #else - qInstallMessageHandler(myMessageOutputQt5); + qInstallMessageHandler(myMessageOutput); #endif retval = app.exec(); From 6dbdaafb332aa1cde577ece46bb554cb0ac28c6b Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Tue, 24 Jun 2014 19:13:47 +0200 Subject: [PATCH 10/32] Ported cockatrice --- cockatrice/CMakeLists.txt | 7 +++ cockatrice/src/abstractcounter.cpp | 14 ++++- cockatrice/src/carddatabasemodel.cpp | 8 +++ cockatrice/src/decklistmodel.cpp | 8 +++ cockatrice/src/deckstats_interface.cpp | 8 +-- cockatrice/src/deckview.cpp | 4 ++ cockatrice/src/dlg_create_token.cpp | 5 ++ cockatrice/src/dlg_edit_tokens.cpp | 5 ++ cockatrice/src/gameselector.cpp | 5 +- cockatrice/src/main.cpp | 23 +++++++- cockatrice/src/pilezone.cpp | 4 ++ cockatrice/src/player.cpp | 52 ++++++++++++++++--- cockatrice/src/playerlistwidget.cpp | 4 ++ cockatrice/src/remotedecklist_treewidget.cpp | 13 +++++ .../src/remotereplaylist_treewidget.cpp | 4 ++ cockatrice/src/soundengine.cpp | 5 ++ cockatrice/src/tab_deck_editor.cpp | 4 ++ cockatrice/src/tab_deck_storage.cpp | 4 ++ cockatrice/src/tab_replays.cpp | 4 ++ cockatrice/src/tab_server.cpp | 8 ++- cockatrice/src/tablezone.cpp | 4 ++ cockatrice/src/userlist.cpp | 4 ++ 22 files changed, 181 insertions(+), 16 deletions(-) diff --git a/cockatrice/CMakeLists.txt b/cockatrice/CMakeLists.txt index 8edbf602..e02f9e2c 100644 --- a/cockatrice/CMakeLists.txt +++ b/cockatrice/CMakeLists.txt @@ -172,6 +172,13 @@ if(Qt5Widgets_FOUND) list(APPEND COCKATRICE_LIBS Multimedia) endif() + # QtPrinter + find_package(Qt5PrintSupport) + if(Qt5PrintSupport_FOUND) + include_directories(${Qt5PrintSupport_INCLUDE_DIRS}) + list(APPEND COCKATRICE_LIBS PrintSupport) + endif() + # QtXml find_package(Qt5Xml) if(Qt5Xml_FOUND) diff --git a/cockatrice/src/abstractcounter.cpp b/cockatrice/src/abstractcounter.cpp index 73fc9466..b9debae4 100644 --- a/cockatrice/src/abstractcounter.cpp +++ b/cockatrice/src/abstractcounter.cpp @@ -11,8 +11,12 @@ 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 + if (player->getLocal()) { menu = new QMenu(name); aSet = new QAction(this); @@ -129,7 +133,13 @@ void AbstractCounter::setCounter() { bool ok; dialogSemaphore = true; - int newValue = QInputDialog::getInteger(0, tr("Set counter"), tr("New value for counter '%1':").arg(name), value, -2000000000, 2000000000, 1, &ok); + 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); if (deleteAfterDialog) { deleteLater(); return; diff --git a/cockatrice/src/carddatabasemodel.cpp b/cockatrice/src/carddatabasemodel.cpp index e62664be..65b08d49 100644 --- a/cockatrice/src/carddatabasemodel.cpp +++ b/cockatrice/src/carddatabasemodel.cpp @@ -68,6 +68,10 @@ QVariant CardDatabaseModel::headerData(int section, Qt::Orientation orientation, void CardDatabaseModel::updateCardList() { +#if QT_VERSION >= 0x050000 + beginResetModel(); +#endif + for (int i = 0; i < cardList.size(); ++i) disconnect(cardList[i], 0, this, 0); @@ -75,7 +79,11 @@ void CardDatabaseModel::updateCardList() for (int i = 0; i < cardList.size(); ++i) connect(cardList[i], SIGNAL(cardInfoChanged(CardInfo *)), this, SLOT(cardInfoChanged(CardInfo *))); +#if QT_VERSION < 0x050000 reset(); +#else + endResetModel(); +#endif } void CardDatabaseModel::cardInfoChanged(CardInfo *card) diff --git a/cockatrice/src/decklistmodel.cpp b/cockatrice/src/decklistmodel.cpp index 00d92fae..8a1065f0 100644 --- a/cockatrice/src/decklistmodel.cpp +++ b/cockatrice/src/decklistmodel.cpp @@ -30,6 +30,10 @@ DeckListModel::~DeckListModel() void DeckListModel::rebuildTree() { +#if QT_VERSION >= 0x050000 + beginResetModel(); +#endif + root->clearTree(); InnerDecklistNode *listRoot = deckList->getRoot(); for (int i = 0; i < listRoot->size(); i++) { @@ -55,7 +59,11 @@ void DeckListModel::rebuildTree() } } +#if QT_VERSION < 0x050000 reset(); +#else + endResetModel(); +#endif } int DeckListModel::rowCount(const QModelIndex &parent) const diff --git a/cockatrice/src/deckstats_interface.cpp b/cockatrice/src/deckstats_interface.cpp index d5cb4ba0..4eb62d20 100644 --- a/cockatrice/src/deckstats_interface.cpp +++ b/cockatrice/src/deckstats_interface.cpp @@ -48,13 +48,15 @@ void DeckStatsInterface::analyzeDeck(DeckList *deck) QUrl params; #if QT_VERSION < 0x050000 params.addQueryItem("deck", deck->writeToString_Plain()); + QByteArray data; + data.append(params.encodedQuery()); #else QUrlQuery urlQuery; urlQuery.addQueryItem("deck", deck->writeToString_Plain()); - params.setUrlQuery(urlQuery); -#endif + params.setQuery(urlQuery); QByteArray data; - data.append(params.encodedQuery()); + data.append(params.query(QUrl::EncodeReserved)); +#endif QNetworkRequest request(QUrl("http://deckstats.net/index.php")); request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); diff --git a/cockatrice/src/deckview.cpp b/cockatrice/src/deckview.cpp index 1746c58b..5a14ec3f 100644 --- a/cockatrice/src/deckview.cpp +++ b/cockatrice/src/deckview.cpp @@ -64,7 +64,11 @@ 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 942fdda6..9775ed0c 100644 --- a/cockatrice/src/dlg_create_token.cpp +++ b/cockatrice/src/dlg_create_token.cpp @@ -79,8 +79,13 @@ DlgCreateToken::DlgCreateToken(const QStringList &_predefinedTokens, QWidget *pa 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))); if (predefinedTokens.isEmpty()) diff --git a/cockatrice/src/dlg_edit_tokens.cpp b/cockatrice/src/dlg_edit_tokens.cpp index 038b1a4a..28fefa7d 100644 --- a/cockatrice/src/dlg_edit_tokens.cpp +++ b/cockatrice/src/dlg_edit_tokens.cpp @@ -73,8 +73,13 @@ DlgEditTokens::DlgEditTokens(CardDatabaseModel *_cardDatabaseModel, QWidget *par 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/gameselector.cpp b/cockatrice/src/gameselector.cpp index 6a05d905..02fb323e 100644 --- a/cockatrice/src/gameselector.cpp +++ b/cockatrice/src/gameselector.cpp @@ -33,8 +33,11 @@ GameSelector::GameSelector(AbstractClient *_client, const TabSupervisor *_tabSup gameListView->header()->hideSection(1); else gameListProxyModel->setUnavailableGamesVisible(true); +#if QT_VERSION < 0x050000 gameListView->header()->setResizeMode(1, QHeaderView::ResizeToContents); - +#else + gameListView->header()->setSectionResizeMode(1, QHeaderView::ResizeToContents); +#endif filterButton = new QPushButton; filterButton->setIcon(QIcon(":/resources/icon_search.svg")); connect(filterButton, SIGNAL(clicked()), this, SLOT(actSetFilter())); diff --git a/cockatrice/src/main.cpp b/cockatrice/src/main.cpp index 23ca8c7a..c47eb7bc 100644 --- a/cockatrice/src/main.cpp +++ b/cockatrice/src/main.cpp @@ -55,6 +55,7 @@ QString translationPath = TRANSLATION_PATH; QString translationPath = QString(); #endif +#if QT_VERSION < 0x050000 void myMessageOutput(QtMsgType /*type*/, const char *msg) { QFile file("qdebug.txt"); @@ -63,6 +64,16 @@ void myMessageOutput(QtMsgType /*type*/, const char *msg) out << msg << endl; file.close(); } +#else +void myMessageOutput(QtMsgType /*type*/, const QMessageLogContext &, const QString &msg) +{ + QFile file("qdebug.txt"); + file.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text); + QTextStream out(&file); + out << msg << endl; + file.close(); +} +#endif void installNewTranslator() { @@ -87,7 +98,13 @@ 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_MAC QDir baseDir(app.applicationDirPath()); baseDir.cdUp(); @@ -100,7 +117,11 @@ int main(int argc, char *argv[]) #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"); @@ -131,7 +152,7 @@ int main(int argc, char *argv[]) #if QT_VERSION < 0x050000 const QString dataDir = QDesktopServices::storageLocation(QDesktopServices::DataLocation); #else - const QString dataDir = QStandardPaths::standardLocations(QStandardPaths::DataLocation)).toString(); + const QString dataDir = QStandardPaths::standardLocations(QStandardPaths::DataLocation).first(); #endif if (!db->getLoadSuccess()) if (db->loadCardDatabase(dataDir + "/cards.xml")) diff --git a/cockatrice/src/pilezone.cpp b/cockatrice/src/pilezone.cpp index 0dbdd566..ed9daa88 100644 --- a/cockatrice/src/pilezone.cpp +++ b/cockatrice/src/pilezone.cpp @@ -13,7 +13,11 @@ 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 762b4387..d260cbea 100644 --- a/cockatrice/src/player.cpp +++ b/cockatrice/src/player.cpp @@ -774,7 +774,13 @@ void Player::actViewLibrary() void Player::actViewTopCards() { bool ok; - int number = QInputDialog::getInteger(0, tr("View top cards of library"), tr("Number of cards:"), defaultNumberTopCards, 1, 2000000000, 1, &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); if (ok) { defaultNumberTopCards = number; static_cast(scene())->toggleZoneView(this, "deck", number); @@ -829,7 +835,13 @@ void Player::actMulligan() void Player::actDrawCards() { - int number = QInputDialog::getInteger(0, tr("Draw cards"), tr("Number:")); + int number = +#if QT_VERSION < 0x050000 + QInputDialog::getInteger( +#else + QInputDialog::getInt( +#endif + 0, tr("Draw cards"), tr("Number:")); if (number) { Command_DrawCards cmd; cmd.set_number(number); @@ -844,8 +856,14 @@ void Player::actUndoDraw() void Player::actMoveTopCardsToGrave() { - int number = QInputDialog::getInteger(0, tr("Move top cards to grave"), tr("Number:")); - if (!number) + int number = +#if QT_VERSION < 0x050000 + QInputDialog::getInteger( +#else + QInputDialog::getInt( +#endif + 0, tr("Move top cards to grave"), tr("Number:")); + if (!number) return; const int maxCards = zones.value("deck")->getCards().size(); @@ -867,8 +885,14 @@ void Player::actMoveTopCardsToGrave() void Player::actMoveTopCardsToExile() { - int number = QInputDialog::getInteger(0, tr("Move top cards to exile"), tr("Number:")); - if (!number) + int number = +#if QT_VERSION < 0x050000 + QInputDialog::getInteger( +#else + QInputDialog::getInt( +#endif + 0, tr("Move top cards to exile"), tr("Number:")); + if (!number) return; const int maxCards = zones.value("deck")->getCards().size(); @@ -914,7 +938,13 @@ void Player::actUntapAll() void Player::actRollDie() { bool ok; - int sides = QInputDialog::getInteger(0, tr("Roll die"), tr("Number of sides:"), 20, 2, 1000, 1, &ok); + int sides = +#if QT_VERSION < 0x050000 + QInputDialog::getInteger( +#else + QInputDialog::getInt( +#endif + 0, tr("Roll die"), tr("Number of sides:"), 20, 2, 1000, 1, &ok); if (ok) { Command_RollDie cmd; cmd.set_sides(sides); @@ -2022,7 +2052,13 @@ void Player::actCardCounterTrigger() case 11: { bool ok; dialogSemaphore = true; - int number = QInputDialog::getInteger(0, tr("Set counters"), tr("Number:"), 0, 0, MAX_COUNTERS_ON_CARD, 1, &ok); + 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); dialogSemaphore = false; if (clearCardsToDelete()) return; diff --git a/cockatrice/src/playerlistwidget.cpp b/cockatrice/src/playerlistwidget.cpp index f299cda9..ee088203 100644 --- a/cockatrice/src/playerlistwidget.cpp +++ b/cockatrice/src/playerlistwidget.cpp @@ -72,7 +72,11 @@ PlayerListWidget::PlayerListWidget(TabSupervisor *_tabSupervisor, AbstractClient setColumnCount(6); setHeaderHidden(true); setRootIsDecorated(false); +#if QT_VERSION < 0x050000 header()->setResizeMode(QHeaderView::ResizeToContents); +#else + header()->setSectionResizeMode(QHeaderView::ResizeToContents); +#endif retranslateUi(); } diff --git a/cockatrice/src/remotedecklist_treewidget.cpp b/cockatrice/src/remotedecklist_treewidget.cpp index b72df671..809f3fe8 100644 --- a/cockatrice/src/remotedecklist_treewidget.cpp +++ b/cockatrice/src/remotedecklist_treewidget.cpp @@ -258,8 +258,17 @@ void RemoteDeckList_TreeModel::deckListFinished(const Response &r) { const Response_DeckList &resp = r.GetExtension(Response_DeckList::ext); +#if QT_VERSION >= 0x050000 + beginResetModel(); +#endif + root->clearTree(); + +#if QT_VERSION < 0x050000 reset(); +#else + endResetModel(); +#endif ServerInfo_DeckStorage_TreeItem tempRoot; tempRoot.set_id(0); @@ -280,7 +289,11 @@ 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 6184049e..5357596f 100644 --- a/cockatrice/src/remotereplaylist_treewidget.cpp +++ b/cockatrice/src/remotereplaylist_treewidget.cpp @@ -278,7 +278,11 @@ 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/soundengine.cpp b/cockatrice/src/soundengine.cpp index 5847c9ae..89820f9d 100644 --- a/cockatrice/src/soundengine.cpp +++ b/cockatrice/src/soundengine.cpp @@ -33,8 +33,13 @@ void SoundEngine::soundEnabledChanged() if (settingsCache->getSoundEnabled()) { qDebug("SoundEngine: enabling sound"); 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); diff --git a/cockatrice/src/tab_deck_editor.cpp b/cockatrice/src/tab_deck_editor.cpp index 0c1d44e1..0b27dcbf 100644 --- a/cockatrice/src/tab_deck_editor.cpp +++ b/cockatrice/src/tab_deck_editor.cpp @@ -134,7 +134,11 @@ TabDeckEditor::TabDeckEditor(TabSupervisor *_tabSupervisor, QWidget *parent) 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(&deckViewKeySignals, SIGNAL(onEnter()), this, SLOT(actIncrement())); diff --git a/cockatrice/src/tab_deck_storage.cpp b/cockatrice/src/tab_deck_storage.cpp index 7e7d30ed..9898c9ee 100644 --- a/cockatrice/src/tab_deck_storage.cpp +++ b/cockatrice/src/tab_deck_storage.cpp @@ -38,7 +38,11 @@ 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_replays.cpp b/cockatrice/src/tab_replays.cpp index 92b0be08..6b3a6210 100644 --- a/cockatrice/src/tab_replays.cpp +++ b/cockatrice/src/tab_replays.cpp @@ -36,7 +36,11 @@ 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_server.cpp b/cockatrice/src/tab_server.cpp index a8e89af5..b82248a3 100644 --- a/cockatrice/src/tab_server.cpp +++ b/cockatrice/src/tab_server.cpp @@ -28,11 +28,17 @@ RoomSelector::RoomSelector(AbstractClient *_client, QWidget *parent) roomList->setRootIsDecorated(false); roomList->setColumnCount(4); 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 d7fa4218..f716cfbc 100644 --- a/cockatrice/src/tablezone.cpp +++ b/cockatrice/src/tablezone.cpp @@ -28,7 +28,11 @@ TableZone::TableZone(Player *_p, QGraphicsItem *parent) currentMinimumWidth = minWidth; setCacheMode(DeviceCoordinateCache); +#if QT_VERSION < 0x050000 setAcceptsHoverEvents(true); +#else + setAcceptHoverEvents(true); +#endif } void TableZone::updateBgPixmap() diff --git a/cockatrice/src/userlist.cpp b/cockatrice/src/userlist.cpp index 562d395b..29d13781 100644 --- a/cockatrice/src/userlist.cpp +++ b/cockatrice/src/userlist.cpp @@ -216,7 +216,11 @@ 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)); From 7035150351c3b9f013a55af9db00097b8f8bd77c Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Wed, 25 Jun 2014 09:07:02 +0200 Subject: [PATCH 11/32] Deckstats: move QUrl handling into its own function; better separation of qt4/qt5 code --- cockatrice/src/deckstats_interface.cpp | 21 +++++++++++++++------ cockatrice/src/deckstats_interface.h | 2 ++ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/cockatrice/src/deckstats_interface.cpp b/cockatrice/src/deckstats_interface.cpp index 4eb62d20..245e04c2 100644 --- a/cockatrice/src/deckstats_interface.cpp +++ b/cockatrice/src/deckstats_interface.cpp @@ -43,20 +43,29 @@ void DeckStatsInterface::queryFinished(QNetworkReply *reply) deleteLater(); } -void DeckStatsInterface::analyzeDeck(DeckList *deck) +#if QT_VERSION < 0x050000 +void DeckStatsInterface::getAnalyzeRequestData(DeckList *deck, QByteArray *data) { QUrl params; -#if QT_VERSION < 0x050000 params.addQueryItem("deck", deck->writeToString_Plain()); - QByteArray data; - data.append(params.encodedQuery()); + data->append(params.encodedQuery()); +} #else +void DeckStatsInterface::getAnalyzeRequestData(DeckList *deck, QByteArray *data) +{ + QUrl params; QUrlQuery urlQuery; urlQuery.addQueryItem("deck", deck->writeToString_Plain()); params.setQuery(urlQuery); - QByteArray data; - data.append(params.query(QUrl::EncodeReserved)); + data->append(params.query(QUrl::EncodeReserved)); +} #endif + + +void DeckStatsInterface::analyzeDeck(DeckList *deck) +{ + QByteArray data; + getAnalyzeRequestData(deck, &data); QNetworkRequest request(QUrl("http://deckstats.net/index.php")); request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); diff --git a/cockatrice/src/deckstats_interface.h b/cockatrice/src/deckstats_interface.h index e8454dd5..756f917d 100644 --- a/cockatrice/src/deckstats_interface.h +++ b/cockatrice/src/deckstats_interface.h @@ -3,6 +3,7 @@ #include +class QByteArray; class QNetworkAccessManager; class QNetworkReply; class DeckList; @@ -13,6 +14,7 @@ private: QNetworkAccessManager *manager; private slots: void queryFinished(QNetworkReply *reply); + void getAnalyzeRequestData(DeckList *deck, QByteArray *data); public: DeckStatsInterface(QObject *parent = 0); void analyzeDeck(DeckList *deck); From c4458b16b2004aa9fbe6c353c58c81134fb4304b Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Wed, 25 Jun 2014 15:53:25 +0200 Subject: [PATCH 12/32] Qt5: fix plugin installation --- cockatrice/CMakeLists.txt | 5 ++++- oracle/CMakeLists.txt | 3 +++ servatrice/CMakeLists.txt | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/cockatrice/CMakeLists.txt b/cockatrice/CMakeLists.txt index 92586891..be347188 100644 --- a/cockatrice/CMakeLists.txt +++ b/cockatrice/CMakeLists.txt @@ -201,10 +201,13 @@ if(Qt5Widgets_FOUND) list(APPEND COCKATRICE_LIBS LinguistTools) endif() - # Let cmake chew Qt4's translations and resource files + # Let cmake chew Qt5's translations and resource files # Note: header files are MOC-ed automatically by cmake QT5_ADD_TRANSLATION(cockatrice_QM ${cockatrice_TS}) QT5_ADD_RESOURCES(cockatrice_RESOURCES_RCC ${cockatrice_RESOURCES}) + + # guess plugins directory + set(QT_PLUGINS_DIR "${Qt5Widgets_DIR}/../../../plugins") endif() # Declare path variables diff --git a/oracle/CMakeLists.txt b/oracle/CMakeLists.txt index 99abc4d1..b6db8eb4 100644 --- a/oracle/CMakeLists.txt +++ b/oracle/CMakeLists.txt @@ -63,6 +63,9 @@ if(Qt5Widgets_FOUND) include_directories(${Qt5Svg_INCLUDE_DIRS}) list(APPEND ORACLE_LIBS Svg) endif() + + # guess plugins directory + set(QT_PLUGINS_DIR "${Qt5Widgets_DIR}/../../../plugins") endif() INCLUDE_DIRECTORIES(../cockatrice/src) diff --git a/servatrice/CMakeLists.txt b/servatrice/CMakeLists.txt index b1fc00c8..a5743f8e 100644 --- a/servatrice/CMakeLists.txt +++ b/servatrice/CMakeLists.txt @@ -51,6 +51,9 @@ if(Qt5Widgets_FOUND) include_directories(${Qt5Sql_INCLUDE_DIRS}) list(APPEND SERVATRICE_LIBS Sql) endif() + + # guess plugins directory + set(QT_PLUGINS_DIR "${Qt5Widgets_DIR}/../../../plugins") endif() SET(QT_DONT_USE_QTGUI TRUE) From 2354ed6909f18f228152869a7bb34af7a379f700 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Wed, 25 Jun 2014 16:00:48 +0200 Subject: [PATCH 13/32] Require Qt4 >=4.8.0; remove some ifdefs on qt version --- CMakeLists.txt | 2 +- cockatrice/src/carddatabasemodel.cpp | 6 ------ cockatrice/src/decklistmodel.cpp | 6 ------ cockatrice/src/remotedecklist_treewidget.cpp | 6 ------ 4 files changed, 1 insertion(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 16e2f0ee..9c74b40e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -76,7 +76,7 @@ FIND_PACKAGE(Qt5Widgets) IF(Qt5Widgets_FOUND) MESSAGE(STATUS "Found Qt ${Qt5Widgets_VERSION_STRING}") ELSE() - FIND_PACKAGE(Qt4 REQUIRED) + FIND_PACKAGE(Qt4 4.8.0 REQUIRED) IF(Qt4_FOUND) MESSAGE(STATUS "Found Qt ${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH}") ELSE() diff --git a/cockatrice/src/carddatabasemodel.cpp b/cockatrice/src/carddatabasemodel.cpp index 65b08d49..a77bbd12 100644 --- a/cockatrice/src/carddatabasemodel.cpp +++ b/cockatrice/src/carddatabasemodel.cpp @@ -68,9 +68,7 @@ QVariant CardDatabaseModel::headerData(int section, Qt::Orientation orientation, void CardDatabaseModel::updateCardList() { -#if QT_VERSION >= 0x050000 beginResetModel(); -#endif for (int i = 0; i < cardList.size(); ++i) disconnect(cardList[i], 0, this, 0); @@ -79,11 +77,7 @@ void CardDatabaseModel::updateCardList() for (int i = 0; i < cardList.size(); ++i) connect(cardList[i], SIGNAL(cardInfoChanged(CardInfo *)), this, SLOT(cardInfoChanged(CardInfo *))); -#if QT_VERSION < 0x050000 - reset(); -#else endResetModel(); -#endif } void CardDatabaseModel::cardInfoChanged(CardInfo *card) diff --git a/cockatrice/src/decklistmodel.cpp b/cockatrice/src/decklistmodel.cpp index 8a1065f0..de18a9c5 100644 --- a/cockatrice/src/decklistmodel.cpp +++ b/cockatrice/src/decklistmodel.cpp @@ -30,9 +30,7 @@ DeckListModel::~DeckListModel() void DeckListModel::rebuildTree() { -#if QT_VERSION >= 0x050000 beginResetModel(); -#endif root->clearTree(); InnerDecklistNode *listRoot = deckList->getRoot(); @@ -59,11 +57,7 @@ void DeckListModel::rebuildTree() } } -#if QT_VERSION < 0x050000 - reset(); -#else endResetModel(); -#endif } int DeckListModel::rowCount(const QModelIndex &parent) const diff --git a/cockatrice/src/remotedecklist_treewidget.cpp b/cockatrice/src/remotedecklist_treewidget.cpp index 809f3fe8..cb96ef7f 100644 --- a/cockatrice/src/remotedecklist_treewidget.cpp +++ b/cockatrice/src/remotedecklist_treewidget.cpp @@ -258,17 +258,11 @@ void RemoteDeckList_TreeModel::deckListFinished(const Response &r) { const Response_DeckList &resp = r.GetExtension(Response_DeckList::ext); -#if QT_VERSION >= 0x050000 beginResetModel(); -#endif root->clearTree(); -#if QT_VERSION < 0x050000 - reset(); -#else endResetModel(); -#endif ServerInfo_DeckStorage_TreeItem tempRoot; tempRoot.set_id(0); From 4e4401a9e2e2d6366e0c3fb8c1da4abf4034a053 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Wed, 25 Jun 2014 18:39:26 +0200 Subject: [PATCH 14/32] maybe fix travis build for ubuntu --- travis-dependencies.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/travis-dependencies.sh b/travis-dependencies.sh index 533a213b..e9317d2a 100755 --- a/travis-dependencies.sh +++ b/travis-dependencies.sh @@ -5,5 +5,5 @@ if [[ $TRAVIS_OS_NAME == "osx" ]] ; then brew install qt cmake protobuf else sudo apt-get update -qq - sudo apt-get install -y qtmobility-dev libprotobuf-dev protobuf-compiler libqt4-dev + sudo apt-get install -y qtmobility-dev libprotobuf-dev protobuf-compiler libqt4-dev qt4-dev-tools fi From 382a382c70b78a0c582ca52217c4e84addf24d68 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Wed, 25 Jun 2014 18:50:58 +0200 Subject: [PATCH 15/32] Maybe workaround buggy cmake module --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c74b40e..65448a1c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -77,7 +77,7 @@ IF(Qt5Widgets_FOUND) MESSAGE(STATUS "Found Qt ${Qt5Widgets_VERSION_STRING}") ELSE() FIND_PACKAGE(Qt4 4.8.0 REQUIRED) - IF(Qt4_FOUND) + IF(Qt4_FOUND OR QT4_FOUND) MESSAGE(STATUS "Found Qt ${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH}") ELSE() MESSAGE(FATAL_ERROR "No Qt4 or Qt5 found!") From 07ed519a2529c51aa73a899aecfd9a3149538d70 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Wed, 25 Jun 2014 19:12:38 +0200 Subject: [PATCH 16/32] Apply the patch in the previous commit globally --- CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 65448a1c..ed69a67a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -77,7 +77,11 @@ IF(Qt5Widgets_FOUND) MESSAGE(STATUS "Found Qt ${Qt5Widgets_VERSION_STRING}") ELSE() FIND_PACKAGE(Qt4 4.8.0 REQUIRED) - IF(Qt4_FOUND OR QT4_FOUND) + 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}") ELSE() MESSAGE(FATAL_ERROR "No Qt4 or Qt5 found!") From 4e56ceb623e935f049bf6b255ec263814402f47d Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Wed, 25 Jun 2014 19:13:11 +0200 Subject: [PATCH 17/32] revert changes in .travis.yml --- travis-dependencies.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/travis-dependencies.sh b/travis-dependencies.sh index e9317d2a..533a213b 100755 --- a/travis-dependencies.sh +++ b/travis-dependencies.sh @@ -5,5 +5,5 @@ if [[ $TRAVIS_OS_NAME == "osx" ]] ; then brew install qt cmake protobuf else sudo apt-get update -qq - sudo apt-get install -y qtmobility-dev libprotobuf-dev protobuf-compiler libqt4-dev qt4-dev-tools + sudo apt-get install -y qtmobility-dev libprotobuf-dev protobuf-compiler libqt4-dev fi From 62ca6130d16f1c4be26d18c9e15289a4b7d39f5a Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Wed, 25 Jun 2014 19:28:03 +0200 Subject: [PATCH 18/32] #include only for qt5, qt4 has this in QtCore --- oracle/src/oraclewizard.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/oracle/src/oraclewizard.cpp b/oracle/src/oraclewizard.cpp index 4f0e102a..96b78145 100644 --- a/oracle/src/oraclewizard.cpp +++ b/oracle/src/oraclewizard.cpp @@ -3,9 +3,9 @@ #include #else #include + #include #endif #include -#include #include #include #include From 634dd91b665cfd0a544a0525863b11ff2fde6c89 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Thu, 26 Jun 2014 20:19:47 +0200 Subject: [PATCH 19/32] Set some cmake policies to mute cmake warnings --- CMakeLists.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index ed69a67a..b2439806 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,14 @@ cmake_minimum_required(VERSION 2.6) +if(POLICY CMP0043) + cmake_policy(SET CMP0043 OLD) +endif() + +if(POLICY CMP0048) + cmake_policy(SET CMP0048 OLD) +endif() + set(PROJECT_NAME "Cockatrice") set(PROJECT_VERSION_MAJOR 0) set(PROJECT_VERSION_MINOR 0) From 34772cccab9d4db03c681b0a8542220d46cb7d50 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Fri, 27 Jun 2014 17:09:09 +0200 Subject: [PATCH 20/32] Compilation fix for MSVC+Qt5 --- cockatrice/CMakeLists.txt | 14 ++++++++------ oracle/CMakeLists.txt | 10 ++++++---- servatrice/CMakeLists.txt | 11 ++++++++--- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/cockatrice/CMakeLists.txt b/cockatrice/CMakeLists.txt index be347188..08714b07 100644 --- a/cockatrice/CMakeLists.txt +++ b/cockatrice/CMakeLists.txt @@ -224,18 +224,20 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) 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) - TARGET_LINK_LIBRARIES(cockatrice cockatrice_common) + if(MSVC) + TARGET_LINK_LIBRARIES(cockatrice cockatrice_common Qt5::WinMain) + else() + TARGET_LINK_LIBRARIES(cockatrice cockatrice_common) + endif() qt5_use_modules(cockatrice ${COCKATRICE_LIBS}) endif() - -if(MSVC) - set_target_properties(cockatrice PROPERTIES LINK_FLAGS "/SUBSYSTEM:WINDOWS") -endif(MSVC) - if(UNIX) if(APPLE) INSTALL(TARGETS cockatrice BUNDLE DESTINATION ./) diff --git a/oracle/CMakeLists.txt b/oracle/CMakeLists.txt index b6db8eb4..9f713889 100644 --- a/oracle/CMakeLists.txt +++ b/oracle/CMakeLists.txt @@ -74,16 +74,18 @@ INCLUDE_DIRECTORIES(../cockatrice/src) ADD_EXECUTABLE(oracle WIN32 MACOSX_BUNDLE ${oracle_SOURCES} ${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}) endif() -if(MSVC) - set_target_properties(oracle PROPERTIES LINK_FLAGS "/SUBSYSTEM:WINDOWS") -endif(MSVC) - if(UNIX) if(APPLE) INSTALL(TARGETS oracle BUNDLE DESTINATION ./) diff --git a/servatrice/CMakeLists.txt b/servatrice/CMakeLists.txt index a5743f8e..1f548038 100644 --- a/servatrice/CMakeLists.txt +++ b/servatrice/CMakeLists.txt @@ -69,15 +69,20 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) ADD_EXECUTABLE(servatrice MACOSX_BUNDLE ${servatrice_SOURCES} ${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) - TARGET_LINK_LIBRARIES(servatrice cockatrice_common ${LIBGCRYPT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT}) + 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}) endif() - - #add_custom_target(versionheader ALL DEPENDS version_header) add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/version_string.h ${CMAKE_CURRENT_BINARY_DIR}/version_string.cpp From fc8c55ae9761c037f63344bb6783c06923d3e395 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Fri, 27 Jun 2014 17:24:25 +0200 Subject: [PATCH 21/32] Added cmake policy specific for win32 compilation --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index b2439806..1317c483 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,10 @@ cmake_minimum_required(VERSION 2.6) +if(POLICY CMP0020) + cmake_policy(SET CMP0020 OLD) +endif() + if(POLICY CMP0043) cmake_policy(SET CMP0043 OLD) endif() From 096f200eb9f8058a432baf7e54779f0391e0560a Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Fri, 27 Jun 2014 17:40:29 +0200 Subject: [PATCH 22/32] Install libraries and plugins automatically under windows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit You won’t have to copy manually all the dlls in the release directory anymore --- cockatrice/CMakeLists.txt | 37 ++++++++++++++++++++++++++++++++++++- oracle/CMakeLists.txt | 36 +++++++++++++++++++++++++++++++++++- servatrice/CMakeLists.txt | 36 +++++++++++++++++++++++++++++++++++- 3 files changed, 106 insertions(+), 3 deletions(-) diff --git a/cockatrice/CMakeLists.txt b/cockatrice/CMakeLists.txt index 08714b07..53313151 100644 --- a/cockatrice/CMakeLists.txt +++ b/cockatrice/CMakeLists.txt @@ -206,8 +206,10 @@ if(Qt5Widgets_FOUND) QT5_ADD_TRANSLATION(cockatrice_QM ${cockatrice_TS}) QT5_ADD_RESOURCES(cockatrice_RESOURCES_RCC ${cockatrice_RESOURCES}) - # guess plugins directory + # guess plugins and libraries directory set(QT_PLUGINS_DIR "${Qt5Widgets_DIR}/../../../plugins") + get_target_property(QT_LIBRARY_DIR Qt5::Core LOCATION) + get_filename_component(QT_LIBRARY_DIR ${QT_LIBRARY_DIR} PATH) endif() # Declare path variables @@ -292,3 +294,36 @@ Data = Resources\") fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/cockatrice.app\" \"\${QTPLUGINS}\" \"${QT_LIBRARY_DIR}\") " COMPONENT Runtime) endif() + +if(WIN32) + # these needs to be relative to CMAKE_INSTALL_PREFIX + set(plugin_dest_dir Plugins) + set(qtconf_dest_dir .) + + # note: no codecs in qt5 + # note: phonon_backend => mediaservice + # note: needs platform on osx + + if (CMAKE_BUILD_TYPE STREQUAL "Debug") + install(DIRECTORY "${QT_PLUGINS_DIR}/" DESTINATION ${plugin_dest_dir} COMPONENT Runtime + FILES_MATCHING REGEX "(codecs|iconengines|imageformats|mediaservice|phonon_backend|platforms)/.*d\\.dll") + else() + install(DIRECTORY "${QT_PLUGINS_DIR}/" DESTINATION ${plugin_dest_dir} COMPONENT Runtime + FILES_MATCHING REGEX "(codecs|iconengines|imageformats|mediaservice|phonon_backend|platforms)/.*[^d]\\.dll") + endif() + + install(CODE " + file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${qtconf_dest_dir}/qt.conf\" \"[Paths] +Plugins = Plugins +Translations = Resources/translations +Data = Resources\") + " COMPONENT Runtime) + + install(CODE " + file(GLOB_RECURSE QTPLUGINS + \"\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/*.dll\") + set(BU_CHMOD_BUNDLE_ITEMS ON) + include(BundleUtilities) + fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/cockatrice.exe\" \"\${QTPLUGINS}\" \"${QT_LIBRARY_DIR}\") + " COMPONENT Runtime) +endif() \ No newline at end of file diff --git a/oracle/CMakeLists.txt b/oracle/CMakeLists.txt index 9f713889..c3431571 100644 --- a/oracle/CMakeLists.txt +++ b/oracle/CMakeLists.txt @@ -64,8 +64,10 @@ if(Qt5Widgets_FOUND) list(APPEND ORACLE_LIBS Svg) endif() - # guess plugins directory + # guess plugins and libraries directory set(QT_PLUGINS_DIR "${Qt5Widgets_DIR}/../../../plugins") + get_target_property(QT_LIBRARY_DIR Qt5::Core LOCATION) + get_filename_component(QT_LIBRARY_DIR ${QT_LIBRARY_DIR} PATH) endif() INCLUDE_DIRECTORIES(../cockatrice/src) @@ -132,3 +134,35 @@ Translations = Resources/translations\") fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/oracle.app\" \"\${QTPLUGINS}\" \"${QT_LIBRARY_DIR}\") " COMPONENT Runtime) endif() + +IF(WIN32) + # these needs to be relative to CMAKE_INSTALL_PREFIX + set(plugin_dest_dir Plugins) + set(qtconf_dest_dir .) + + # note: no codecs in qt5 + # note: phonon_backend => mediaservice + # note: needs platform on osx + + if (CMAKE_BUILD_TYPE STREQUAL "Debug") + install(DIRECTORY "${QT_PLUGINS_DIR}/" DESTINATION ${plugin_dest_dir} COMPONENT Runtime + FILES_MATCHING REGEX "(codecs|iconengines|imageformats|mediaservice|phonon_backend|platforms)/.*d\\.dll") + else() + install(DIRECTORY "${QT_PLUGINS_DIR}/" DESTINATION ${plugin_dest_dir} COMPONENT Runtime + FILES_MATCHING REGEX "(codecs|iconengines|imageformats|mediaservice|phonon_backend|platforms)/.*[^d]\\.dll") + endif() + + install(CODE " + file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${qtconf_dest_dir}/qt.conf\" \"[Paths] +Plugins = Plugins +Translations = Resources/translations\") + " COMPONENT Runtime) + + install(CODE " + file(GLOB_RECURSE QTPLUGINS + \"\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/*.dll\") + set(BU_CHMOD_BUNDLE_ITEMS ON) + include(BundleUtilities) + fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/oracle.exe\" \"\${QTPLUGINS}\" \"${QT_LIBRARY_DIR}\") + " COMPONENT Runtime) +endif() \ No newline at end of file diff --git a/servatrice/CMakeLists.txt b/servatrice/CMakeLists.txt index 1f548038..1f5383b4 100644 --- a/servatrice/CMakeLists.txt +++ b/servatrice/CMakeLists.txt @@ -52,8 +52,10 @@ if(Qt5Widgets_FOUND) list(APPEND SERVATRICE_LIBS Sql) endif() - # guess plugins directory + # guess plugins and libraries directory set(QT_PLUGINS_DIR "${Qt5Widgets_DIR}/../../../plugins") + get_target_property(QT_LIBRARY_DIR Qt5::Core LOCATION) + get_filename_component(QT_LIBRARY_DIR ${QT_LIBRARY_DIR} PATH) endif() SET(QT_DONT_USE_QTGUI TRUE) @@ -132,3 +134,35 @@ Translations = Resources/translations\") fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/servatrice.app\" \"\${QTPLUGINS}\" \"${QT_LIBRARY_DIR}\") " COMPONENT Runtime) endif() + +if(WIN32) + # these needs to be relative to CMAKE_INSTALL_PREFIX + set(plugin_dest_dir Plugins) + set(qtconf_dest_dir .) + + # note: no codecs in qt5 + # note: phonon_backend => mediaservice + # note: needs platform on osx + + if (CMAKE_BUILD_TYPE STREQUAL "Debug") + install(DIRECTORY "${QT_PLUGINS_DIR}/" DESTINATION ${plugin_dest_dir} COMPONENT Runtime + FILES_MATCHING REGEX "(codecs|iconengines|imageformats|mediaservice|phonon_backend|platforms)/.*d\\.dll") + else() + install(DIRECTORY "${QT_PLUGINS_DIR}/" DESTINATION ${plugin_dest_dir} COMPONENT Runtime + FILES_MATCHING REGEX "(codecs|iconengines|imageformats|mediaservice|phonon_backend|platforms)/.*[^d]\\.dll") + endif() + + install(CODE " + file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${qtconf_dest_dir}/qt.conf\" \"[Paths] +Plugins = Plugins +Translations = Resources/translations\") + " COMPONENT Runtime) + + install(CODE " + file(GLOB_RECURSE QTPLUGINS + \"\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/*.dll\") + set(BU_CHMOD_BUNDLE_ITEMS ON) + include(BundleUtilities) + fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/servatrice.exe\" \"\${QTPLUGINS}\" \"${QT_LIBRARY_DIR}\") + " COMPONENT Runtime) +endif() \ No newline at end of file From d19340a117e165472dfaed1db96ffc98e3aac696 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Fri, 27 Jun 2014 20:21:26 +0200 Subject: [PATCH 23/32] Windows: create nsis package using cake --- CMakeLists.txt | 2 +- nsis/NSIS.template.in | 95 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 nsis/NSIS.template.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 1317c483..8542836a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -139,7 +139,7 @@ elseif(WIN32) set(CPACK_NSIS_HELP_LINK "https://github.com/Daenyth/Cockatrice") set(CPACK_NSIS_URL_INFO_ABOUT "https://github.com/Daenyth/Cockatrice") set(CPACK_NSIS_CONTACT "Daenyth+github@gmail.com") - set(CPACK_NSIS_MODIFY_PATH ON) + set(CPACK_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/nsis") endif() include(CPack) diff --git a/nsis/NSIS.template.in b/nsis/NSIS.template.in new file mode 100644 index 00000000..dde353e9 --- /dev/null +++ b/nsis/NSIS.template.in @@ -0,0 +1,95 @@ +!include "MUI2.nsh" +!include "FileFunc.nsh" + +!define /date TIMESTAMP "%Y%m%d" +!searchparse /file ../../../cockatrice/version_string.cpp '= "' VERSION '";' + +Name "Cockatrice" +OutFile "cockatrice_win32_${TIMESTAMP}_git-${VERSION}.exe" +SetCompressor /SOLID lzma +InstallDir "$PROGRAMFILES\Cockatrice" + +!define MUI_ABORTWARNING +!define MUI_WELCOMEFINISHPAGE_BITMAP "..\..\..\..\nsis\leftimage.bmp" +!define MUI_UNWELCOMEFINISHPAGE_BITMAP "..\..\..\..\nsis\leftimage.bmp" +!define MUI_HEADERIMAGE +!define MUI_HEADERIMAGE_BITMAP "..\..\..\..\nsis\headerimage.bmp" +!define MUI_HEADERIMAGE_UNBITMAP "..\..\..\..\nsis\headerimage.bmp" +!define MUI_WELCOMEPAGE_TEXT "This wizard will guide you through the installation of Cockatrice.$\r$\n$\r$\nClick Next to continue." +!define MUI_FINISHPAGE_RUN "$INSTDIR/oracle.exe" +!define MUI_FINISHPAGE_RUN_TEXT "Run card database downloader now" +!define MUI_FINISHPAGE_RUN_PARAMETERS "-dlsets" + +!insertmacro MUI_PAGE_WELCOME +!insertmacro MUI_PAGE_LICENSE "..\..\..\..\COPYING" +!insertmacro MUI_PAGE_COMPONENTS +!insertmacro MUI_PAGE_DIRECTORY +!insertmacro MUI_PAGE_INSTFILES +!insertmacro MUI_PAGE_FINISH + +!insertmacro MUI_UNPAGE_CONFIRM +!insertmacro MUI_UNPAGE_INSTFILES +!insertmacro MUI_UNPAGE_FINISH + +!insertmacro MUI_LANGUAGE "English" + +Section "Application" SecApplication + SetShellVarContext all + SetOutPath "$INSTDIR" + + File /r ..\..\..\Release\*.* + + WriteUninstaller "$INSTDIR\uninstall.exe" + ${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2 + IntFmt $0 "0x%08X" $0 + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "DisplayName" "Cockatrice" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "UninstallString" "$\"$INSTDIR\uninstall.exe$\"" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "QuietUninstallString" "$\"$INSTDIR\uninstall.exe$\" /S" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "InstallLocation" "$INSTDIR" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "DisplayIcon" "$INSTDIR\cockatrice.exe" + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "EstimatedSize" "$0" +SectionEnd + +Section "Update configuration" SecUpdateConfig + WriteRegStr HKCU "Software\Cockatrice\Cockatrice\paths" "carddatabase" "$APPDATA\Cockatrice\cards.xml" + WriteRegStr HKCU "Software\Cockatrice\Cockatrice\paths" "decks" "$APPDATA\Cockatrice\decks" + WriteRegStr HKCU "Software\Cockatrice\Cockatrice\paths" "pics" "$APPDATA\Cockatrice\pics" + WriteRegStr HKCU "Software\Cockatrice\Cockatrice\sound" "path" "$APPDATA\Cockatrice\sounds" +SectionEnd + +Section "Start menu item" SecStartMenu + createDirectory "$SMPROGRAMS\Cockatrice" + createShortCut "$SMPROGRAMS\Cockatrice\Cockatrice.lnk" "$INSTDIR\cockatrice.exe" '--debug-output' + createShortCut "$SMPROGRAMS\Cockatrice\Oracle.lnk" "$INSTDIR\oracle.exe" + createShortCut "$SMPROGRAMS\Cockatrice\Usermanual.lnk" "$INSTDIR\Usermanual.pdf" +SectionEnd + +Section Uninstall +SetShellVarContext all + RMDir /r "$INSTDIR\zonebg" + RMDir /r "$INSTDIR\plugins" + RMDir /r "$INSTDIR\sounds" + RMDir /r "$INSTDIR\translations" + Delete "$INSTDIR\uninstall.exe" + Delete "$INSTDIR\cockatrice.exe" + Delete "$INSTDIR\oracle.exe" + Delete "$INSTDIR\Usermanual.pdf" + Delete "$INSTDIR\libprotobuf.lib" + Delete "$INSTDIR\Qt*.dll" + RMDir "$INSTDIR" + + RMDir "$SMPROGRAMS\Cockatrice" + + DeleteRegKey HKCU "Software\Cockatrice" + DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" +SectionEnd + +LangString DESC_SecApplication ${LANG_ENGLISH} "Cockatrice program files" +LangString DESC_SecUpdateConfig ${LANG_ENGLISH} "Update the paths in the application settings according to the installation paths." +LangString DESC_SecStartMenu ${LANG_ENGLISH} "Create start menu items for Cockatrice and Oracle." +!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN + !insertmacro MUI_DESCRIPTION_TEXT ${SecApplication} $(DESC_SecApplication) + !insertmacro MUI_DESCRIPTION_TEXT ${SecUpdateConfig} $(DESC_SecUpdateConfig) + !insertmacro MUI_DESCRIPTION_TEXT ${SecStartMenu} $(DESC_SecStartMenu) +!insertmacro MUI_FUNCTION_DESCRIPTION_END + From 803fd7c95d784059014ea687a7855eb460d3e8e7 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Sat, 28 Jun 2014 18:43:18 +0200 Subject: [PATCH 24/32] Windows: Generate an nsis package on the fly with "make package" --- CMakeLists.txt | 6 ++++++ nsis/NSIS.definitions.nsh.in | 3 +++ nsis/NSIS.template.in | 17 +++++++++-------- 3 files changed, 18 insertions(+), 8 deletions(-) create mode 100644 nsis/NSIS.definitions.nsh.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 6f19f769..b8bba102 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -140,6 +140,12 @@ elseif(WIN32) set(CPACK_NSIS_URL_INFO_ABOUT "https://github.com/Daenyth/Cockatrice") set(CPACK_NSIS_CONTACT "Daenyth+github@gmail.com") set(CPACK_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/nsis") + + # Configure file with custom definitions for NSIS. + configure_file( + ${PROJECT_SOURCE_DIR}/nsis/NSIS.definitions.nsh.in + ${PROJECT_BINARY_DIR}/NSIS.definitions.nsh + ) endif() include(CPack) diff --git a/nsis/NSIS.definitions.nsh.in b/nsis/NSIS.definitions.nsh.in new file mode 100644 index 00000000..0d98b666 --- /dev/null +++ b/nsis/NSIS.definitions.nsh.in @@ -0,0 +1,3 @@ +!define NSIS_PROJECT_NAME "@PROJECT_NAME@" +!define NSIS_SOURCE_PATH "@PROJECT_SOURCE_DIR@" +!define NSIS_BINARY_PATH "@PROJECT_BINARY_DIR@" \ No newline at end of file diff --git a/nsis/NSIS.template.in b/nsis/NSIS.template.in index dde353e9..8deb40ea 100644 --- a/nsis/NSIS.template.in +++ b/nsis/NSIS.template.in @@ -1,27 +1,28 @@ +!include ..\..\..\NSIS.definitions.nsh !include "MUI2.nsh" !include "FileFunc.nsh" !define /date TIMESTAMP "%Y%m%d" !searchparse /file ../../../cockatrice/version_string.cpp '= "' VERSION '";' -Name "Cockatrice" -OutFile "cockatrice_win32_${TIMESTAMP}_git-${VERSION}.exe" +Name "${NSIS_PROJECT_NAME}" +OutFile "@CPACK_TOPLEVEL_DIRECTORY@/@CPACK_OUTPUT_FILE_NAME@" SetCompressor /SOLID lzma InstallDir "$PROGRAMFILES\Cockatrice" !define MUI_ABORTWARNING -!define MUI_WELCOMEFINISHPAGE_BITMAP "..\..\..\..\nsis\leftimage.bmp" -!define MUI_UNWELCOMEFINISHPAGE_BITMAP "..\..\..\..\nsis\leftimage.bmp" +!define MUI_WELCOMEFINISHPAGE_BITMAP "${NSIS_SOURCE_PATH}\nsis\leftimage.bmp" +!define MUI_UNWELCOMEFINISHPAGE_BITMAP "${NSIS_SOURCE_PATH}\nsis\leftimage.bmp" !define MUI_HEADERIMAGE -!define MUI_HEADERIMAGE_BITMAP "..\..\..\..\nsis\headerimage.bmp" -!define MUI_HEADERIMAGE_UNBITMAP "..\..\..\..\nsis\headerimage.bmp" +!define MUI_HEADERIMAGE_BITMAP "${NSIS_SOURCE_PATH}\nsis\headerimage.bmp" +!define MUI_HEADERIMAGE_UNBITMAP "${NSIS_SOURCE_PATH}\nsis\headerimage.bmp" !define MUI_WELCOMEPAGE_TEXT "This wizard will guide you through the installation of Cockatrice.$\r$\n$\r$\nClick Next to continue." !define MUI_FINISHPAGE_RUN "$INSTDIR/oracle.exe" !define MUI_FINISHPAGE_RUN_TEXT "Run card database downloader now" !define MUI_FINISHPAGE_RUN_PARAMETERS "-dlsets" !insertmacro MUI_PAGE_WELCOME -!insertmacro MUI_PAGE_LICENSE "..\..\..\..\COPYING" +!insertmacro MUI_PAGE_LICENSE "${NSIS_SOURCE_PATH}\COPYING" !insertmacro MUI_PAGE_COMPONENTS !insertmacro MUI_PAGE_DIRECTORY !insertmacro MUI_PAGE_INSTFILES @@ -37,7 +38,7 @@ Section "Application" SecApplication SetShellVarContext all SetOutPath "$INSTDIR" - File /r ..\..\..\Release\*.* + File /r "${NSIS_BINARY_PATH}\Release\*.*" WriteUninstaller "$INSTDIR\uninstall.exe" ${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2 From e997b1d2bc121f6cec880971e1579788a9938a8f Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Sat, 28 Jun 2014 18:44:19 +0200 Subject: [PATCH 25/32] Windows: drop the old nsis script cpack generates it on the fly from a template --- nsis/cockatrice.nsi | 132 -------------------------------------------- 1 file changed, 132 deletions(-) delete mode 100644 nsis/cockatrice.nsi diff --git a/nsis/cockatrice.nsi b/nsis/cockatrice.nsi deleted file mode 100644 index 27f55ce3..00000000 --- a/nsis/cockatrice.nsi +++ /dev/null @@ -1,132 +0,0 @@ -!include "MUI2.nsh" -!include "FileFunc.nsh" - -!define /date TIMESTAMP "%Y%m%d" -!searchparse /file ../build/cockatrice/version_string.cpp '= "' VERSION '";' - -Name "Cockatrice" -OutFile "cockatrice_win32_${TIMESTAMP}_git-${VERSION}.exe" -SetCompressor /SOLID lzma -InstallDir "$PROGRAMFILES\Cockatrice" - -; set the Qt install dir here (and make sure you use the latest 4.8 version for packaging) -!define QTDIR "C:\Qt\4.8.6" - -!define MUI_ABORTWARNING -!define MUI_WELCOMEFINISHPAGE_BITMAP "leftimage.bmp" -!define MUI_UNWELCOMEFINISHPAGE_BITMAP "leftimage.bmp" -!define MUI_HEADERIMAGE -!define MUI_HEADERIMAGE_BITMAP "headerimage.bmp" -!define MUI_HEADERIMAGE_UNBITMAP "headerimage.bmp" -!define MUI_WELCOMEPAGE_TEXT "This wizard will guide you through the installation of Cockatrice.$\r$\n$\r$\nClick Next to continue." -!define MUI_FINISHPAGE_RUN "$INSTDIR/oracle.exe" -!define MUI_FINISHPAGE_RUN_TEXT "Run card database downloader now" -!define MUI_FINISHPAGE_RUN_PARAMETERS "-dlsets" - -!insertmacro MUI_PAGE_WELCOME -!insertmacro MUI_PAGE_LICENSE "..\COPYING" -!insertmacro MUI_PAGE_COMPONENTS -!insertmacro MUI_PAGE_DIRECTORY -!insertmacro MUI_PAGE_INSTFILES -!insertmacro MUI_PAGE_FINISH - -!insertmacro MUI_UNPAGE_CONFIRM -!insertmacro MUI_UNPAGE_INSTFILES -!insertmacro MUI_UNPAGE_FINISH - -!insertmacro MUI_LANGUAGE "English" - -Section "Application" SecApplication - SetShellVarContext all - SetOutPath "$INSTDIR" - File ..\build\cockatrice\Release\cockatrice.exe - File ..\build\oracle\Release\oracle.exe - File ..\doc\usermanual\Usermanual.pdf - File ..\build\protobuf-2.5.0\protobuf-2.5.0\vsprojects\Release\libprotobuf.lib - File "${QTDIR}\bin\QtCore4.dll" - File "${QTDIR}\bin\QtGui4.dll" - File "${QTDIR}\bin\QtNetwork4.dll" - File "${QTDIR}\bin\QtSvg4.dll" - File "${QTDIR}\bin\QtXml4.dll" - File "${QTDIR}\bin\QtMultimedia4.dll" - - SetOutPath "$INSTDIR\zonebg" - File /r ..\zonebg\*.* - - SetOutPath "$INSTDIR\plugins" - SetOutPath "$INSTDIR\plugins\codecs" - File "${QTDIR}\plugins\codecs\qcncodecs4.dll" - File "${QTDIR}\plugins\codecs\qjpcodecs4.dll" - File "${QTDIR}\plugins\codecs\qkrcodecs4.dll" - File "${QTDIR}\plugins\codecs\qtwcodecs4.dll" - SetOutPath "$INSTDIR\plugins\iconengines" - File "${QTDIR}\plugins\iconengines\qsvgicon4.dll" - SetOutPath "$INSTDIR\plugins\imageformats" - File "${QTDIR}\plugins\imageformats\qjpeg4.dll" - File "${QTDIR}\plugins\imageformats\qsvg4.dll" - - SetOutPath "$INSTDIR\sounds" - File /r ..\sounds\*.* - - SetOutPath "$INSTDIR\translations" - File /r ..\build\cockatrice\*.qm - - WriteUninstaller "$INSTDIR\uninstall.exe" - ${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2 - IntFmt $0 "0x%08X" $0 - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "DisplayName" "Cockatrice" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "UninstallString" "$\"$INSTDIR\uninstall.exe$\"" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "QuietUninstallString" "$\"$INSTDIR\uninstall.exe$\" /S" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "InstallLocation" "$INSTDIR" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "DisplayIcon" "$INSTDIR\cockatrice.exe" - WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "EstimatedSize" "$0" -SectionEnd - -Section "Update configuration" SecUpdateConfig - WriteRegStr HKCU "Software\Cockatrice\Cockatrice\paths" "carddatabase" "$APPDATA\Cockatrice\cards.xml" - WriteRegStr HKCU "Software\Cockatrice\Cockatrice\paths" "decks" "$APPDATA\Cockatrice\decks" - WriteRegStr HKCU "Software\Cockatrice\Cockatrice\paths" "pics" "$APPDATA\Cockatrice\pics" - WriteRegStr HKCU "Software\Cockatrice\Cockatrice\sound" "path" "$APPDATA\Cockatrice\sounds" -SectionEnd - -Section "Start menu item" SecStartMenu - createDirectory "$SMPROGRAMS\Cockatrice" - createShortCut "$SMPROGRAMS\Cockatrice\Cockatrice.lnk" "$INSTDIR\cockatrice.exe" '--debug-output' - createShortCut "$SMPROGRAMS\Cockatrice\Oracle.lnk" "$INSTDIR\oracle.exe" - createShortCut "$SMPROGRAMS\Cockatrice\Usermanual.lnk" "$INSTDIR\Usermanual.pdf" -SectionEnd - -Section Uninstall -SetShellVarContext all - RMDir /r "$INSTDIR\zonebg" - RMDir /r "$INSTDIR\plugins" - RMDir /r "$INSTDIR\sounds" - RMDir /r "$INSTDIR\translations" - Delete "$INSTDIR\uninstall.exe" - Delete "$INSTDIR\cockatrice.exe" - Delete "$INSTDIR\oracle.exe" - Delete "$INSTDIR\Usermanual.pdf" - Delete "$INSTDIR\libprotobuf.lib" - Delete "$INSTDIR\QtCore4.dll" - Delete "$INSTDIR\QtGui4.dll" - Delete "$INSTDIR\QtNetwork4.dll" - Delete "$INSTDIR\QtSvg4.dll" - Delete "$INSTDIR\QtXml4.dll" - Delete "$INSTDIR\QtMultimedia4.dll" - RMDir "$INSTDIR" - - RMDir "$SMPROGRAMS\Cockatrice" - - DeleteRegKey HKCU "Software\Cockatrice" - DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" -SectionEnd - -LangString DESC_SecApplication ${LANG_ENGLISH} "Cockatrice program files" -LangString DESC_SecUpdateConfig ${LANG_ENGLISH} "Update the paths in the application settings according to the installation paths." -LangString DESC_SecStartMenu ${LANG_ENGLISH} "Create start menu items for Cockatrice and Oracle." -!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN - !insertmacro MUI_DESCRIPTION_TEXT ${SecApplication} $(DESC_SecApplication) - !insertmacro MUI_DESCRIPTION_TEXT ${SecUpdateConfig} $(DESC_SecUpdateConfig) - !insertmacro MUI_DESCRIPTION_TEXT ${SecStartMenu} $(DESC_SecStartMenu) -!insertmacro MUI_FUNCTION_DESCRIPTION_END - From fc24ffdec2123e5069debf023d0f215775464f36 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Sat, 28 Jun 2014 19:39:26 +0200 Subject: [PATCH 26/32] Cmake reorganization MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Move all cmake-related files in a new “cmake” folder * move nsis files in there, too, since they are templates parsed by cake * retrieve git version once when cmake is run, and use it for both creating version_string.h/cpp and for package naming --- CMakeLists.txt | 29 ++++++++++----------- {servatrice => cmake}/FindLibgcrypt.cmake | 0 {cockatrice => cmake}/FindQtMobility.cmake | 0 {nsis => cmake}/NSIS.definitions.nsh.in | 0 {nsis => cmake}/NSIS.template.in | 8 +++--- cmake/createversionfile.cmake | 17 ++++++++++++ {common => cmake}/getversion.cmake | 14 ++-------- {nsis => cmake}/headerimage.bmp | Bin {nsis => cmake}/leftimage.bmp | Bin cockatrice/CMakeLists.txt | 10 ++----- servatrice/CMakeLists.txt | 10 +------ 11 files changed, 40 insertions(+), 48 deletions(-) rename {servatrice => cmake}/FindLibgcrypt.cmake (100%) rename {cockatrice => cmake}/FindQtMobility.cmake (100%) rename {nsis => cmake}/NSIS.definitions.nsh.in (100%) rename {nsis => cmake}/NSIS.template.in (92%) create mode 100644 cmake/createversionfile.cmake rename {common => cmake}/getversion.cmake (52%) rename {nsis => cmake}/headerimage.bmp (100%) rename {nsis => cmake}/leftimage.bmp (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index b8bba102..4f95201a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,12 +20,8 @@ if(POLICY CMP0048) endif() set(PROJECT_NAME "Cockatrice") -set(PROJECT_VERSION_MAJOR 0) -set(PROJECT_VERSION_MINOR 0) -set(PROJECT_VERSION_PATCH 1) -set(PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH} ) -# Defualt to "Release" build type +# Default to "Release" build type # User-provided value for CMAKE_BUILD_TYPE must be checked before the PROJECT() call IF(DEFINED CMAKE_BUILD_TYPE) SET(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "Type of build") @@ -36,9 +32,19 @@ ENDIF() # A project name is needed for CPack PROJECT("${PROJECT_NAME}") + # Set conventional loops set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true) +# Search path for cmake modules +SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) + +# Retrieve git version hash +include(getversion) + +# Create a header and a cpp file containing the version hash +include(createversionfile) + # Define a proper install path if(UNIX) if(APPLE) @@ -109,8 +115,8 @@ FIND_PACKAGE(Protobuf REQUIRED) set(CPACK_PACKAGE_CONTACT "Daenyth+github@gmail.com") set(CPACK_PACKAGE_DESCRIPTION_SUMMARY ${PROJECT_NAME}) set(CPACK_PACKAGE_VENDOR "Cockatrice Development Team") -set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md") -set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING") +set(CPACK_PACKAGE_DESCRIPTION_FILE "${PROJECT_SOURCE_DIR}/README.md") +set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/COPYING") set(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}") set(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}") set(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}") @@ -133,17 +139,10 @@ if(UNIX) endif() elseif(WIN32) set(CPACK_GENERATOR NSIS ${CPACK_GENERATOR}) - set(CPACK_PACKAGE_INSTALL_DIRECTORY "${PROJECT_NAME}\\\\${PROJECT_VERSION}") - set(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\${PROJECT_NAME}.exe") - set(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} ${PROJECT_NAME}") - set(CPACK_NSIS_HELP_LINK "https://github.com/Daenyth/Cockatrice") - set(CPACK_NSIS_URL_INFO_ABOUT "https://github.com/Daenyth/Cockatrice") - set(CPACK_NSIS_CONTACT "Daenyth+github@gmail.com") - set(CPACK_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/nsis") # Configure file with custom definitions for NSIS. configure_file( - ${PROJECT_SOURCE_DIR}/nsis/NSIS.definitions.nsh.in + ${CMAKE_MODULE_PATH}/NSIS.definitions.nsh.in ${PROJECT_BINARY_DIR}/NSIS.definitions.nsh ) endif() diff --git a/servatrice/FindLibgcrypt.cmake b/cmake/FindLibgcrypt.cmake similarity index 100% rename from servatrice/FindLibgcrypt.cmake rename to cmake/FindLibgcrypt.cmake diff --git a/cockatrice/FindQtMobility.cmake b/cmake/FindQtMobility.cmake similarity index 100% rename from cockatrice/FindQtMobility.cmake rename to cmake/FindQtMobility.cmake diff --git a/nsis/NSIS.definitions.nsh.in b/cmake/NSIS.definitions.nsh.in similarity index 100% rename from nsis/NSIS.definitions.nsh.in rename to cmake/NSIS.definitions.nsh.in diff --git a/nsis/NSIS.template.in b/cmake/NSIS.template.in similarity index 92% rename from nsis/NSIS.template.in rename to cmake/NSIS.template.in index 8deb40ea..ed28a165 100644 --- a/nsis/NSIS.template.in +++ b/cmake/NSIS.template.in @@ -11,11 +11,11 @@ SetCompressor /SOLID lzma InstallDir "$PROGRAMFILES\Cockatrice" !define MUI_ABORTWARNING -!define MUI_WELCOMEFINISHPAGE_BITMAP "${NSIS_SOURCE_PATH}\nsis\leftimage.bmp" -!define MUI_UNWELCOMEFINISHPAGE_BITMAP "${NSIS_SOURCE_PATH}\nsis\leftimage.bmp" +!define MUI_WELCOMEFINISHPAGE_BITMAP "${NSIS_SOURCE_PATH}\cmake\leftimage.bmp" +!define MUI_UNWELCOMEFINISHPAGE_BITMAP "${NSIS_SOURCE_PATH}\cmake\leftimage.bmp" !define MUI_HEADERIMAGE -!define MUI_HEADERIMAGE_BITMAP "${NSIS_SOURCE_PATH}\nsis\headerimage.bmp" -!define MUI_HEADERIMAGE_UNBITMAP "${NSIS_SOURCE_PATH}\nsis\headerimage.bmp" +!define MUI_HEADERIMAGE_BITMAP "${NSIS_SOURCE_PATH}\cmake\headerimage.bmp" +!define MUI_HEADERIMAGE_UNBITMAP "${NSIS_SOURCE_PATH}\cmake\headerimage.bmp" !define MUI_WELCOMEPAGE_TEXT "This wizard will guide you through the installation of Cockatrice.$\r$\n$\r$\nClick Next to continue." !define MUI_FINISHPAGE_RUN "$INSTDIR/oracle.exe" !define MUI_FINISHPAGE_RUN_TEXT "Run card database downloader now" diff --git a/cmake/createversionfile.cmake b/cmake/createversionfile.cmake new file mode 100644 index 00000000..b71aa8ad --- /dev/null +++ b/cmake/createversionfile.cmake @@ -0,0 +1,17 @@ +set(VERSION_STRING_CPP "${PROJECT_BINARY_DIR}/version_string.cpp") +set(VERSION_STRING_H "${PROJECT_BINARY_DIR}/version_string.h") +INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR}) + +set( hstring "extern const char *VERSION_STRING\;\n" ) +set( cppstring "const char * VERSION_STRING = \"${PROJECT_VERSION}\"\;\n") + +file(WRITE ${PROJECT_BINARY_DIR}/version_string.cpp.txt ${cppstring} ) +file(WRITE ${PROJECT_BINARY_DIR}/version_string.h.txt ${hstring} ) + +execute_process( + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PROJECT_BINARY_DIR}/version_string.h.txt ${VERSION_STRING_H} +) +execute_process( + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PROJECT_BINARY_DIR}/version_string.cpp.txt ${VERSION_STRING_CPP} +) + diff --git a/common/getversion.cmake b/cmake/getversion.cmake similarity index 52% rename from common/getversion.cmake rename to cmake/getversion.cmake index ec5fe753..9db61040 100644 --- a/common/getversion.cmake +++ b/cmake/getversion.cmake @@ -15,15 +15,5 @@ else() message( WARNING "Git not found. Build will not contain git revision info." ) endif() -set( hstring "extern const char *VERSION_STRING\;\n" ) -set( cppstring "const char * VERSION_STRING = \"${GIT_COMMIT_ID}\"\;\n") - -file(WRITE version_string.cpp.txt ${cppstring} ) -file(WRITE version_string.h.txt ${hstring} ) - -execute_process( - COMMAND ${CMAKE_COMMAND} -E copy_if_different version_string.h.txt ${CMAKE_CURRENT_BINARY_DIR}/version_string.h -) -execute_process( - COMMAND ${CMAKE_COMMAND} -E copy_if_different version_string.cpp.txt ${CMAKE_CURRENT_BINARY_DIR}/version_string.cpp -) +set(PROJECT_VERSION_MAJOR ${GIT_COMMIT_ID}) +set(PROJECT_VERSION ${GIT_COMMIT_ID} ) \ No newline at end of file diff --git a/nsis/headerimage.bmp b/cmake/headerimage.bmp similarity index 100% rename from nsis/headerimage.bmp rename to cmake/headerimage.bmp diff --git a/nsis/leftimage.bmp b/cmake/leftimage.bmp similarity index 100% rename from nsis/leftimage.bmp rename to cmake/leftimage.bmp diff --git a/cockatrice/CMakeLists.txt b/cockatrice/CMakeLists.txt index 53313151..f785b1fd 100644 --- a/cockatrice/CMakeLists.txt +++ b/cockatrice/CMakeLists.txt @@ -90,7 +90,7 @@ SET(cockatrice_SOURCES src/qt-json/json.cpp src/soundengine.cpp src/pending_command.cpp - ${CMAKE_CURRENT_BINARY_DIR}/version_string.cpp + ${VERSION_STRING_CPP} ) if (UNIX AND NOT APPLE) @@ -130,9 +130,8 @@ set(COCKATRICE_LIBS) # Qt4 stuff if(Qt4_FOUND) if (NOT QT_QTMULTIMEDIA_FOUND) - SET(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}) FIND_PACKAGE(QtMobility REQUIRED) - endif (NOT QT_QTMULTIMEDIA_FOUND) + endif() SET(QT_USE_QTNETWORK TRUE) SET(QT_USE_QTMULTIMEDIA TRUE) @@ -257,11 +256,6 @@ elseif(WIN32) INSTALL(FILES ${cockatrice_QM} DESTINATION ./translations) endif() -add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/version_string.cpp ${CMAKE_CURRENT_BINARY_DIR}/version_string.h - COMMAND ${CMAKE_COMMAND} -DSOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} -P ${CMAKE_CURRENT_SOURCE_DIR}/../common/getversion.cmake -) - if(APPLE) # these needs to be relative to CMAKE_INSTALL_PREFIX set(plugin_dest_dir cockatrice.app/Contents/Plugins) diff --git a/servatrice/CMakeLists.txt b/servatrice/CMakeLists.txt index 1f5383b4..42e2bb74 100644 --- a/servatrice/CMakeLists.txt +++ b/servatrice/CMakeLists.txt @@ -4,8 +4,6 @@ PROJECT(servatrice) -# cmake module for libgcrypt is included in current directory -SET(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}) FIND_PACKAGE(Libgcrypt REQUIRED) SET(servatrice_SOURCES @@ -17,7 +15,7 @@ SET(servatrice_SOURCES src/server_logger.cpp src/serversocketinterface.cpp src/isl_interface.cpp - ${CMAKE_CURRENT_BINARY_DIR}/version_string.cpp + ${VERSION_STRING_CPP} ) set(SERVATRICE_LIBS) @@ -85,12 +83,6 @@ if(Qt5Widgets_FOUND) qt5_use_modules(servatrice ${SERVATRICE_LIBS}) endif() -#add_custom_target(versionheader ALL DEPENDS version_header) -add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/version_string.h ${CMAKE_CURRENT_BINARY_DIR}/version_string.cpp - COMMAND ${CMAKE_COMMAND} -DSOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} -P ${CMAKE_CURRENT_SOURCE_DIR}/../common/getversion.cmake -) - # install rules if(UNIX) if(APPLE) From fc5a193e0dc707562d1fefe88b684cd921f95152 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Sat, 28 Jun 2014 19:39:47 +0200 Subject: [PATCH 27/32] NSIS: remove additional files on uninstall --- cmake/NSIS.template.in | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmake/NSIS.template.in b/cmake/NSIS.template.in index ed28a165..e9607466 100644 --- a/cmake/NSIS.template.in +++ b/cmake/NSIS.template.in @@ -77,6 +77,9 @@ SetShellVarContext all Delete "$INSTDIR\Usermanual.pdf" Delete "$INSTDIR\libprotobuf.lib" Delete "$INSTDIR\Qt*.dll" + Delete "$INSTDIR\icu*.dll" + Delete "$INSTDIR\qt.conf" + Delete "$INSTDIR\qdebug.txt" RMDir "$INSTDIR" RMDir "$SMPROGRAMS\Cockatrice" From 3509df76b769eef4c35e6d27e19842ae5f3ace34 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Sat, 28 Jun 2014 19:48:51 +0200 Subject: [PATCH 28/32] Remove old version parsing from nsis script --- cmake/NSIS.template.in | 3 --- 1 file changed, 3 deletions(-) diff --git a/cmake/NSIS.template.in b/cmake/NSIS.template.in index e9607466..b2c60d11 100644 --- a/cmake/NSIS.template.in +++ b/cmake/NSIS.template.in @@ -2,9 +2,6 @@ !include "MUI2.nsh" !include "FileFunc.nsh" -!define /date TIMESTAMP "%Y%m%d" -!searchparse /file ../../../cockatrice/version_string.cpp '= "' VERSION '";' - Name "${NSIS_PROJECT_NAME}" OutFile "@CPACK_TOPLEVEL_DIRECTORY@/@CPACK_OUTPUT_FILE_NAME@" SetCompressor /SOLID lzma From c0981a174324e693eb986c0bb1bd29bd185631bd Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Sat, 28 Jun 2014 19:53:15 +0200 Subject: [PATCH 29/32] Prettier package name --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4f95201a..8101be12 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -128,7 +128,7 @@ if(UNIX) set(CPACK_DMG_FORMAT "UDBZ") set(CPACK_DMG_VOLUME_NAME "${PROJECT_NAME}") set(CPACK_SYSTEM_NAME "OSX") - set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PROJECT_VERSION}") + set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-osx_git-${PROJECT_VERSION}") set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/cockatrice/resources/appicon.icns") else() # linux @@ -139,6 +139,7 @@ if(UNIX) endif() elseif(WIN32) set(CPACK_GENERATOR NSIS ${CPACK_GENERATOR}) + set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}_win32_git-${PROJECT_VERSION}") # Configure file with custom definitions for NSIS. configure_file( From 523483bccc504bae63e1c120895cc1bf1e59293f Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Mon, 30 Jun 2014 22:10:29 +0200 Subject: [PATCH 30/32] Add a WITH_QT4 cmake option to force the use of Qt4 --- CMakeLists.txt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2eb5fac1..7cb17317 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -89,8 +89,14 @@ IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") ADD_DEFINITIONS("-DSFMT_MEXP=19937") ENDIF() -#Find Qt and enable the needed features -FIND_PACKAGE(Qt5Widgets) +# Find Qt and enable the needed features +# Default is Qt5 unless WITH_QT4 option is enabled +option(WITH_QT4 "Force thr use of Qt4 libraries" OFF) + +IF(NOT WITH_QT4) + FIND_PACKAGE(Qt5Widgets) +ENDIF() + IF(Qt5Widgets_FOUND) MESSAGE(STATUS "Found Qt ${Qt5Widgets_VERSION_STRING}") ELSE() From 04ad73fcdc5f52e523743c95145f4b0bf03e9609 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Sun, 6 Jul 2014 23:25:44 +0200 Subject: [PATCH 31/32] Workaround for qt5 version compiled with -reduce-relocations --- CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7cb17317..825ed5cb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -99,6 +99,11 @@ ENDIF() IF(Qt5Widgets_FOUND) MESSAGE(STATUS "Found Qt ${Qt5Widgets_VERSION_STRING}") + + if(UNIX AND NOT APPLE AND "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64") + # FIX: Qt was built with -reduce-relocations + add_definitions(-fPIC) + endif() ELSE() FIND_PACKAGE(Qt4 4.8.0 REQUIRED) IF(QT4_FOUND) From d894c5326566d5ba56925cfed0358c8cd787da3c Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Tue, 8 Jul 2014 22:05:06 +0200 Subject: [PATCH 32/32] Servatrice: fix handling of incoming connections on qt5 --- servatrice/src/servatrice.cpp | 4 ++++ servatrice/src/servatrice.h | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/servatrice/src/servatrice.cpp b/servatrice/src/servatrice.cpp index 87eada78..30c88cfd 100644 --- a/servatrice/src/servatrice.cpp +++ b/servatrice/src/servatrice.cpp @@ -78,7 +78,11 @@ 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; diff --git a/servatrice/src/servatrice.h b/servatrice/src/servatrice.h index fbfac035..2b991512 100644 --- a/servatrice/src/servatrice.h +++ b/servatrice/src/servatrice.h @@ -52,7 +52,11 @@ 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 {