From b51197936bc13f726f5390e4ca7be89df106a175 Mon Sep 17 00:00:00 2001 From: "Vladimir Golovnev (glassez)" Date: Sat, 24 Jul 2021 14:58:58 +0300 Subject: [PATCH 1/3] QMake: Don't use WinExtras module with Qt6 --- src/src.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/src.pro b/src/src.pro index 8e87c56c9..1ba2f49fc 100644 --- a/src/src.pro +++ b/src/src.pro @@ -23,7 +23,7 @@ nogui { DEFINES += QBT_STATIC_QT QTPLUGIN += qico } - win32 { + win32: lessThan(QT_VERSION_MAJOR, 6) { QT += winextras } macx { From 86b1ac5d7cd36a1fefeadc6200d0aa40fafa8be5 Mon Sep 17 00:00:00 2001 From: "Vladimir Golovnev (Glassez)" Date: Mon, 1 Mar 2021 08:38:51 +0300 Subject: [PATCH 2/3] CMake: Allow to build with Qt6 --- CMakeLists.txt | 4 +++- src/CMakeLists.txt | 36 ++++++++++++++++++++++++++---------- src/app/CMakeLists.txt | 6 +++--- src/base/CMakeLists.txt | 4 ++-- src/gui/CMakeLists.txt | 14 ++++++-------- 5 files changed, 40 insertions(+), 24 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c639e7d98..063c169f2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,8 @@ project(qBittorrent set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON) # version requirements - older versions may work, but you are on your own set(minBoostVersion 1.65) -set(minQtVersion 5.15.2) +set(minQt5Version 5.15.2) +set(minQt6Version 6.2) set(minOpenSSLVersion 1.1.1) set(minLibtorrent1Version 1.2.14) set(minLibtorrentVersion 2.0.4) @@ -22,6 +23,7 @@ set(minZlibVersion 1.2.11) include(CheckCXXSourceCompiles) # TODO: migrate to CheckSourceCompiles in CMake >= 3.19 include(FeatureSummary) include(FeatureOptionsSetup) +feature_option(QT6 "Use Qt6" OFF) feature_option(STACKTRACE "Enable stacktraces" ON) feature_option(GUI "Build GUI application" ON) feature_option(WEBUI "Enables built-in HTTP server for headless use" ON) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d22c93a27..fd90de4b7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -43,13 +43,24 @@ set_property(CACHE LibtorrentRasterbar_DIR PROPERTY TYPE PATH) find_package(Boost ${minBoostVersion} REQUIRED) find_package(OpenSSL ${minOpenSSLVersion} REQUIRED) find_package(ZLIB ${minZlibVersion} REQUIRED) -find_package(Qt5 ${minQtVersion} REQUIRED COMPONENTS Core Network Sql Xml LinguistTools) -if (DBUS) - find_package(Qt5 ${minQtVersion} REQUIRED COMPONENTS DBus) - set_package_properties(Qt5DBus PROPERTIES - DESCRIPTION "Qt5 module for inter-process communication over the D-Bus protocol" - PURPOSE "Required by the DBUS feature" - ) +if (QT6) + find_package(Qt6 ${minQt6Version} REQUIRED COMPONENTS Core Network Sql Xml LinguistTools) + if (DBUS) + find_package(Qt6 ${minQt6Version} REQUIRED COMPONENTS DBus) + set_package_properties(Qt6DBus PROPERTIES + DESCRIPTION "Qt6 module for inter-process communication over the D-Bus protocol" + PURPOSE "Required by the DBUS feature" + ) + endif() +else() + find_package(Qt5 ${minQt5Version} REQUIRED COMPONENTS Core Network Sql Xml LinguistTools) + if (DBUS) + find_package(Qt5 ${minQt5Version} REQUIRED COMPONENTS DBus) + set_package_properties(Qt5DBus PROPERTIES + DESCRIPTION "Qt5 module for inter-process communication over the D-Bus protocol" + PURPOSE "Required by the DBUS feature" + ) + endif() endif() # automatically call Qt moc, rcc and uic as needed for all targets by default @@ -68,10 +79,15 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}) add_subdirectory(base) if (GUI) - find_package(Qt5 ${minQtVersion} REQUIRED COMPONENTS Widgets Svg) - if (CMAKE_SYSTEM_NAME STREQUAL "Windows") - find_package(Qt5 ${minQtVersion} REQUIRED COMPONENTS WinExtras) + if (QT6) + find_package(Qt6 ${minQt6Version} REQUIRED COMPONENTS Widgets Svg) + else() + find_package(Qt5 ${minQt5Version} REQUIRED COMPONENTS Widgets Svg) + if (CMAKE_SYSTEM_NAME STREQUAL "Windows") + find_package(Qt5 ${minQt5Version} REQUIRED COMPONENTS WinExtras) + endif() endif() + add_subdirectory(gui) endif() diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt index c43600fdd..8d7a297e5 100644 --- a/src/app/CMakeLists.txt +++ b/src/app/CMakeLists.txt @@ -4,14 +4,14 @@ # Based on https://gist.github.com/giraldeau/546ba5512a74dfe9d8ea0862d66db412 file(GLOB QBT_TS_FILES "${qBittorrent_SOURCE_DIR}/src/lang/*.ts") set_source_files_properties(${QBT_TS_FILES} PROPERTIES OUTPUT_LOCATION "${qBittorrent_BINARY_DIR}/src/lang") -qt5_add_translation(QBT_QM_FILES ${QBT_TS_FILES} OPTIONS -silent) +qt_add_translation(QBT_QM_FILES ${QBT_TS_FILES} OPTIONS -silent) configure_file("${qBittorrent_SOURCE_DIR}/src/lang/lang.qrc" "${qBittorrent_BINARY_DIR}/src/lang/lang.qrc" COPYONLY) if (WEBUI) file(GLOB QBT_WEBUI_TS_FILES "${qBittorrent_SOURCE_DIR}/src/webui/www/translations/*.ts") set_source_files_properties(${QBT_WEBUI_TS_FILES} PROPERTIES OUTPUT_LOCATION "${qBittorrent_BINARY_DIR}/src/webui/www/translations") - qt5_add_translation(QBT_WEBUI_QM_FILES ${QBT_WEBUI_TS_FILES} OPTIONS -silent) + qt_add_translation(QBT_WEBUI_QM_FILES ${QBT_WEBUI_TS_FILES} OPTIONS -silent) configure_file("${qBittorrent_SOURCE_DIR}/src/webui/www/translations/webui_translations.qrc" "${qBittorrent_BINARY_DIR}/src/webui/www/translations/webui_translations.qrc" COPYONLY) endif() @@ -139,7 +139,7 @@ endif() if (GUI) target_link_libraries(qbt_app PRIVATE qbt_gui) if ((CMAKE_SYSTEM_NAME STREQUAL "Windows") OR (CMAKE_SYSTEM_NAME STREQUAL "Darwin")) - qt_import_plugins(qbt_app INCLUDE Qt5::QSvgIconPlugin Qt5::QSvgPlugin) + qt_import_plugins(qbt_app INCLUDE Qt::QSvgIconPlugin Qt::QSvgPlugin) endif() endif() diff --git a/src/base/CMakeLists.txt b/src/base/CMakeLists.txt index 8274330da..67238b4e8 100644 --- a/src/base/CMakeLists.txt +++ b/src/base/CMakeLists.txt @@ -177,7 +177,7 @@ target_link_libraries(qbt_base ZLIB::ZLIB PUBLIC LibtorrentRasterbar::torrent-rasterbar - Qt5::Core Qt5::Network Qt5::Sql Qt5::Xml + Qt::Core Qt::Network Qt::Sql Qt::Xml qbt_common_cfg ) @@ -204,5 +204,5 @@ if (NOT WEBUI) endif() if (DBUS) - target_link_libraries(qbt_base PUBLIC Qt5::DBus) + target_link_libraries(qbt_base PUBLIC Qt::DBus) endif() diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 78e899798..882e28f8f 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -199,7 +199,7 @@ target_link_libraries(qbt_gui PRIVATE qbt_base PUBLIC - Qt5::Gui Qt5::Widgets + Qt::Gui Qt::Widgets ) if (DBUS) @@ -219,10 +219,10 @@ if ((CMAKE_SYSTEM_NAME STREQUAL "Windows") OR (CMAKE_SYSTEM_NAME STREQUAL "Darwi endif() if (CMAKE_SYSTEM_NAME STREQUAL "Windows") - target_link_libraries(qbt_gui PRIVATE - Qt5::WinExtras - PowrProf - ) + target_link_libraries(qbt_gui PRIVATE PowrProf) + if (NOT QT6) + target_link_libraries(qbt_gui PRIVATE Qt5::WinExtras) + endif() endif() if (CMAKE_SYSTEM_NAME STREQUAL "Darwin") @@ -230,7 +230,5 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Darwin") macutilities.h macutilities.mm ) - target_link_libraries(qbt_gui PRIVATE - objc - ) + target_link_libraries(qbt_gui PRIVATE objc) endif() From add75fbc771e195d6b70ff6b36953f0976baa1a2 Mon Sep 17 00:00:00 2001 From: "Vladimir Golovnev (glassez)" Date: Sat, 24 Jul 2021 15:37:11 +0300 Subject: [PATCH 3/3] Make complete type declarations available where needed --- src/gui/mainwindow.cpp | 1 - src/gui/mainwindow.h | 7 ++----- src/gui/transferlistfilterswidget.cpp | 2 -- src/gui/transferlistfilterswidget.h | 5 +++-- src/gui/transferlistwidget.cpp | 1 - src/gui/transferlistwidget.h | 4 +++- 6 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index cac39e4e0..691039586 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -55,7 +55,6 @@ #include "base/bittorrent/session.h" #include "base/bittorrent/sessionstatus.h" -#include "base/bittorrent/torrent.h" #include "base/global.h" #include "base/logger.h" #include "base/net/downloadmanager.h" diff --git a/src/gui/mainwindow.h b/src/gui/mainwindow.h index 8fa089adb..12d56ed83 100644 --- a/src/gui/mainwindow.h +++ b/src/gui/mainwindow.h @@ -35,6 +35,8 @@ #include #endif +#include "base/bittorrent/torrent.h" + class QCloseEvent; class QFileSystemWatcher; class QSplitter; @@ -57,11 +59,6 @@ class TorrentCreatorDialog; class TransferListFiltersWidget; class TransferListWidget; -namespace BitTorrent -{ - class Torrent; -} - namespace Net { struct DownloadResult; diff --git a/src/gui/transferlistfilterswidget.cpp b/src/gui/transferlistfilterswidget.cpp index 7210fcef5..042e955b2 100644 --- a/src/gui/transferlistfilterswidget.cpp +++ b/src/gui/transferlistfilterswidget.cpp @@ -38,10 +38,8 @@ #include #include -#include "base/bittorrent/infohash.h" #include "base/bittorrent/session.h" #include "base/bittorrent/torrent.h" -#include "base/bittorrent/trackerentry.h" #include "base/global.h" #include "base/logger.h" #include "base/net/downloadmanager.h" diff --git a/src/gui/transferlistfilterswidget.h b/src/gui/transferlistfilterswidget.h index b47077ead..0a0f39491 100644 --- a/src/gui/transferlistfilterswidget.h +++ b/src/gui/transferlistfilterswidget.h @@ -32,6 +32,9 @@ #include #include +#include "base/bittorrent/infohash.h" +#include "base/bittorrent/trackerentry.h" + class QCheckBox; class QResizeEvent; @@ -40,8 +43,6 @@ class TransferListWidget; namespace BitTorrent { class Torrent; - class TorrentID; - struct TrackerEntry; } namespace Net diff --git a/src/gui/transferlistwidget.cpp b/src/gui/transferlistwidget.cpp index fba5468ae..e42a144c9 100644 --- a/src/gui/transferlistwidget.cpp +++ b/src/gui/transferlistwidget.cpp @@ -44,7 +44,6 @@ #include #include "base/bittorrent/common.h" -#include "base/bittorrent/infohash.h" #include "base/bittorrent/session.h" #include "base/bittorrent/torrent.h" #include "base/bittorrent/trackerentry.h" diff --git a/src/gui/transferlistwidget.h b/src/gui/transferlistwidget.h index ef1400e3b..9257ea15b 100644 --- a/src/gui/transferlistwidget.h +++ b/src/gui/transferlistwidget.h @@ -29,9 +29,12 @@ #pragma once #include + #include #include +#include "base/bittorrent/infohash.h" + class MainWindow; class TransferListModel; class TransferListSortModel; @@ -39,7 +42,6 @@ class TransferListSortModel; namespace BitTorrent { class Torrent; - class TorrentID; } enum class CopyInfohashPolicy