This commit is contained in:
tooomm 2026-07-06 16:34:03 +00:00 committed by GitHub
commit 5565348006
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
65 changed files with 147 additions and 635 deletions

View file

@ -188,6 +188,8 @@ if [[ $RUNNER_OS == macOS ]]; then
# we use find to get the first subfolder with the name "macos" # we use find to get the first subfolder with the name "macos"
# this works independent of the qt version as there should be only one version installed on the runner at a time # this works independent of the qt version as there should be only one version installed on the runner at a time
export QTDIR export QTDIR
# Add QTDIR to CMAKE_PREFIX_PATH so CMake can find Qt6
export CMAKE_PREFIX_PATH="$QTDIR:$CMAKE_PREFIX_PATH"
if [[ $TARGET_MACOS_VERSION ]]; then if [[ $TARGET_MACOS_VERSION ]]; then
# CMAKE_OSX_DEPLOYMENT_TARGET is a vanilla cmake flag needed to compile to target macOS version # CMAKE_OSX_DEPLOYMENT_TARGET is a vanilla cmake flag needed to compile to target macOS version

View file

@ -31,7 +31,7 @@ if [[ ! -e $FILE ]]; then
fi fi
# print version # print version
if ! lupdate -version; then if ! /usr/lib/qt6/bin/lupdate -version; then
echo "failed to run lupdate" >&2 echo "failed to run lupdate" >&2
exit 4; exit 4;
fi fi
@ -39,7 +39,7 @@ fi
# run lupdate, duplicating the output in stderr and saving it # run lupdate, duplicating the output in stderr and saving it
# for convenience we ignore that $DIRS will be split on spaces # for convenience we ignore that $DIRS will be split on spaces
# shellcheck disable=SC2086 # shellcheck disable=SC2086
if ! got="$(lupdate $DIRS -ts "$FILE" | tee /dev/stderr)"; then if ! got="$(/usr/lib/qt6/bin/lupdate $DIRS -ts "$FILE" | tee /dev/stderr)"; then
echo "failed to update $FILE with $DIRS" >&2 echo "failed to update $FILE with $DIRS" >&2
exit 4; exit 4;
fi fi

View file

@ -26,13 +26,13 @@ jobs:
shell: bash shell: bash
run: | run: |
sudo apt-get update sudo apt-get update
sudo apt-get install -y --no-install-recommends qttools5-dev-tools sudo apt-get install -y --no-install-recommends qt6-l10n-tools
- name: "Update Cockatrice translation source" - name: "Update Cockatrice translation source"
env:
FILE: cockatrice/cockatrice_en@source.ts
id: cockatrice id: cockatrice
shell: bash shell: bash
env:
FILE: cockatrice/cockatrice_en@source.ts
run: > run: >
DIRS="cockatrice/src $(find . -maxdepth 1 -type d -name 'libcockatrice_*')" DIRS="cockatrice/src $(find . -maxdepth 1 -type d -name 'libcockatrice_*')"
.ci/update_translation_source_strings.sh .ci/update_translation_source_strings.sh

View file

@ -5,8 +5,7 @@
# This file sets all the variables shared between the projects # This file sets all the variables shared between the projects
# like the installation path, compilation flags etc.. # like the installation path, compilation flags etc..
# cmake 3.16 is required if using qt6 cmake_minimum_required(VERSION 3.25)
cmake_minimum_required(VERSION 3.10)
# Early detect ccache # Early detect ccache
option(USE_CCACHE "Cache the build results with ccache" ON) option(USE_CCACHE "Cache the build results with ccache" ON)
@ -52,22 +51,20 @@ if(WIN32 OR USE_VCPKG)
# Use vcpkg toolchain on Windows (and on macOS in CI) # Use vcpkg toolchain on Windows (and on macOS in CI)
set(CMAKE_TOOLCHAIN_FILE set(CMAKE_TOOLCHAIN_FILE
${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake ${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake
CACHE STRING "Vcpkg toolchain file" CACHE FILEPATH "Vcpkg toolchain file"
)
# Qt path set by user or env var
if(QTDIR
OR DEFINED ENV{QTDIR}
OR DEFINED ENV{QTDIR32}
OR DEFINED ENV{QTDIR64}
) )
else() # Show warning if QTDIR is NOT defined
if(NOT QTDIR
AND NOT DEFINED ENV{QTDIR}
AND NOT DEFINED ENV{QTDIR64}
)
set(QTDIR set(QTDIR
"" ""
CACHE PATH "Path to Qt (e.g. C:/Qt/5.7/msvc2015_64)" CACHE PATH "Path to Qt (e.g. C:/Qt/5.7/msvc2015_64)"
) )
message( message(
WARNING "QTDIR variable is missing. Please set this variable to specify path to Qt (e.g. C:/Qt/5.7/msvc2015_64)" WARNING "QTDIR variable is missing. Please set this variable to specify path to Qt (e.g. C:/Qt/5.7/msvc2015_64)"
) )
endif() endif()
endif() endif()
@ -151,7 +148,7 @@ if(MSVC)
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF /OPT:ICF") set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF /OPT:ICF")
add_compile_definitions(_SILENCE_STDEXT_ARR_ITERS_DEPRECATION_WARNING) add_compile_definitions(_SILENCE_STDEXT_ARR_ITERS_DEPRECATION_WARNING)
elseif(CMAKE_COMPILER_IS_GNUCXX) elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# linux/gcc, bsd/gcc, windows/mingw # linux/gcc, bsd/gcc, windows/mingw
include(CheckCXXCompilerFlag) include(CheckCXXCompilerFlag)
@ -174,7 +171,7 @@ elseif(CMAKE_COMPILER_IS_GNUCXX)
-Wno-error=delete-non-virtual-dtor -Wno-error=delete-non-virtual-dtor
-Wno-error=sign-compare -Wno-error=sign-compare
-Wno-error=missing-declarations -Wno-error=missing-declarations
-Wno-error=sfinae-incomplete # GCC 16+: Qt MOC + protobuf forward decls trigger this -Wno-error=sfinae-incomplete # GCC 16+: Qt MOC + protobuf forward decls trigger this
) )
foreach(FLAG ${ADDITIONAL_DEBUG_FLAGS}) foreach(FLAG ${ADDITIONAL_DEBUG_FLAGS})
@ -200,19 +197,8 @@ endif()
find_package(Threads REQUIRED) find_package(Threads REQUIRED)
# Determine 32 or 64 bit build if(DEFINED QTDIR)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(_lib_suffix 64)
else()
set(_lib_suffix 32)
endif()
if(DEFINED QTDIR${_lib_suffix})
list(APPEND CMAKE_PREFIX_PATH "${QTDIR${_lib_suffix}}")
elseif(DEFINED QTDIR)
list(APPEND CMAKE_PREFIX_PATH "${QTDIR}") list(APPEND CMAKE_PREFIX_PATH "${QTDIR}")
elseif(DEFINED ENV{QTDIR${_lib_suffix}})
list(APPEND CMAKE_PREFIX_PATH "$ENV{QTDIR${_lib_suffix}}")
elseif(DEFINED ENV{QTDIR}) elseif(DEFINED ENV{QTDIR})
list(APPEND CMAKE_PREFIX_PATH "$ENV{QTDIR}") list(APPEND CMAKE_PREFIX_PATH "$ENV{QTDIR}")
endif() endif()
@ -221,9 +207,12 @@ message(STATUS "Update Translations: ${UPDATE_TRANSLATIONS}")
include(FindQtRuntime) include(FindQtRuntime)
find_package(Qt6 6.4 REQUIRED)
set(CMAKE_AUTOMOC TRUE) set(CMAKE_AUTOMOC TRUE)
# Find other needed libraries ## Find other needed libraries
# Find Protobuf
find_package(Protobuf CONFIG) find_package(Protobuf CONFIG)
if(NOT Protobuf_FOUND) if(NOT Protobuf_FOUND)
find_package(Protobuf REQUIRED) find_package(Protobuf REQUIRED)
@ -233,7 +222,7 @@ if(${Protobuf_VERSION} VERSION_LESS "3.21.0.0" AND NOT EXISTS "${Protobuf_PROTOC
message(FATAL_ERROR "No protoc command found!") message(FATAL_ERROR "No protoc command found!")
endif() endif()
#Find OpenSSL # Find OpenSSL
if(WIN32) if(WIN32)
find_package(OpenSSL REQUIRED) find_package(OpenSSL REQUIRED)
if(OPENSSL_FOUND) if(OPENSSL_FOUND)
@ -246,7 +235,7 @@ if(WIN32)
endif() endif()
endif() endif()
#Find VCredist # Find VCredist
if(MSVC) if(MSVC)
find_package(VCredistRuntime) find_package(VCredistRuntime)
endif() endif()
@ -282,8 +271,6 @@ if(UNIX)
set(CPACK_RPM_MAIN_COMPONENT "cockatrice") set(CPACK_RPM_MAIN_COMPONENT "cockatrice")
if(Qt6_FOUND) if(Qt6_FOUND)
set(CPACK_RPM_PACKAGE_REQUIRES "protobuf, qt6-qttools, qt6-qtsvg, qt6-qtmultimedia, qt6-qtimageformats") set(CPACK_RPM_PACKAGE_REQUIRES "protobuf, qt6-qttools, qt6-qtsvg, qt6-qtmultimedia, qt6-qtimageformats")
elseif(Qt5_FOUND)
set(CPACK_RPM_PACKAGE_REQUIRES "protobuf, qt5-qttools, qt5-qtsvg, qt5-qtmultimedia")
endif() endif()
set(CPACK_RPM_PACKAGE_GROUP "Amusements/Games") set(CPACK_RPM_PACKAGE_GROUP "Amusements/Games")
set(CPACK_RPM_PACKAGE_URL "http://github.com/Cockatrice/Cockatrice") set(CPACK_RPM_PACKAGE_URL "http://github.com/Cockatrice/Cockatrice")
@ -305,8 +292,6 @@ if(UNIX)
if(Qt6_FOUND) if(Qt6_FOUND)
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libqt6multimedia6, libqt6svg6, qt6-qpa-plugins, qt6-image-formats-plugins") set(CPACK_DEBIAN_PACKAGE_DEPENDS "libqt6multimedia6, libqt6svg6, qt6-qpa-plugins, qt6-image-formats-plugins")
set(CPACK_DEBIAN_PACKAGE_RECOMMENDS "libqt6sql6-mysql") # for connecting servatrice to a mysql db set(CPACK_DEBIAN_PACKAGE_RECOMMENDS "libqt6sql6-mysql") # for connecting servatrice to a mysql db
elseif(Qt5_FOUND)
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libqt5multimedia5-plugins, libqt5svg5")
endif() endif()
endif() endif()
endif() endif()
@ -367,7 +352,6 @@ if(TEST)
add_subdirectory(tests) add_subdirectory(tests)
endif() endif()
if(Qt6_FOUND AND Qt6_VERSION_MINOR GREATER_EQUAL 3) if(Qt6_FOUND)
# Qt6.3+ requires project finalization to support translations
qt6_finalize_project() qt6_finalize_project()
endif() endif()

View file

@ -158,7 +158,6 @@ The following flags (with their non-default values) can be passed to `cmake`:
| `-DWARNING_AS_ERROR=0` | Don't treat compilation warnings as errors in debug mode | | `-DWARNING_AS_ERROR=0` | Don't treat compilation warnings as errors in debug mode |
| `-DUPDATE_TRANSLATIONS=1` | Configure `make` to update the translation .ts files for new strings in the source code<br> **Note:** `make clean` will remove the .ts files | | `-DUPDATE_TRANSLATIONS=1` | Configure `make` to update the translation .ts files for new strings in the source code<br> **Note:** `make clean` will remove the .ts files |
| `-DTEST=1` | Enable regression tests<br> **Note:** `make test` to run tests, *googletest* will be downloaded if not available | | `-DTEST=1` | Enable regression tests<br> **Note:** `make test` to run tests, *googletest* will be downloaded if not available |
| `-DFORCE_USE_QT5=1` | Skip looking for Qt6 before trying to find Qt5 |
# Run # Run

View file

@ -1,8 +1,7 @@
# Find a compatible Qt version # Find a compatible Qt version
# Inputs: WITH_SERVER, WITH_CLIENT, WITH_ORACLE, FORCE_USE_QT5 # Inputs: WITH_SERVER, WITH_CLIENT, WITH_ORACLE
# Optional Input: QT6_DIR -- Hint as to where Qt6 lives on the system # Optional Input: QT6_DIR -- Hint as to where Qt6 lives on the system
# Optional Input: QT5_DIR -- Hint as to where Qt5 lives on the system # Output: COCKATRICE_QT_VERSION_NAME -- Example values: Qt6
# Output: COCKATRICE_QT_VERSION_NAME -- Example values: Qt5, Qt6
# Output: SERVATRICE_QT_MODULES # Output: SERVATRICE_QT_MODULES
# Output: COCKATRICE_QT_MODULES # Output: COCKATRICE_QT_MODULES
# Output: ORACLE_QT_MODULES # Output: ORACLE_QT_MODULES
@ -39,54 +38,32 @@ set(REQUIRED_QT_COMPONENTS ${REQUIRED_QT_COMPONENTS} ${_SERVATRICE_NEEDED} ${_CO
) )
list(REMOVE_DUPLICATES REQUIRED_QT_COMPONENTS) list(REMOVE_DUPLICATES REQUIRED_QT_COMPONENTS)
if(NOT FORCE_USE_QT5) # Find Qt and all required components, as well as Linguist
# Linguist is now a component in Qt6 instead of an external package find_package(
find_package( Qt6
Qt6 6.4.2 COMPONENTS ${REQUIRED_QT_COMPONENTS} Linguist
COMPONENTS ${REQUIRED_QT_COMPONENTS} Linguist QUIET HINTS ${Qt6_DIR}
QUIET HINTS ${Qt6_DIR} )
)
endif()
if(Qt6_FOUND) if(Qt6_FOUND)
set(COCKATRICE_QT_VERSION_NAME Qt6) set(COCKATRICE_QT_VERSION_NAME Qt6)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
list(FIND Qt6LinguistTools_TARGETS Qt6::lrelease QT6_LRELEASE_INDEX) if(Qt6LinguistTools_FOUND)
if(QT6_LRELEASE_INDEX EQUAL -1) list(FIND Qt6LinguistTools_TARGETS Qt6::lrelease QT6_LRELEASE_INDEX)
message(WARNING "Qt6 lrelease not found.") if(QT6_LRELEASE_INDEX EQUAL -1)
endif() message(WARNING "Qt6 lrelease not found.")
list(FIND Qt6LinguistTools_TARGETS Qt6::lupdate QT6_LUPDATE_INDEX)
if(QT6_LUPDATE_INDEX EQUAL -1)
message(WARNING "Qt6 lupdate not found.")
endif()
else()
find_package(
Qt5 5.15.2
COMPONENTS ${REQUIRED_QT_COMPONENTS}
QUIET HINTS ${Qt5_DIR}
)
if(Qt5_FOUND)
set(COCKATRICE_QT_VERSION_NAME Qt5)
else()
message(FATAL_ERROR "No suitable version of Qt was found")
endif()
# Qt5 Linguist is in a separate package
find_package(Qt5LinguistTools QUIET)
if(Qt5LinguistTools_FOUND)
if(NOT Qt5_LRELEASE_EXECUTABLE)
message(WARNING "Qt5 lrelease not found.")
endif() endif()
if(NOT Qt5_LUPDATE_EXECUTABLE)
message(WARNING "Qt5 lupdate not found.") list(FIND Qt6LinguistTools_TARGETS Qt6::lupdate QT6_LUPDATE_INDEX)
if(QT6_LUPDATE_INDEX EQUAL -1)
message(WARNING "Qt6 lupdate not found.")
endif() endif()
else() else()
message(WARNING "Linguist Tools not found, cannot handle translations") message(WARNING "Linguist Tools not found, cannot handle translations")
endif() endif()
endif() else()
message(FATAL_ERROR "Qt6 not found")
if(Qt5_POSITION_INDEPENDENT_CODE OR Qt6_FOUND)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif() endif()
# Establish Qt Plugins directory & Library directories # Establish Qt Plugins directory & Library directories
@ -99,9 +76,6 @@ if(Qt6_FOUND)
# Mac needs a bit more help finding all necessary components # Mac needs a bit more help finding all necessary components
list(APPEND QT_LIBRARY_DIR "/usr/local/lib") list(APPEND QT_LIBRARY_DIR "/usr/local/lib")
endif() endif()
elseif(Qt5_FOUND)
get_filename_component(QT_PLUGINS_DIR "${Qt5Core_DIR}/../../../plugins" ABSOLUTE)
get_filename_component(QT_LIBRARY_DIR "${QT_LIBRARY_DIR}/.." ABSOLUTE)
endif() endif()
message(DEBUG "QT_PLUGINS_DIR = ${QT_PLUGINS_DIR}") message(DEBUG "QT_PLUGINS_DIR = ${QT_PLUGINS_DIR}")
message(DEBUG "QT_LIBRARY_DIR = ${QT_LIBRARY_DIR}") message(DEBUG "QT_LIBRARY_DIR = ${QT_LIBRARY_DIR}")

View file

@ -57,21 +57,13 @@ Page Custom PortableModePageCreate PortableModePageLeave
Function .onInit Function .onInit
${If} ${NSIS_IS_64_BIT} == 1 #NSIS 64bit ${If} ${NSIS_IS_64_BIT} == 1 # NSIS 64bit
${IfNot} ${RunningX64} ${IfNot} ${RunningX64}
MessageBox MB_OK|MB_ICONSTOP "This version of Cockatrice requires a 64-bit Windows system." MessageBox MB_OK|MB_ICONSTOP "This version of Cockatrice requires a 64-bit Windows system."
Abort Abort
${EndIf} ${EndIf}
StrCpy $NormalDestDir "$ProgramFiles64\Cockatrice" StrCpy $NormalDestDir "$ProgramFiles64\Cockatrice"
SetRegView 64 SetRegView 64
${Else} #NSIS 32bit
${If} ${RunningX64}
MessageBox MB_OK|MB_ICONEXCLAMATION \
"You are about to install a 32-bit version of Cockatrice on a 64-bit Windows system.$\n\
We advise you to use the correct 64-bit installer instead to get around potential issues.$\n$\n\
Download from our webpage: https://cockatrice.github.io"
${EndIf}
StrCpy $NormalDestDir "$ProgramFiles\Cockatrice"
${EndIf} ${EndIf}
StrCpy $PortableDestDir "$Desktop\CockatricePortable" StrCpy $PortableDestDir "$Desktop\CockatricePortable"
@ -156,7 +148,6 @@ ${If} $8 != "admin"
${EndIf} ${EndIf}
FunctionEnd FunctionEnd
Function SetModeDestinationFromInstdir Function SetModeDestinationFromInstdir
${If} $PortableMode = 0 ${If} $PortableMode = 0
StrCpy $NormalDestDir $InstDir StrCpy $NormalDestDir $InstDir
@ -175,27 +166,14 @@ Function AutoUninstallIfNeeded
SetShellVarContext all SetShellVarContext all
; --- 32-bit uninstall --- SetRegView 64
SetRegView 32
ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "QuietUninstallString" ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "QuietUninstallString"
StrCmp $R0 "" done32 StrCmp $R0 "" done64
DetailPrint "Removing previous version (32-bit)..." DetailPrint "Removing previous version..."
ExecWait '$R0' ExecWait '$R0'
done32: done64:
; --- 64-bit uninstall ---
${If} ${RunningX64}
SetRegView 64
ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "QuietUninstallString"
StrCmp $R0 "" done64
DetailPrint "Removing previous version (64-bit)..."
ExecWait '$R0'
done64:
${EndIf}
FunctionEnd FunctionEnd
@ -244,45 +222,23 @@ ${EndIf}
${If} $PortableMode = 0 ${If} $PortableMode = 0
SetShellVarContext all SetShellVarContext all
# uninstall 32bit version SetRegView 64
SetRegView 32
ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "UninstallString" ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "UninstallString"
StrCmp $R0 "" done32 StrCmp $R0 "" done64
${If} $ReinstallMode = 0 ${If} $ReinstallMode = 0
MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION "A previous version of Cockatrice must be uninstalled before installing the new one." IDOK uninst32 MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION "A previous version of Cockatrice must be uninstalled before installing the new one." IDOK uninst64
Abort Abort
${Else} ${Else}
Goto uninst32 Goto uninst64
${EndIf} ${EndIf}
uninst32: uninst64:
ClearErrors ClearErrors
ExecWait "$R0" ExecWait "$R0"
done32: done64:
# uninstall 64bit version
${If} ${NSIS_IS_64_BIT} == 1
SetRegView 64
ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "UninstallString"
StrCmp $R0 "" done64
${If} $ReinstallMode = 0
MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION "A previous version of Cockatrice must be uninstalled before installing the new one." IDOK uninst64
Abort
${Else}
Goto uninst64
${EndIf}
uninst64:
ClearErrors
ExecWait "$R0"
done64:
${EndIf}
${Else} ${Else}
Abort Abort
@ -296,70 +252,62 @@ SetOutPath "$INSTDIR"
${If} $PortableMode = 1 ${If} $PortableMode = 1
${AndIf} ${FileExists} "$INSTDIR\portable.dat" ${AndIf} ${FileExists} "$INSTDIR\portable.dat"
; upgrade portable mode ; upgrade portable mode
RMDir /r "$INSTDIR\plugins" RMDir /r "$INSTDIR\plugins"
RMDir /r "$INSTDIR\sounds" RMDir /r "$INSTDIR\sounds"
RMDir /r "$INSTDIR\themes" RMDir /r "$INSTDIR\themes"
RMDir /r "$INSTDIR\translations" RMDir /r "$INSTDIR\translations"
Delete "$INSTDIR\uninstall.exe" Delete "$INSTDIR\uninstall.exe"
Delete "$INSTDIR\cockatrice.exe" Delete "$INSTDIR\cockatrice.exe"
Delete "$INSTDIR\oracle.exe" Delete "$INSTDIR\oracle.exe"
Delete "$INSTDIR\servatrice.exe" Delete "$INSTDIR\servatrice.exe"
Delete "$INSTDIR\Qt*.dll" Delete "$INSTDIR\Qt*.dll"
Delete "$INSTDIR\libmysql.dll" Delete "$INSTDIR\libmysql.dll"
Delete "$INSTDIR\icu*.dll" Delete "$INSTDIR\icu*.dll"
Delete "$INSTDIR\libeay32.dll" Delete "$INSTDIR\libeay32.dll"
Delete "$INSTDIR\ssleay32.dll" Delete "$INSTDIR\ssleay32.dll"
Delete "$INSTDIR\qt.conf" Delete "$INSTDIR\qt.conf"
Delete "$INSTDIR\qdebug.txt" Delete "$INSTDIR\qdebug.txt"
Delete "$INSTDIR\servatrice.sql" Delete "$INSTDIR\servatrice.sql"
Delete "$INSTDIR\servatrice.ini.example" Delete "$INSTDIR\servatrice.ini.example"
Delete "$INSTDIR\zlib*.dll" Delete "$INSTDIR\zlib*.dll"
RMDir "$INSTDIR" RMDir "$INSTDIR"
${EndIf} ${EndIf}
@CPACK_NSIS_EXTRA_PREINSTALL_COMMANDS@ @CPACK_NSIS_EXTRA_PREINSTALL_COMMANDS@
@CPACK_NSIS_FULL_INSTALL@ @CPACK_NSIS_FULL_INSTALL@
${If} $PortableMode = 0 ${If} $PortableMode = 0
WriteUninstaller "$INSTDIR\uninstall.exe" WriteUninstaller "$INSTDIR\uninstall.exe"
${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2 ${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2
IntFmt $0 "0x%08X" $0 IntFmt $0 "0x%08X" $0
; Enable Windows User-Mode Dumps ; Enable Windows User-Mode Dumps
; https://learn.microsoft.com/en-us/windows/win32/wer/collecting-user-mode-dumps ; https://learn.microsoft.com/en-us/windows/win32/wer/collecting-user-mode-dumps
WriteRegExpandStr HKLM "Software\Microsoft\Windows\Windows Error Reporting\LocalDumps\cockatrice.exe" "DumpFolder" "%LOCALAPPDATA%\CrashDumps\Cockatrice" WriteRegExpandStr HKLM "Software\Microsoft\Windows\Windows Error Reporting\LocalDumps\cockatrice.exe" "DumpFolder" "%LOCALAPPDATA%\CrashDumps\Cockatrice"
WriteRegDWORD HKLM "Software\Microsoft\Windows\Windows Error Reporting\LocalDumps\cockatrice.exe" "DumpCount" "5" WriteRegDWORD HKLM "Software\Microsoft\Windows\Windows Error Reporting\LocalDumps\cockatrice.exe" "DumpCount" "5"
WriteRegDWORD HKLM "Software\Microsoft\Windows\Windows Error Reporting\LocalDumps\cockatrice.exe" "DumpType" "2" WriteRegDWORD HKLM "Software\Microsoft\Windows\Windows Error Reporting\LocalDumps\cockatrice.exe" "DumpType" "2"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "DisplayIcon" "$INSTDIR\cockatrice.exe" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "DisplayIcon" "$INSTDIR\cockatrice.exe"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "DisplayName" "Cockatrice" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "DisplayName" "Cockatrice"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "DisplayVersion" "@CPACK_PACKAGE_VERSION_MAJOR@.@CPACK_PACKAGE_VERSION_MINOR@.@CPACK_PACKAGE_VERSION_PATCH@" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "DisplayVersion" "@CPACK_PACKAGE_VERSION_MAJOR@.@CPACK_PACKAGE_VERSION_MINOR@.@CPACK_PACKAGE_VERSION_PATCH@"
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "EstimatedSize" "$0" WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "EstimatedSize" "$0"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "InstallLocation" "$INSTDIR" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "InstallLocation" "$INSTDIR"
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "NoModify" "1" WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "NoModify" "1"
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "NoRepair" "1" WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "NoRepair" "1"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "Publisher" "Cockatrice team" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "Publisher" "Cockatrice team"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "QuietUninstallString" "$\"$INSTDIR\uninstall.exe$\" /S" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "QuietUninstallString" "$\"$INSTDIR\uninstall.exe$\" /S"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "UninstallString" "$\"$INSTDIR\uninstall.exe$\"" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "UninstallString" "$\"$INSTDIR\uninstall.exe$\""
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "VersionMajor" "@CPACK_PACKAGE_VERSION_MAJOR@" WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "VersionMajor" "@CPACK_PACKAGE_VERSION_MAJOR@"
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "VersionMinor" "@CPACK_PACKAGE_VERSION_MINOR@" WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "VersionMinor" "@CPACK_PACKAGE_VERSION_MINOR@"
IfFileExists "$INSTDIR\vc_redist.x86.exe" VcRedist86Exists PastVcRedist86Check IfFileExists "$INSTDIR\vc_redist.x64.exe" VcRedist64Exists PastVcRedist64Check
VcRedist86Exists: VcRedist64Exists:
ExecWait '"$INSTDIR\vc_redist.x86.exe" /passive /norestart' ExecWait '"$INSTDIR\vc_redist.x64.exe" /passive /norestart'
DetailPrint "Wait to ensure unlock of vc_redist file after installation..." DetailPrint "Sleep to ensure unlock of vc_redist file after installation..."
Sleep 3000 Sleep 3000
Delete "$INSTDIR\vc_redist.x86.exe" Delete "$INSTDIR\vc_redist.x64.exe"
PastVcRedist86Check: PastVcRedist64Check:
IfFileExists "$INSTDIR\vc_redist.x64.exe" VcRedist64Exists PastVcRedist64Check
VcRedist64Exists:
ExecWait '"$INSTDIR\vc_redist.x64.exe" /passive /norestart'
DetailPrint "Sleep to ensure unlock of vc_redist file after installation..."
Sleep 3000
Delete "$INSTDIR\vc_redist.x64.exe"
PastVcRedist64Check:
${Else} ${Else}
; Create the file the application uses to detect portable mode ; Create the file the application uses to detect portable mode
@ -377,51 +325,51 @@ SectionEnd
Section "Start menu item" SecStartMenu Section "Start menu item" SecStartMenu
${If} $PortableMode = 0 ${If} $PortableMode = 0
SetShellVarContext all SetShellVarContext all
createDirectory "$SMPROGRAMS\Cockatrice" createDirectory "$SMPROGRAMS\Cockatrice"
createShortCut "$SMPROGRAMS\Cockatrice\Cockatrice.lnk" "$INSTDIR\cockatrice.exe" createShortCut "$SMPROGRAMS\Cockatrice\Cockatrice.lnk" "$INSTDIR\cockatrice.exe"
createShortCut "$SMPROGRAMS\Cockatrice\Oracle.lnk" "$INSTDIR\oracle.exe" createShortCut "$SMPROGRAMS\Cockatrice\Oracle.lnk" "$INSTDIR\oracle.exe"
createShortCut "$SMPROGRAMS\Cockatrice\Servatrice.lnk" "$INSTDIR\servatrice.exe" createShortCut "$SMPROGRAMS\Cockatrice\Servatrice.lnk" "$INSTDIR\servatrice.exe"
${EndIf} ${EndIf}
SectionEnd SectionEnd
Section "un.Application" UnSecApplication Section "un.Application" UnSecApplication
SetShellVarContext all SetShellVarContext all
RMDir /r "$INSTDIR\plugins" RMDir /r "$INSTDIR\plugins"
RMDir /r "$INSTDIR\sounds" RMDir /r "$INSTDIR\sounds"
RMDir /r "$INSTDIR\themes" RMDir /r "$INSTDIR\themes"
RMDir /r "$INSTDIR\translations" RMDir /r "$INSTDIR\translations"
Delete "$INSTDIR\*.exe" Delete "$INSTDIR\*.exe"
Delete "$INSTDIR\*.dll" Delete "$INSTDIR\*.dll"
Delete "$INSTDIR\qt.conf" Delete "$INSTDIR\qt.conf"
Delete "$INSTDIR\qdebug.txt" Delete "$INSTDIR\qdebug.txt"
Delete "$INSTDIR\servatrice.sql" Delete "$INSTDIR\servatrice.sql"
Delete "$INSTDIR\servatrice.ini.example" Delete "$INSTDIR\servatrice.ini.example"
RMDir "$INSTDIR" RMDir "$INSTDIR"
RMDir "$SMPROGRAMS\Cockatrice" RMDir "$SMPROGRAMS\Cockatrice"
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice"
SectionEnd SectionEnd
; unselected because it is /o ; unselected because it is /o
Section /o "un.Configurations, decks, cards, pics" UnSecConfiguration Section /o "un.Configurations, decks, cards, pics" UnSecConfiguration
SetShellVarContext current SetShellVarContext current
DeleteRegKey HKCU "Software\Cockatrice" DeleteRegKey HKCU "Software\Cockatrice"
RMDir /r "$LOCALAPPDATA\Cockatrice" RMDir /r "$LOCALAPPDATA\Cockatrice"
SectionEnd SectionEnd
LangString DESC_SecApplication ${LANG_ENGLISH} "Cockatrice program files" LangString DESC_SecApplication ${LANG_ENGLISH} "Cockatrice program files"
LangString DESC_SecStartMenu ${LANG_ENGLISH} "Create start menu items for Cockatrice and Oracle." LangString DESC_SecStartMenu ${LANG_ENGLISH} "Create start menu items for Cockatrice and Oracle."
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${SecApplication} $(DESC_SecApplication) !insertmacro MUI_DESCRIPTION_TEXT ${SecApplication} $(DESC_SecApplication)
!insertmacro MUI_DESCRIPTION_TEXT ${SecStartMenu} $(DESC_SecStartMenu) !insertmacro MUI_DESCRIPTION_TEXT ${SecStartMenu} $(DESC_SecStartMenu)
!insertmacro MUI_FUNCTION_DESCRIPTION_END !insertmacro MUI_FUNCTION_DESCRIPTION_END
LangString DESC_UnSecApplication ${LANG_ENGLISH} "Cockatrice program files and start menu items" LangString DESC_UnSecApplication ${LANG_ENGLISH} "Cockatrice program files and start menu items"
LangString DESC_UnSecConfiguration ${LANG_ENGLISH} "Configurations, decks, card database, pictures" LangString DESC_UnSecConfiguration ${LANG_ENGLISH} "Configurations, decks, card database, pictures"
!insertmacro MUI_UNFUNCTION_DESCRIPTION_BEGIN !insertmacro MUI_UNFUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${UnSecApplication} $(DESC_UnSecApplication) !insertmacro MUI_DESCRIPTION_TEXT ${UnSecApplication} $(DESC_UnSecApplication)
!insertmacro MUI_DESCRIPTION_TEXT ${UnSecConfiguration} $(DESC_UnSecConfiguration) !insertmacro MUI_DESCRIPTION_TEXT ${UnSecConfiguration} $(DESC_UnSecConfiguration)
!insertmacro MUI_UNFUNCTION_DESCRIPTION_END !insertmacro MUI_UNFUNCTION_DESCRIPTION_END

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.10) cmake_minimum_required(VERSION 3.16)
project(gtest-download LANGUAGES NONE) project(gtest-download LANGUAGES NONE)

View file

@ -401,8 +401,6 @@ endif(APPLE)
if(Qt6_FOUND) if(Qt6_FOUND)
qt6_add_resources(cockatrice_RESOURCES_RCC ${cockatrice_RESOURCES}) qt6_add_resources(cockatrice_RESOURCES_RCC ${cockatrice_RESOURCES})
elseif(Qt5_FOUND)
qt5_add_resources(cockatrice_RESOURCES_RCC ${cockatrice_RESOURCES})
endif() endif()
# Declare path variables # Declare path variables
@ -429,44 +427,7 @@ if(Qt6_FOUND)
${cockatrice_MOC_SRCS} ${cockatrice_MOC_SRCS}
MANUAL_FINALIZATION MANUAL_FINALIZATION
) )
elseif(Qt5_FOUND)
# Qt5 Translations need to be linked at executable creation time
if(Qt5LinguistTools_FOUND)
if(UPDATE_TRANSLATIONS)
qt5_create_translation(cockatrice_QM ${translate_SRCS} ${cockatrice_TS})
else()
qt5_add_translation(cockatrice_QM ${cockatrice_TS})
endif()
endif()
add_executable(
cockatrice WIN32 MACOSX_BUNDLE ${cockatrice_MOC_SRCS} ${cockatrice_QM} ${cockatrice_RESOURCES_RCC}
${cockatrice_SOURCES}
)
if(UNIX)
if(APPLE)
install(FILES ${cockatrice_QM} DESTINATION ${COCKATRICE_MAC_QM_INSTALL_DIR})
else()
install(FILES ${cockatrice_QM} DESTINATION ${COCKATRICE_UNIX_QM_INSTALL_DIR})
endif()
elseif(WIN32)
install(FILES ${cockatrice_QM} DESTINATION ${COCKATRICE_WIN32_QM_INSTALL_DIR})
endif()
endif()
if(Qt5_FOUND)
target_link_libraries(
cockatrice
libcockatrice_card
libcockatrice_deck_list
libcockatrice_filters
libcockatrice_utility
libcockatrice_network
libcockatrice_models
libcockatrice_rng
libcockatrice_settings
${COCKATRICE_QT_MODULES}
)
else()
target_link_libraries( target_link_libraries(
cockatrice cockatrice
PUBLIC libcockatrice_card PUBLIC libcockatrice_card
@ -509,7 +470,7 @@ if(APPLE)
set(plugin_dest_dir cockatrice.app/Contents/Plugins) set(plugin_dest_dir cockatrice.app/Contents/Plugins)
set(qtconf_dest_dir cockatrice.app/Contents/Resources) set(qtconf_dest_dir cockatrice.app/Contents/Resources)
# Qt plugins: audio (Qt5), iconengines, imageformats, multimedia (Qt6), platforms, printsupport (Qt5), styles, tls (Qt6) # Qt plugins: iconengines, imageformats, multimedia (Qt6), platforms, styles, tls (Qt6)
install( install(
DIRECTORY "${QT_PLUGINS_DIR}/" DIRECTORY "${QT_PLUGINS_DIR}/"
DESTINATION ${plugin_dest_dir} DESTINATION ${plugin_dest_dir}
@ -517,12 +478,10 @@ if(APPLE)
FILES_MATCHING FILES_MATCHING
PATTERN "*.dSYM" EXCLUDE PATTERN "*.dSYM" EXCLUDE
PATTERN "*_debug.dylib" EXCLUDE PATTERN "*_debug.dylib" EXCLUDE
PATTERN "audio/*.dylib"
PATTERN "iconengines/*.dylib" PATTERN "iconengines/*.dylib"
PATTERN "imageformats/*.dylib" PATTERN "imageformats/*.dylib"
PATTERN "multimedia/*.dylib" PATTERN "multimedia/*.dylib"
PATTERN "platforms/*.dylib" PATTERN "platforms/*.dylib"
PATTERN "printsupport/*.dylib"
PATTERN "styles/*.dylib" PATTERN "styles/*.dylib"
PATTERN "tls/*.dylib" PATTERN "tls/*.dylib"
) )
@ -576,14 +535,12 @@ if(WIN32)
PATTERN "*.ini" PATTERN "*.ini"
) )
# Qt plugins: audio (Qt5), iconengines, imageformats, multimedia (Qt6) platforms, printsupport (Qt5), styles, tls (Qt6) # Qt plugins: iconengines, imageformats, multimedia (Qt6) platforms, styles, tls (Qt6)
install( install(
DIRECTORY "${QT_PLUGINS_DIR}/" DIRECTORY "${QT_PLUGINS_DIR}/"
DESTINATION ${plugin_dest_dir} DESTINATION ${plugin_dest_dir}
COMPONENT Runtime COMPONENT Runtime
FILES_MATCHING FILES_MATCHING
PATTERN "audio/qtaudio_wasapi.dll"
PATTERN "audio/qtaudio_windows.dll"
PATTERN "iconengines/qsvgicon.dll" PATTERN "iconengines/qsvgicon.dll"
PATTERN "imageformats/*.dll" PATTERN "imageformats/*.dll"
PATTERN "mediaservice/dsengine.dll" PATTERN "mediaservice/dsengine.dll"
@ -593,7 +550,6 @@ if(WIN32)
PATTERN "platforms/qminimal.dll" PATTERN "platforms/qminimal.dll"
PATTERN "platforms/qoffscreen.dll" PATTERN "platforms/qoffscreen.dll"
PATTERN "platforms/qwindows.dll" PATTERN "platforms/qwindows.dll"
PATTERN "printsupport/windowsprintersupport.dll"
PATTERN "styles/qcertonlybackend.dll" PATTERN "styles/qcertonlybackend.dll"
PATTERN "styles/qopensslbackend.dll" PATTERN "styles/qopensslbackend.dll"
PATTERN "styles/qschannelbackend.dll" PATTERN "styles/qschannelbackend.dll"

View file

@ -59,7 +59,7 @@ bool ReleaseChannel::downloadMatchesCurrentOS(const QString &fileName)
char arch[255]; char arch[255];
size_t len = sizeof(arch); size_t len = sizeof(arch);
if (sysctlbyname("machdep.cpu.brand_string", arch, &len, nullptr, 0) == 0) { if (sysctlbyname("machdep.cpu.brand_string", arch, &len, nullptr, 0) == 0) {
// Intel mac is only supported on macOS 13 versions // Intel Mac is only supported on macOS 13 versions
if (QString::fromUtf8(arch).contains("Intel")) { if (QString::fromUtf8(arch).contains("Intel")) {
return 13; return 13;
} }
@ -74,13 +74,9 @@ bool ReleaseChannel::downloadMatchesCurrentOS(const QString &fileName)
return rel_maj == sys_maj; return rel_maj == sys_maj;
#elif defined(Q_OS_WIN) #elif defined(Q_OS_WIN)
#if Q_PROCESSOR_WORDSIZE == 4 #if Q_PROCESSOR_WORDSIZE == 8 // 64-bit
return fileName.contains("32bit");
#elif Q_PROCESSOR_WORDSIZE == 8
const QString &version = QSysInfo::productVersion(); const QString &version = QSysInfo::productVersion();
if (version.startsWith("7") || version.startsWith("8")) { if (version.startsWith("10")) {
return fileName.contains("Win7");
} else {
return fileName.contains("Win10"); return fileName.contains("Win10");
} }
#else #else

View file

@ -2,13 +2,10 @@
#include "settings/cache_settings.h" #include "settings/cache_settings.h"
#include <QAudioOutput>
#include <QDir> #include <QDir>
#include <QMediaPlayer> #include <QMediaPlayer>
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
#include <QAudioOutput>
#endif
#define DEFAULT_THEME_NAME "Default" #define DEFAULT_THEME_NAME "Default"
#define TEST_SOUND_FILENAME "player_join" #define TEST_SOUND_FILENAME "player_join"
@ -40,10 +37,8 @@ void SoundEngine::soundEnabledChanged()
qCInfo(SoundEngineLog) << "SoundEngine: enabling sound with" << audioData.size() << "sounds"; qCInfo(SoundEngineLog) << "SoundEngine: enabling sound with" << audioData.size() << "sounds";
if (!player) { if (!player) {
player = new QMediaPlayer; player = new QMediaPlayer;
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
audioOutput = new QAudioOutput(player); audioOutput = new QAudioOutput(player);
player->setAudioOutput(audioOutput); player->setAudioOutput(audioOutput);
#endif
} }
} else { } else {
qCInfo(SoundEngineLog) << "SoundEngine: disabling sound"; qCInfo(SoundEngineLog) << "SoundEngine: disabling sound";
@ -71,13 +66,8 @@ void SoundEngine::playSound(const QString &fileName)
player->stop(); player->stop();
int volumeSliderValue = SettingsCache::instance().getMasterVolume(); int volumeSliderValue = SettingsCache::instance().getMasterVolume();
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
player->audioOutput()->setVolume(qreal(volumeSliderValue) / 100); player->audioOutput()->setVolume(qreal(volumeSliderValue) / 100);
player->setSource(QUrl::fromLocalFile(audioData[fileName])); player->setSource(QUrl::fromLocalFile(audioData[fileName]));
#else
player->setVolume(volumeSliderValue);
player->setMedia(QUrl::fromLocalFile(audioData[fileName]));
#endif
player->play(); player->play();
} }

View file

@ -1352,11 +1352,7 @@ void PlayerActions::actSetPT(QList<CardItem *> selectedCards, const QString &pt)
const auto oldpt = CardItem::parsePT(card->getPT()); const auto oldpt = CardItem::parsePT(card->getPT());
int ptIter = 0; int ptIter = 0;
for (const auto &_item : ptList) { for (const auto &_item : ptList) {
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
if (_item.typeId() == QMetaType::Type::Int) { if (_item.typeId() == QMetaType::Type::Int) {
#else
if (_item.type() == QVariant::Int) {
#endif
int oldItem = ptIter < oldpt.size() ? oldpt.at(ptIter).toInt() : 0; int oldItem = ptIter < oldpt.size() ? oldpt.at(ptIter).toInt() : 0;
newpt += '/' + QString::number(oldItem + _item.toInt()); newpt += '/' + QString::number(oldItem + _item.toInt());
} else { } else {

View file

@ -25,11 +25,7 @@ bool PlayerListItemDelegate::editorEvent(QEvent *event,
if ((event->type() == QEvent::MouseButtonPress) && index.isValid()) { if ((event->type() == QEvent::MouseButtonPress) && index.isValid()) {
auto *const mouseEvent = static_cast<QMouseEvent *>(event); auto *const mouseEvent = static_cast<QMouseEvent *>(event);
if (mouseEvent->button() == Qt::RightButton) { if (mouseEvent->button() == Qt::RightButton) {
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
static_cast<PlayerListWidget *>(parent())->showContextMenu(mouseEvent->globalPosition().toPoint(), index); static_cast<PlayerListWidget *>(parent())->showContextMenu(mouseEvent->globalPosition().toPoint(), index);
#else
static_cast<PlayerListWidget *>(parent())->showContextMenu(mouseEvent->globalPos(), index);
#endif
return true; return true;
} }
} }

View file

@ -66,9 +66,8 @@ QList<TallyRow> countSubtypes(const QList<CardItem *> &cards)
}); });
// convert entries into TallyRows // convert entries into TallyRows
QList<TallyRow> rows; QList<TallyRow> rows = QList<TallyRow>(entries.size());
rows.reserve(entries.size()); // for backwards compatibility with Qt5 std::transform(entries.begin(), entries.end(), rows.begin(),
std::transform(entries.begin(), entries.end(), std::back_inserter(rows),
[](const SubtypeEntry &e) { return TallyRow{e.name, QString::number(e.count)}; }); [](const SubtypeEntry &e) { return TallyRow{e.name, QString::number(e.count)}; });
return rows; return rows;

View file

@ -312,13 +312,7 @@ bool CardPictureLoader::hasCustomArt()
// Check if there is at least one non-directory file in the pics path, other // Check if there is at least one non-directory file in the pics path, other
// than in the "downloadedPics" subdirectory. // than in the "downloadedPics" subdirectory.
while (it.hasNext()) { while (it.hasNext()) {
#if (QT_VERSION >= QT_VERSION_CHECK(6, 3, 0))
QFileInfo dir(it.nextFileInfo()); QFileInfo dir(it.nextFileInfo());
#else
// nextFileInfo() is only available in Qt 6.3+, for previous versions, we build
// the QFileInfo from a QString which requires more system calls.
QFileInfo dir(it.next());
#endif
if (it.fileName() == "downloadedPics") { if (it.fileName() == "downloadedPics") {
continue; continue;

View file

@ -246,11 +246,7 @@ QSize CardInfoPictureWidget::sizeHint() const
* @brief Starts the hover timer to show the enlarged pixmap on hover. * @brief Starts the hover timer to show the enlarged pixmap on hover.
* @param event The enter event. * @param event The enter event.
*/ */
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
void CardInfoPictureWidget::enterEvent(QEnterEvent *event) void CardInfoPictureWidget::enterEvent(QEnterEvent *event)
#else
void CardInfoPictureWidget::enterEvent(QEvent *event)
#endif
{ {
QWidget::enterEvent(event); // Call the base class implementation QWidget::enterEvent(event); // Call the base class implementation

View file

@ -48,11 +48,7 @@ signals:
protected: protected:
void resizeEvent(QResizeEvent *event) override; void resizeEvent(QResizeEvent *event) override;
void paintEvent(QPaintEvent *) override; void paintEvent(QPaintEvent *) override;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) void enterEvent(QEnterEvent *event) override;
void enterEvent(QEnterEvent *event) override; // Qt6 signature
#else
void enterEvent(QEvent *event) override; // Qt5 signature
#endif
void leaveEvent(QEvent *event) override; void leaveEvent(QEvent *event) override;
void moveEvent(QMoveEvent *event) override; void moveEvent(QMoveEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override; void mouseMoveEvent(QMouseEvent *event) override;

View file

@ -147,11 +147,7 @@ bool ResizablePanel::eventFilter(QObject *obj, QEvent *event)
if (event->type() == QEvent::MouseButtonPress) { if (event->type() == QEvent::MouseButtonPress) {
auto *mouseEvent = static_cast<QMouseEvent *>(event); auto *mouseEvent = static_cast<QMouseEvent *>(event);
if (mouseEvent->button() == Qt::LeftButton) { if (mouseEvent->button() == Qt::LeftButton) {
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
dragStartPos = mouseEvent->globalPosition().toPoint(); dragStartPos = mouseEvent->globalPosition().toPoint();
#else
dragStartPos = mouseEvent->globalPos();
#endif
isDraggingPanel = false; isDraggingPanel = false;
dragButton->setCursor(Qt::ClosedHandCursor); dragButton->setCursor(Qt::ClosedHandCursor);
} }
@ -159,11 +155,7 @@ bool ResizablePanel::eventFilter(QObject *obj, QEvent *event)
} else if (event->type() == QEvent::MouseMove) { } else if (event->type() == QEvent::MouseMove) {
auto *mouseEvent = static_cast<QMouseEvent *>(event); auto *mouseEvent = static_cast<QMouseEvent *>(event);
if (mouseEvent->buttons() & Qt::LeftButton) { if (mouseEvent->buttons() & Qt::LeftButton) {
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QPoint currentPos = mouseEvent->globalPosition().toPoint(); QPoint currentPos = mouseEvent->globalPosition().toPoint();
#else
QPoint currentPos = mouseEvent->globalPos();
#endif
int distance = (currentPos - dragStartPos).manhattanLength(); int distance = (currentPos - dragStartPos).manhattanLength();
if (distance >= 5 && !isDraggingPanel) { if (distance >= 5 && !isDraggingPanel) {
isDraggingPanel = true; isDraggingPanel = true;
@ -182,22 +174,14 @@ bool ResizablePanel::eventFilter(QObject *obj, QEvent *event)
if (obj == resizeHandle) { if (obj == resizeHandle) {
if (event->type() == QEvent::MouseButtonPress) { if (event->type() == QEvent::MouseButtonPress) {
auto *mouseEvent = static_cast<QMouseEvent *>(event); auto *mouseEvent = static_cast<QMouseEvent *>(event);
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
resizeStartY = mouseEvent->globalPosition().y(); resizeStartY = mouseEvent->globalPosition().y();
#else
resizeStartY = mouseEvent->globalPos().y();
#endif
isResizing = true; isResizing = true;
resizeStartHeight = currentHeight; resizeStartHeight = currentHeight;
resizeHandle->grabMouse(); resizeHandle->grabMouse();
return true; return true;
} else if (event->type() == QEvent::MouseMove && isResizing) { } else if (event->type() == QEvent::MouseMove && isResizing) {
auto *mouseEvent = static_cast<QMouseEvent *>(event); auto *mouseEvent = static_cast<QMouseEvent *>(event);
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
int deltaY = mouseEvent->globalPosition().y() - resizeStartY; int deltaY = mouseEvent->globalPosition().y() - resizeStartY;
#else
int deltaY = mouseEvent->globalPos().y() - resizeStartY;
#endif
int newHeight = resizeStartHeight + deltaY; int newHeight = resizeStartHeight + deltaY;
int minAllowed = getMinimumAllowedHeight(); int minAllowed = getMinimumAllowedHeight();
@ -221,11 +205,7 @@ void ResizablePanel::dragEnterEvent(QDragEnterEvent *event)
{ {
if (event->mimeData()->hasFormat("application/x-resizablepanel")) { if (event->mimeData()->hasFormat("application/x-resizablepanel")) {
event->acceptProposedAction(); event->acceptProposedAction();
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
showDropIndicator(event->position().y()); showDropIndicator(event->position().y());
#else
showDropIndicator(event->pos().y());
#endif
} }
} }
@ -233,13 +213,8 @@ void ResizablePanel::dragMoveEvent(QDragMoveEvent *event)
{ {
if (event->mimeData()->hasFormat("application/x-resizablepanel")) { if (event->mimeData()->hasFormat("application/x-resizablepanel")) {
event->acceptProposedAction(); event->acceptProposedAction();
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
showDropIndicator(event->position().y()); showDropIndicator(event->position().y());
lastDragPos = mapToGlobal(event->position().toPoint()); lastDragPos = mapToGlobal(event->position().toPoint());
#else
showDropIndicator(event->pos().y());
lastDragPos = mapToGlobal(event->pos());
#endif
if (!autoScrollTimer->isActive()) { if (!autoScrollTimer->isActive()) {
autoScrollTimer->start(); autoScrollTimer->start();
@ -265,11 +240,7 @@ void ResizablePanel::dropEvent(QDropEvent *event)
ResizablePanel *draggedPanel = reinterpret_cast<ResizablePanel *>(ptr); ResizablePanel *draggedPanel = reinterpret_cast<ResizablePanel *>(ptr);
if (draggedPanel && draggedPanel != this) { if (draggedPanel && draggedPanel != this) {
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
bool insertBefore = (event->position().y() < height() / 2); bool insertBefore = (event->position().y() < height() / 2);
#else
bool insertBefore = (event->pos().y() < height() / 2);
#endif
emit dropRequested(draggedPanel, this, insertBefore); emit dropRequested(draggedPanel, this, insertBefore);
event->acceptProposedAction(); event->acceptProposedAction();
} }

View file

@ -321,11 +321,7 @@ void DlgSelectSetForCards::dropEvent(QDropEvent *event)
{ {
QByteArray itemData = event->mimeData()->data("application/x-setentrywidget"); QByteArray itemData = event->mimeData()->data("application/x-setentrywidget");
QString draggedSetName = QString::fromUtf8(itemData); QString draggedSetName = QString::fromUtf8(itemData);
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QPoint adjustedPos = event->position().toPoint() + QPoint(0, scrollArea->verticalScrollBar()->value()); QPoint adjustedPos = event->position().toPoint() + QPoint(0, scrollArea->verticalScrollBar()->value());
#else
QPoint adjustedPos = event->pos() + QPoint(0, scrollArea->verticalScrollBar()->value());
#endif
int dropIndex = -1; int dropIndex = -1;
for (int i = 0; i < listLayout->count(); ++i) { for (int i = 0; i < listLayout->count(); ++i) {
QWidget *widget = listLayout->itemAt(i)->widget(); QWidget *widget = listLayout->itemAt(i)->widget();
@ -491,11 +487,7 @@ void SetEntryWidget::mousePressEvent(QMouseEvent *event)
} }
} }
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
void SetEntryWidget::enterEvent(QEnterEvent *event) void SetEntryWidget::enterEvent(QEnterEvent *event)
#else
void SetEntryWidget::enterEvent(QEvent *event)
#endif
{ {
QWidget::enterEvent(event); // Call the base class handler QWidget::enterEvent(event); // Call the base class handler
// Highlight the widget by changing the background color only for the widget itself // Highlight the widget by changing the background color only for the widget itself

View file

@ -87,11 +87,7 @@ public:
public slots: public slots:
void mousePressEvent(QMouseEvent *event) override; void mousePressEvent(QMouseEvent *event) override;
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
void enterEvent(QEnterEvent *event) override; void enterEvent(QEnterEvent *event) override;
#else
void enterEvent(QEvent *event) override;
#endif
void leaveEvent(QEvent *event) override; void leaveEvent(QEvent *event) override;
void dragMoveEvent(QDragMoveEvent *event) override; void dragMoveEvent(QDragMoveEvent *event) override;

View file

@ -207,11 +207,7 @@ void BarChartWidget::mouseMoveEvent(QMouseEvent *e)
if (hoveredSegment >= 0) { if (hoveredSegment >= 0) {
const auto &s = segments[hoveredSegment]; const auto &s = segments[hoveredSegment];
QString text = QString("%1: %2 cards\n\n%3").arg(s.category).arg(s.value).arg(s.cards.join("\n")); QString text = QString("%1: %2 cards\n\n%3").arg(s.category).arg(s.value).arg(s.cards.join("\n"));
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QToolTip::showText(e->globalPosition().toPoint(), text, this); QToolTip::showText(e->globalPosition().toPoint(), text, this);
#else
QToolTip::showText(e->globalPos(), text, this);
#endif
} else { } else {
QToolTip::hideText(); QToolTip::hideText();
} }

View file

@ -83,19 +83,11 @@ void ColorBar::paintEvent(QPaintEvent *)
} }
} }
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
void ColorBar::enterEvent(QEnterEvent *event) void ColorBar::enterEvent(QEnterEvent *event)
{ {
Q_UNUSED(event); Q_UNUSED(event);
isHovered = true; isHovered = true;
} }
#else
void ColorBar::enterEvent(QEvent *event)
{
Q_UNUSED(event);
isHovered = true;
}
#endif
void ColorBar::leaveEvent(QEvent *) void ColorBar::leaveEvent(QEvent *)
{ {
@ -108,13 +100,8 @@ void ColorBar::mouseMoveEvent(QMouseEvent *event)
return; return;
} }
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
int x = int(event->position().x()); int x = int(event->position().x());
QPoint gp = event->globalPosition().toPoint(); QPoint gp = event->globalPosition().toPoint();
#else
int x = event->pos().x();
QPoint gp = event->globalPos();
#endif
QString text = tooltipForPosition(x); QString text = tooltipForPosition(x);
if (!text.isEmpty()) { if (!text.isEmpty()) {

View file

@ -76,17 +76,10 @@ protected:
*/ */
void paintEvent(QPaintEvent *event) override; void paintEvent(QPaintEvent *event) override;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
/** /**
* @brief Handles mouse hover entering (Qt6 version). * @brief Handles mouse hover entering.
*/ */
void enterEvent(QEnterEvent *event) override; void enterEvent(QEnterEvent *event) override;
#else
/**
* @brief Handles mouse hover entering (Qt5 version).
*/
void enterEvent(QEvent *event) override;
#endif
/** /**
* @brief Handles mouse hover leaving. * @brief Handles mouse hover leaving.

View file

@ -134,9 +134,5 @@ void SegmentedBarWidget::mouseMoveEvent(QMouseEvent *e)
const Segment &s = segments[idx]; const Segment &s = segments[idx];
QString text = QString("%1: %2 cards\n%3").arg(s.category).arg(s.value).arg(s.cards.join(", ")); QString text = QString("%1: %2 cards\n%3").arg(s.category).arg(s.value).arg(s.cards.join(", "));
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QToolTip::showText(e->globalPosition().toPoint(), text, this); QToolTip::showText(e->globalPosition().toPoint(), text, this);
#else
QToolTip::showText(e->globalPos(), text, this);
#endif
} }

View file

@ -82,11 +82,9 @@ void ColorPie::paintEvent(QPaintEvent *)
QString label = QString("%1%").arg(int(ratio * 100 + 0.5)); QString label = QString("%1%").arg(int(ratio * 100 + 0.5));
QFontMetrics fm(p.font()); QFontMetrics fm(p.font());
#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)
int labelWidth = fm.horizontalAdvance(label); int labelWidth = fm.horizontalAdvance(label);
#else
int labelWidth = fm.width(label);
#endif
QRectF textRect(labelPos.x() - labelWidth / 2.0, labelPos.y() - fm.height() / 2.0, labelWidth, fm.height()); QRectF textRect(labelPos.x() - labelWidth / 2.0, labelPos.y() - fm.height() / 2.0, labelWidth, fm.height());
p.setPen(Qt::black); p.setPen(Qt::black);
@ -96,19 +94,11 @@ void ColorPie::paintEvent(QPaintEvent *)
} }
} }
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
void ColorPie::enterEvent(QEnterEvent *event) void ColorPie::enterEvent(QEnterEvent *event)
{ {
Q_UNUSED(event); Q_UNUSED(event);
isHovered = true; isHovered = true;
} }
#else
void ColorPie::enterEvent(QEvent *event)
{
Q_UNUSED(event);
isHovered = true;
}
#endif
void ColorPie::leaveEvent(QEvent *) void ColorPie::leaveEvent(QEvent *)
{ {
@ -121,13 +111,8 @@ void ColorPie::mouseMoveEvent(QMouseEvent *event)
return; return;
} }
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QPoint p = event->position().toPoint(); QPoint p = event->position().toPoint();
QPoint gp = event->globalPosition().toPoint(); QPoint gp = event->globalPosition().toPoint();
#else
QPoint p = event->pos();
QPoint gp = event->globalPos();
#endif
QString text = tooltipForPoint(p); QString text = tooltipForPoint(p);
if (!text.isEmpty()) { if (!text.isEmpty()) {

View file

@ -22,11 +22,7 @@ public:
protected: protected:
void paintEvent(QPaintEvent *) override; void paintEvent(QPaintEvent *) override;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
void enterEvent(QEnterEvent *event) override; void enterEvent(QEnterEvent *event) override;
#else
void enterEvent(QEvent *event) override;
#endif
void leaveEvent(QEvent *) override; void leaveEvent(QEvent *) override;
void mouseMoveEvent(QMouseEvent *event) override; void mouseMoveEvent(QMouseEvent *event) override;

View file

@ -141,11 +141,7 @@ bool AllZonesCardAmountWidget::isNonZero()
* *
* @param event The event information for the mouse entry. * @param event The event information for the mouse entry.
*/ */
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
void AllZonesCardAmountWidget::enterEvent(QEnterEvent *event) void AllZonesCardAmountWidget::enterEvent(QEnterEvent *event)
#else
void AllZonesCardAmountWidget::enterEvent(QEvent *event)
#endif
{ {
QWidget::enterEvent(event); QWidget::enterEvent(event);
update(); update();

View file

@ -26,11 +26,7 @@ public:
int getTokensboardAmount(); int getTokensboardAmount();
bool isNonZero(); bool isNonZero();
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
void enterEvent(QEnterEvent *event) override; void enterEvent(QEnterEvent *event) override;
#else
void enterEvent(QEvent *event) override;
#endif
public slots: public slots:
void adjustFontSize(int scalePercentage); void adjustFontSize(int scalePercentage);

View file

@ -105,11 +105,7 @@ void PrintingSelectorCardOverlayWidget::resizeEvent(QResizeEvent *event)
* *
* @param event The event triggered when the mouse enters the widget. * @param event The event triggered when the mouse enters the widget.
*/ */
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
void PrintingSelectorCardOverlayWidget::enterEvent(QEnterEvent *event) void PrintingSelectorCardOverlayWidget::enterEvent(QEnterEvent *event)
#else
void PrintingSelectorCardOverlayWidget::enterEvent(QEvent *event)
#endif
{ {
QWidget::enterEvent(event); QWidget::enterEvent(event);
deckEditor->updateCard(rootCard); deckEditor->updateCard(rootCard);

View file

@ -26,11 +26,7 @@ public:
protected: protected:
void resizeEvent(QResizeEvent *event) override; void resizeEvent(QResizeEvent *event) override;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
void enterEvent(QEnterEvent *event) override; void enterEvent(QEnterEvent *event) override;
#else
void enterEvent(QEvent *event) override;
#endif
void leaveEvent(QEvent *event) override; void leaveEvent(QEvent *event) override;
void mousePressEvent(QMouseEvent *event) override; void mousePressEvent(QMouseEvent *event) override;
void customMenu(QPoint point); void customMenu(QPoint point);

View file

@ -103,11 +103,7 @@ void SettingsButtonWidget::onPopupClosed() const
void SettingsButtonWidget::mousePressEvent(QMouseEvent *event) void SettingsButtonWidget::mousePressEvent(QMouseEvent *event)
{ {
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
if (popup->isVisible() && !popup->geometry().contains(event->globalPosition().toPoint())) { if (popup->isVisible() && !popup->geometry().contains(event->globalPosition().toPoint())) {
#else
if (popup->isVisible() && !popup->geometry().contains(event->globalPos())) {
#endif
popup->close(); popup->close();
} }
QWidget::mousePressEvent(event); QWidget::mousePressEvent(event);

View file

@ -70,11 +70,7 @@ void ReplayTimelineWidget::paintEvent(QPaintEvent * /* event */)
void ReplayTimelineWidget::mousePressEvent(QMouseEvent *event) void ReplayTimelineWidget::mousePressEvent(QMouseEvent *event)
{ {
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
int newTime = static_cast<int>((qint64)maxTime * (qint64)event->position().x() / width()); int newTime = static_cast<int>((qint64)maxTime * (qint64)event->position().x() / width());
#else
int newTime = static_cast<int>((qint64)maxTime * (qint64)event->x() / width());
#endif
// don't buffer rewinds from clicks, since clicks usually don't happen fast enough to require buffering // don't buffer rewinds from clicks, since clicks usually don't happen fast enough to require buffering
skipToTime(newTime, false); skipToTime(newTime, false);
} }

View file

@ -529,23 +529,13 @@ void ChatView::showSystemPopup(const QString &userName)
QColor ChatView::getCustomMentionColor() QColor ChatView::getCustomMentionColor()
{ {
#if (QT_VERSION >= QT_VERSION_CHECK(6, 4, 0))
QColor customColor = QColor::fromString("#" + SettingsCache::instance().getChatMentionColor()); QColor customColor = QColor::fromString("#" + SettingsCache::instance().getChatMentionColor());
#else
QColor customColor;
customColor.setNamedColor("#" + SettingsCache::instance().getChatMentionColor());
#endif
return customColor.isValid() ? customColor : DEFAULT_MENTION_COLOR; return customColor.isValid() ? customColor : DEFAULT_MENTION_COLOR;
} }
QColor ChatView::getCustomHighlightColor() QColor ChatView::getCustomHighlightColor()
{ {
#if (QT_VERSION >= QT_VERSION_CHECK(6, 4, 0))
QColor customColor = QColor::fromString("#" + SettingsCache::instance().getChatMentionColor()); QColor customColor = QColor::fromString("#" + SettingsCache::instance().getChatMentionColor());
#else
QColor customColor;
customColor.setNamedColor("#" + SettingsCache::instance().getChatMentionColor());
#endif
return customColor.isValid() ? customColor : DEFAULT_MENTION_COLOR; return customColor.isValid() ? customColor : DEFAULT_MENTION_COLOR;
} }
@ -578,11 +568,7 @@ void ChatView::redactMessages(const QString &userName, int amount)
} }
} }
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
void ChatView::enterEvent(QEnterEvent * /*event*/) void ChatView::enterEvent(QEnterEvent * /*event*/)
#else
void ChatView::enterEvent(QEvent * /*event*/)
#endif
{ {
setMouseTracking(true); setMouseTracking(true);
} }
@ -639,12 +625,9 @@ void ChatView::mousePressEvent(QMouseEvent *event)
{ {
switch (hoveredItemType) { switch (hoveredItemType) {
case HoveredCard: { case HoveredCard: {
if ((event->button() == Qt::MiddleButton) || (event->button() == Qt::LeftButton)) if ((event->button() == Qt::MiddleButton) || (event->button() == Qt::LeftButton)) {
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
emit showCardInfoPopup(event->globalPosition().toPoint(), {hoveredContent}); emit showCardInfoPopup(event->globalPosition().toPoint(), {hoveredContent});
#else }
emit showCardInfoPopup(event->globalPos(), {hoveredContent});
#endif
break; break;
} }
case HoveredUser: { case HoveredUser: {
@ -654,11 +637,7 @@ void ChatView::mousePressEvent(QMouseEvent *event)
switch (event->button()) { switch (event->button()) {
case Qt::RightButton: { case Qt::RightButton: {
UserLevelFlags userLevel(hoveredContent.left(delimiterIndex).toInt()); UserLevelFlags userLevel(hoveredContent.left(delimiterIndex).toInt());
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
userContextMenu->showContextMenu(event->globalPosition().toPoint(), userName, userLevel, this); userContextMenu->showContextMenu(event->globalPosition().toPoint(), userName, userLevel, this);
#else
userContextMenu->showContextMenu(event->globalPos(), userName, userLevel, this);
#endif
break; break;
} }
case Qt::LeftButton: { case Qt::LeftButton: {

View file

@ -103,11 +103,7 @@ public:
void redactMessages(const QString &userName, int amount); void redactMessages(const QString &userName, int amount);
protected: protected:
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
void enterEvent(QEnterEvent *event) override; void enterEvent(QEnterEvent *event) override;
#else
void enterEvent(QEvent *event) override;
#endif
void leaveEvent(QEvent *event) override; void leaveEvent(QEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override; void mouseMoveEvent(QMouseEvent *event) override;
void mousePressEvent(QMouseEvent *event) override; void mousePressEvent(QMouseEvent *event) override;

View file

@ -339,11 +339,7 @@ bool UserListItemDelegate::editorEvent(QEvent *event,
if ((event->type() == QEvent::MouseButtonPress) && index.isValid()) { if ((event->type() == QEvent::MouseButtonPress) && index.isValid()) {
QMouseEvent *const mouseEvent = static_cast<QMouseEvent *>(event); QMouseEvent *const mouseEvent = static_cast<QMouseEvent *>(event);
if (mouseEvent->button() == Qt::RightButton) { if (mouseEvent->button() == Qt::RightButton) {
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
static_cast<UserListWidget *>(parent())->showContextMenu(mouseEvent->globalPosition().toPoint(), index); static_cast<UserListWidget *>(parent())->showContextMenu(mouseEvent->globalPosition().toPoint(), index);
#else
static_cast<UserListWidget *>(parent())->showContextMenu(mouseEvent->globalPos(), index);
#endif
return true; return true;
} }
} }

View file

@ -137,11 +137,7 @@ void ArchidektApiResponseDeckEntryDisplayWidget::mousePressEvent(QMouseEvent *ev
actRequestNavigationToDeck(); actRequestNavigationToDeck();
} }
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
void ArchidektApiResponseDeckEntryDisplayWidget::enterEvent(QEnterEvent *event) void ArchidektApiResponseDeckEntryDisplayWidget::enterEvent(QEnterEvent *event)
#else
void ArchidektApiResponseDeckEntryDisplayWidget::enterEvent(QEvent *event)
#endif
{ {
QWidget::enterEvent(event); QWidget::enterEvent(event);
backgroundPlateWidget->setFocused(true); backgroundPlateWidget->setFocused(true);

View file

@ -97,12 +97,7 @@ public slots:
protected: protected:
void mousePressEvent(QMouseEvent *event) override; void mousePressEvent(QMouseEvent *event) override;
void enterEvent(QEnterEvent *event) override;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
void enterEvent(QEnterEvent *event) override; ///< Qt6 hover enter
#else
void enterEvent(QEvent *event) override; ///< Qt5 hover enter
#endif
void leaveEvent(QEvent *event) override; void leaveEvent(QEvent *event) override;
private: private:

View file

@ -65,11 +65,7 @@ void EdhrecApiResponseCardDetailsDisplayWidget::mousePressEvent(QMouseEvent *eve
} }
} }
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
void EdhrecApiResponseCardDetailsDisplayWidget::enterEvent(QEnterEvent *event) void EdhrecApiResponseCardDetailsDisplayWidget::enterEvent(QEnterEvent *event)
#else
void EdhrecApiResponseCardDetailsDisplayWidget::enterEvent(QEvent *event)
#endif
{ {
QWidget::enterEvent(event); QWidget::enterEvent(event);
backgroundPlateWidget->setFocused(true); backgroundPlateWidget->setFocused(true);

View file

@ -39,11 +39,7 @@ private:
protected slots: protected slots:
void mousePressEvent(QMouseEvent *event) override; void mousePressEvent(QMouseEvent *event) override;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) void enterEvent(QEnterEvent *event) override;
void enterEvent(QEnterEvent *event) override; ///< Qt6 hover enter
#else
void enterEvent(QEvent *event) override; ///< Qt5 hover enter
#endif
void leaveEvent(QEvent *event) override; void leaveEvent(QEvent *event) override;
}; };

View file

@ -38,18 +38,6 @@
#include <libcockatrice/protocol/pb/serverinfo_room.pb.h> #include <libcockatrice/protocol/pb/serverinfo_room.pb.h>
#include <libcockatrice/protocol/pb/serverinfo_user.pb.h> #include <libcockatrice/protocol/pb/serverinfo_user.pb.h>
QRect MacOSTabFixStyle::subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const
{
if (element != SE_TabBarTabText) {
return QProxyStyle::subElementRect(element, option, widget);
}
// Skip over QProxyStyle handling subElementRect,
// This fixes an issue with Qt 5.10 on OSX where the labels for tabs with a button and an icon
// get cut-off too early
return QCommonStyle::subElementRect(element, option, widget);
}
CloseButton::CloseButton(QWidget *parent) : QAbstractButton(parent) CloseButton::CloseButton(QWidget *parent) : QAbstractButton(parent)
{ {
setFocusPolicy(Qt::NoFocus); setFocusPolicy(Qt::NoFocus);
@ -65,11 +53,7 @@ QSize CloseButton::sizeHint() const
return {width, height}; return {width, height};
} }
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
void CloseButton::enterEvent(QEnterEvent *event) void CloseButton::enterEvent(QEnterEvent *event)
#else
void CloseButton::enterEvent(QEvent *event)
#endif
{ {
update(); update();
QAbstractButton::enterEvent(event); QAbstractButton::enterEvent(event);
@ -117,12 +101,6 @@ TabSupervisor::TabSupervisor(AbstractClient *_client, QMenu *tabsMenu, QWidget *
setMovable(true); setMovable(true);
setIconSize(QSize(15, 15)); setIconSize(QSize(15, 15));
#if defined(Q_OS_MAC)
// This is necessary to fix an issue on macOS with qt5.10,
// where tabs with icons and buttons get drawn incorrectly
tabBar()->setStyle(new MacOSTabFixStyle);
#endif
userListManager = new UserListManager(client, this); userListManager = new UserListManager(client, this);
// connect tab changes // connect tab changes

View file

@ -21,7 +21,6 @@
#include <QAbstractButton> #include <QAbstractButton>
#include <QLoggingCategory> #include <QLoggingCategory>
#include <QMap> #include <QMap>
#include <QProxyStyle>
#include <QTabWidget> #include <QTabWidget>
class TabCardArtRules; class TabCardArtRules;
@ -52,13 +51,6 @@ class ServerInfo_User;
class GameReplay; class GameReplay;
class DeckList; class DeckList;
class MacOSTabFixStyle : public QProxyStyle
{
Q_OBJECT
public:
QRect subElementRect(SubElement, const QStyleOption *, const QWidget *) const override;
};
class CloseButton : public QAbstractButton class CloseButton : public QAbstractButton
{ {
Q_OBJECT Q_OBJECT
@ -71,11 +63,7 @@ public:
} }
protected: protected:
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
void enterEvent(QEnterEvent *event) override; void enterEvent(QEnterEvent *event) override;
#else
void enterEvent(QEvent *event) override;
#endif
void leaveEvent(QEvent *event) override; void leaveEvent(QEvent *event) override;
void paintEvent(QPaintEvent *event) override; void paintEvent(QPaintEvent *event) override;
}; };

View file

@ -71,11 +71,7 @@ void DeckPreviewWidget::resizeEvent(QResizeEvent *event)
} }
} }
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
void DeckPreviewWidget::enterEvent(QEnterEvent *event) void DeckPreviewWidget::enterEvent(QEnterEvent *event)
#else
void DeckPreviewWidget::enterEvent(QEvent *event)
#endif
{ {
QWidget::enterEvent(event); QWidget::enterEvent(event);

View file

@ -72,11 +72,7 @@ public slots:
void resizeEvent(QResizeEvent *event) override; void resizeEvent(QResizeEvent *event) override;
protected: protected:
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) void enterEvent(QEnterEvent *event) override;
void enterEvent(QEnterEvent *event) override; // Qt6 signature
#else
void enterEvent(QEvent *event) override; // Qt5 signature
#endif
private: private:
void updateLastModifiedTime(); void updateLastModifiedTime();

View file

@ -128,11 +128,7 @@ void installNewTranslator()
QString lang = SettingsCache::instance().getLang(); QString lang = SettingsCache::instance().getLang();
QString qtNameHint = "qt_" + lang; QString qtNameHint = "qt_" + lang;
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
QString qtTranslationPath = QLibraryInfo::path(QLibraryInfo::TranslationsPath); QString qtTranslationPath = QLibraryInfo::path(QLibraryInfo::TranslationsPath);
#else
QString qtTranslationPath = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
#endif
bool qtTranslationLoaded = qtTranslator->load(qtNameHint, qtTranslationPath); bool qtTranslationLoaded = qtTranslator->load(qtNameHint, qtTranslationPath);
if (!qtTranslationLoaded) { if (!qtTranslationLoaded) {
@ -277,9 +273,6 @@ int main(int argc, char *argv[])
// force shortcuts to be shown/hidden in right-click menus, regardless of system defaults // force shortcuts to be shown/hidden in right-click menus, regardless of system defaults
qApp->setAttribute(Qt::AA_DontShowShortcutsInContextMenus, !SettingsCache::instance().getShowShortcuts()); qApp->setAttribute(Qt::AA_DontShowShortcutsInContextMenus, !SettingsCache::instance().getShowShortcuts());
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
app.setAttribute(Qt::AA_UseHighDpiPixmaps);
#endif
app.exec(); app.exec();
qCInfo(MainLog) << "Event loop finished, terminating..."; qCInfo(MainLog) << "Event loop finished, terminating...";

View file

@ -21,8 +21,6 @@ set(HEADERS
if(Qt6_FOUND) if(Qt6_FOUND)
qt6_wrap_cpp(MOC_SOURCES ${HEADERS}) qt6_wrap_cpp(MOC_SOURCES ${HEADERS})
elseif(Qt5_FOUND)
qt5_wrap_cpp(MOC_SOURCES ${HEADERS})
endif() endif()
add_library( add_library(

View file

@ -25,22 +25,13 @@ bool CardInfoComparator::operator()(const CardInfoPtr &a, const CardInfoPtr &b)
bool CardInfoComparator::compareVariants(const QVariant &a, const QVariant &b) const bool CardInfoComparator::compareVariants(const QVariant &a, const QVariant &b) const
{ {
// Determine the type of QVariant based on Qt version
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
if (a.typeId() != b.typeId()) { if (a.typeId() != b.typeId()) {
#else
if (a.type() != b.type()) {
#endif
// If they are not the same type, compare as strings // If they are not the same type, compare as strings
return a.toString() < b.toString(); return a.toString() < b.toString();
} }
// Perform type-specific comparison // Perform type-specific comparison
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
switch (static_cast<int>(a.typeId())) { switch (static_cast<int>(a.typeId())) {
#else
switch (static_cast<int>(a.type())) {
#endif
case static_cast<int>(QMetaType::Int): case static_cast<int>(QMetaType::Int):
return a.toInt() < b.toInt(); return a.toInt() < b.toInt();
case static_cast<int>(QMetaType::Double): case static_cast<int>(QMetaType::Double):

View file

@ -16,8 +16,6 @@ set(HEADERS
if(Qt6_FOUND) if(Qt6_FOUND)
qt6_wrap_cpp(MOC_SOURCES ${HEADERS}) qt6_wrap_cpp(MOC_SOURCES ${HEADERS})
elseif(Qt5_FOUND)
qt5_wrap_cpp(MOC_SOURCES ${HEADERS})
endif() endif()
add_library( add_library(

View file

@ -13,14 +13,6 @@
#include <QTextStream> #include <QTextStream>
#include <algorithm> #include <algorithm>
#if QT_VERSION < 0x050600
// qHash on QRegularExpression was added in 5.6, FIX IT
uint qHash(const QRegularExpression &key, uint seed) noexcept
{
return qHash(key.pattern(), seed); // call qHash on pattern QString instead
}
#endif
static const QString CURRENT_SIDEBOARD_PLAN_KEY = ""; static const QString CURRENT_SIDEBOARD_PLAN_KEY = "";
bool DeckList::Metadata::isEmpty() const bool DeckList::Metadata::isEmpty() const

View file

@ -8,8 +8,6 @@ set(HEADERS libcockatrice/filters/filter_card.h libcockatrice/filters/filter_str
if(Qt6_FOUND) if(Qt6_FOUND)
qt6_wrap_cpp(MOC_SOURCES ${HEADERS}) qt6_wrap_cpp(MOC_SOURCES ${HEADERS})
elseif(Qt5_FOUND)
qt5_wrap_cpp(MOC_SOURCES ${HEADERS})
endif() endif()
add_library( add_library(

View file

@ -14,8 +14,6 @@ set(HEADERS
if(Qt6_FOUND) if(Qt6_FOUND)
qt6_wrap_cpp(MOC_SOURCES ${HEADERS}) qt6_wrap_cpp(MOC_SOURCES ${HEADERS})
elseif(Qt5_FOUND)
qt5_wrap_cpp(MOC_SOURCES ${HEADERS})
endif() endif()
add_library(libcockatrice_interfaces STATIC ${MOC_SOURCES}) add_library(libcockatrice_interfaces STATIC ${MOC_SOURCES})

View file

@ -14,8 +14,6 @@ set(HEADERS
if(Qt6_FOUND) if(Qt6_FOUND)
qt6_wrap_cpp(MOC_SOURCES ${HEADERS}) qt6_wrap_cpp(MOC_SOURCES ${HEADERS})
elseif(Qt5_FOUND)
qt5_wrap_cpp(MOC_SOURCES ${HEADERS})
endif() endif()
add_library( add_library(

View file

@ -6,8 +6,6 @@ set(HEADERS deck_list_model.h deck_list_sort_filter_proxy_model.h)
if(Qt6_FOUND) if(Qt6_FOUND)
qt6_wrap_cpp(MOC_SOURCES ${HEADERS}) qt6_wrap_cpp(MOC_SOURCES ${HEADERS})
elseif(Qt5_FOUND)
qt5_wrap_cpp(MOC_SOURCES ${HEADERS})
endif() endif()
add_library( add_library(

View file

@ -8,8 +8,6 @@ set(SOURCES abstract_client.cpp)
if(Qt6_FOUND) if(Qt6_FOUND)
qt6_wrap_cpp(MOC_SOURCES ${HEADERS}) qt6_wrap_cpp(MOC_SOURCES ${HEADERS})
elseif(Qt5_FOUND)
qt5_wrap_cpp(MOC_SOURCES ${HEADERS})
endif() endif()
add_library(libcockatrice_network_client_abstract STATIC ${MOC_SOURCES} ${SOURCES}) add_library(libcockatrice_network_client_abstract STATIC ${MOC_SOURCES} ${SOURCES})

View file

@ -8,8 +8,6 @@ set(SOURCES local_client.cpp)
if(Qt6_FOUND) if(Qt6_FOUND)
qt6_wrap_cpp(MOC_SOURCES ${HEADERS}) qt6_wrap_cpp(MOC_SOURCES ${HEADERS})
elseif(Qt5_FOUND)
qt5_wrap_cpp(MOC_SOURCES ${HEADERS})
endif() endif()
add_library(libcockatrice_network_client_local STATIC ${MOC_SOURCES} ${SOURCES}) add_library(libcockatrice_network_client_local STATIC ${MOC_SOURCES} ${SOURCES})

View file

@ -8,8 +8,6 @@ set(SOURCES remote_client.cpp)
if(Qt6_FOUND) if(Qt6_FOUND)
qt6_wrap_cpp(MOC_SOURCES ${HEADERS}) qt6_wrap_cpp(MOC_SOURCES ${HEADERS})
elseif(Qt5_FOUND)
qt5_wrap_cpp(MOC_SOURCES ${HEADERS})
endif() endif()
add_library(libcockatrice_network_client_remote STATIC ${MOC_SOURCES} ${SOURCES}) add_library(libcockatrice_network_client_remote STATIC ${MOC_SOURCES} ${SOURCES})

View file

@ -8,8 +8,6 @@ set(SOURCES local_server.cpp local_server_interface.cpp)
if(Qt6_FOUND) if(Qt6_FOUND)
qt6_wrap_cpp(MOC_SOURCES ${HEADERS}) qt6_wrap_cpp(MOC_SOURCES ${HEADERS})
elseif(Qt5_FOUND)
qt5_wrap_cpp(MOC_SOURCES ${HEADERS})
endif() endif()
add_library(libcockatrice_network_server_local STATIC ${MOC_SOURCES} ${SOURCES}) add_library(libcockatrice_network_server_local STATIC ${MOC_SOURCES} ${SOURCES})

View file

@ -25,8 +25,6 @@ set(HEADERS
if(Qt6_FOUND) if(Qt6_FOUND)
qt6_wrap_cpp(MOC_SOURCES ${HEADERS}) qt6_wrap_cpp(MOC_SOURCES ${HEADERS})
elseif(Qt5_FOUND)
qt5_wrap_cpp(MOC_SOURCES ${HEADERS})
endif() endif()
add_library( add_library(

View file

@ -6,8 +6,6 @@ set(HEADERS libcockatrice/rng/rng_abstract.h libcockatrice/rng/rng_sfmt.h libcoc
if(Qt6_FOUND) if(Qt6_FOUND)
qt6_wrap_cpp(MOC_SOURCES ${HEADERS}) qt6_wrap_cpp(MOC_SOURCES ${HEADERS})
elseif(Qt5_FOUND)
qt5_wrap_cpp(MOC_SOURCES ${HEADERS})
endif() endif()
add_library( add_library(

View file

@ -17,8 +17,6 @@ set(HEADERS
if(Qt6_FOUND) if(Qt6_FOUND)
qt6_wrap_cpp(MOC_SOURCES ${HEADERS}) qt6_wrap_cpp(MOC_SOURCES ${HEADERS})
elseif(Qt5_FOUND)
qt5_wrap_cpp(MOC_SOURCES ${HEADERS})
endif() endif()
add_library( add_library(

View file

@ -66,8 +66,6 @@ set(oracle_RESOURCES oracle.qrc)
# ------------------------ # ------------------------
if(Qt6_FOUND) if(Qt6_FOUND)
qt6_add_resources(oracle_RESOURCES_RCC ${oracle_RESOURCES}) qt6_add_resources(oracle_RESOURCES_RCC ${oracle_RESOURCES})
elseif(Qt5_FOUND)
qt5_add_resources(oracle_RESOURCES_RCC ${oracle_RESOURCES})
endif() endif()
# ------------------------ # ------------------------
@ -117,25 +115,6 @@ if(Qt6_FOUND)
${oracle_MOC_SRCS} ${oracle_MOC_SRCS}
MANUAL_FINALIZATION MANUAL_FINALIZATION
) )
elseif(Qt5_FOUND)
# Qt5 Translations need to be linked at executable creation time
if(Qt5LinguistTools_FOUND)
if(UPDATE_TRANSLATIONS)
qt5_create_translation(oracle_QM ${translate_SRCS} ${oracle_TS})
else()
qt5_add_translation(oracle_QM ${oracle_TS})
endif()
endif()
add_executable(oracle WIN32 MACOSX_BUNDLE ${oracle_MOC_SRCS} ${oracle_QM} ${oracle_RESOURCES_RCC} ${oracle_SOURCES})
if(UNIX)
if(APPLE)
install(FILES ${oracle_QM} DESTINATION ${ORACLE_MAC_QM_INSTALL_DIR})
else()
install(FILES ${oracle_QM} DESTINATION ${ORACLE_UNIX_QM_INSTALL_DIR})
endif()
elseif(WIN32)
install(FILES ${oracle_QM} DESTINATION ${ORACLE_WIN32_QM_INSTALL_DIR})
endif()
endif() endif()
# ------------------------ # ------------------------

View file

@ -24,11 +24,7 @@ void installNewTranslator()
QString lang = SettingsCache::instance().getLang(); QString lang = SettingsCache::instance().getLang();
QString qtNameHint = "qt_" + lang; QString qtNameHint = "qt_" + lang;
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
QString qtTranslationPath = QLibraryInfo::path(QLibraryInfo::TranslationsPath); QString qtTranslationPath = QLibraryInfo::path(QLibraryInfo::TranslationsPath);
#else
QString qtTranslationPath = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
#endif
bool qtTranslationLoaded = qtTranslator->load(qtNameHint, qtTranslationPath); bool qtTranslationLoaded = qtTranslator->load(qtNameHint, qtTranslationPath);
if (!qtTranslationLoaded) { if (!qtTranslationLoaded) {

View file

@ -109,12 +109,8 @@ QByteArray Json::serialize(const QVariant &data, bool &success)
{ {
str = "null"; str = "null";
} }
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
else if ((data.typeId() == QMetaType::Type::QVariantList) || else if ((data.typeId() == QMetaType::Type::QVariantList) ||
(data.typeId() == QMetaType::Type::QStringList)) // variant is a list? (data.typeId() == QMetaType::Type::QStringList)) // variant is a list?
#else
else if ((data.type() == QVariant::List) || (data.type() == QVariant::StringList)) // variant is a list?
#endif
{ {
QList<QByteArray> values; QList<QByteArray> values;
const QVariantList list = data.toList(); const QVariantList list = data.toList();
@ -129,11 +125,7 @@ QByteArray Json::serialize(const QVariant &data, bool &success)
str = "[ " + join(values, ", ") + " ]"; str = "[ " + join(values, ", ") + " ]";
} }
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
else if ((data.typeId() == QMetaType::Type::QVariantHash)) // variant is a list? else if ((data.typeId() == QMetaType::Type::QVariantHash)) // variant is a list?
#else
else if (data.type() == QVariant::Hash) // variant is a hash?
#endif
{ {
const QVariantHash vhash = data.toHash(); const QVariantHash vhash = data.toHash();
QHashIterator<QString, QVariant> it(vhash); QHashIterator<QString, QVariant> it(vhash);
@ -155,11 +147,7 @@ QByteArray Json::serialize(const QVariant &data, bool &success)
str += join(pairs, ", "); str += join(pairs, ", ");
str += " }"; str += " }";
} }
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
else if ((data.typeId() == QMetaType::Type::QVariantMap)) // variant is a list? else if ((data.typeId() == QMetaType::Type::QVariantMap)) // variant is a list?
#else
else if (data.type() == QVariant::Map) // variant is a map?
#endif
{ {
const QVariantMap vmap = data.toMap(); const QVariantMap vmap = data.toMap();
QMapIterator<QString, QVariant> it(vmap); QMapIterator<QString, QVariant> it(vmap);
@ -177,39 +165,23 @@ QByteArray Json::serialize(const QVariant &data, bool &success)
str += join(pairs, ", "); str += join(pairs, ", ");
str += " }"; str += " }";
} }
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
else if ((data.typeId() == QMetaType::Type::QString) || else if ((data.typeId() == QMetaType::Type::QString) ||
(data.typeId() == QMetaType::Type::QByteArray)) // variant is a list? (data.typeId() == QMetaType::Type::QByteArray)) // variant is a list?
#else
else if ((data.type() == QVariant::String) || (data.type() == QVariant::ByteArray)) // a string or a byte array?
#endif
{ {
str = sanitizeString(data.toString()).toUtf8(); str = sanitizeString(data.toString()).toUtf8();
} }
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
else if (data.typeId() == QMetaType::Type::Double) else if (data.typeId() == QMetaType::Type::Double)
#else
else if (data.type() == QVariant::Double) // double?
#endif
{ {
str = QByteArray::number(data.toDouble(), 'g', 20); str = QByteArray::number(data.toDouble(), 'g', 20);
if (!str.contains(".") && !str.contains("e")) { if (!str.contains(".") && !str.contains("e")) {
str += ".0"; str += ".0";
} }
} }
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
else if (data.typeId() == QMetaType::Type::Bool) else if (data.typeId() == QMetaType::Type::Bool)
#else
else if (data.type() == QVariant::Bool) // boolean value?
#endif
{ {
str = data.toBool() ? "true" : "false"; str = data.toBool() ? "true" : "false";
} }
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
else if (data.typeId() == QMetaType::Type::ULongLong) else if (data.typeId() == QMetaType::Type::ULongLong)
#else
else if (data.type() == QVariant::ULongLong) // large unsigned number?
#endif
{ {
str = QByteArray::number(data.value<qulonglong>()); str = QByteArray::number(data.value<qulonglong>());
} else if (data.canConvert<qlonglong>()) // any signed number? } else if (data.canConvert<qlonglong>()) // any signed number?

View file

@ -45,8 +45,6 @@ endif(APPLE)
if(Qt6_FOUND) if(Qt6_FOUND)
qt6_add_resources(servatrice_RESOURCES_RCC ${servatrice_RESOURCES}) qt6_add_resources(servatrice_RESOURCES_RCC ${servatrice_RESOURCES})
elseif(Qt5_FOUND)
qt5_add_resources(servatrice_RESOURCES_RCC ${servatrice_RESOURCES})
endif() endif()
set(QT_DONT_USE_QTGUI TRUE) set(QT_DONT_USE_QTGUI TRUE)

View file

@ -167,11 +167,7 @@ bool QxtHmac::verify(const QByteArray& otherInner)
void QxtHmac::addData(const char* data, int length) void QxtHmac::addData(const char* data, int length)
{ {
Q_ASSERT(qxt_d().opad.size()); Q_ASSERT(qxt_d().opad.size());
#if (QT_VERSION >= QT_VERSION_CHECK(6, 3, 0))
qxt_d().ihash->addData(QByteArrayView(data, length)); qxt_d().ihash->addData(QByteArrayView(data, length));
#else
qxt_d().ihash->addData(data, length);
#endif
qxt_d().result.clear(); qxt_d().result.clear();
} }

View file

@ -54,13 +54,8 @@ QxtSmtp::QxtSmtp(QObject *parent) : QObject(parent)
// QObject::connect(socket(), SIGNAL(encrypted()), &qxt_d(), SLOT(ehlo())); // QObject::connect(socket(), SIGNAL(encrypted()), &qxt_d(), SLOT(ehlo()));
QObject::connect(socket(), SIGNAL(connected()), this, SIGNAL(connected())); QObject::connect(socket(), SIGNAL(connected()), this, SIGNAL(connected()));
QObject::connect(socket(), SIGNAL(disconnected()), this, SIGNAL(disconnected())); QObject::connect(socket(), SIGNAL(disconnected()), this, SIGNAL(disconnected()));
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
QObject::connect(socket(), SIGNAL(errorOccurred(QAbstractSocket::SocketError)), &qxt_d(), QObject::connect(socket(), SIGNAL(errorOccurred(QAbstractSocket::SocketError)), &qxt_d(),
SLOT(socketError(QAbstractSocket::SocketError))); SLOT(socketError(QAbstractSocket::SocketError)));
#else
QObject::connect(socket(), SIGNAL(error(QAbstractSocket::SocketError)), &qxt_d(),
SLOT(socketError(QAbstractSocket::SocketError)));
#endif
QObject::connect(this, SIGNAL(authenticated()), &qxt_d(), SLOT(sendNext())); QObject::connect(this, SIGNAL(authenticated()), &qxt_d(), SLOT(sendNext()));
QObject::connect(socket(), SIGNAL(readyRead()), &qxt_d(), SLOT(socketRead())); QObject::connect(socket(), SIGNAL(readyRead()), &qxt_d(), SLOT(socketRead()));
} }