Browse Source

Merge pull request #14465 from glassez/qt6

Allow to build with Qt6
adaptive-webui-19844
Vladimir Golovnev 3 years ago committed by GitHub
parent
commit
a8ade3a04b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      CMakeLists.txt
  2. 36
      src/CMakeLists.txt
  3. 6
      src/app/CMakeLists.txt
  4. 4
      src/base/CMakeLists.txt
  5. 14
      src/gui/CMakeLists.txt
  6. 1
      src/gui/mainwindow.cpp
  7. 7
      src/gui/mainwindow.h
  8. 2
      src/gui/transferlistfilterswidget.cpp
  9. 5
      src/gui/transferlistfilterswidget.h
  10. 1
      src/gui/transferlistwidget.cpp
  11. 4
      src/gui/transferlistwidget.h
  12. 2
      src/src.pro

4
CMakeLists.txt

@ -12,7 +12,8 @@ project(qBittorrent
set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON) set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON)
# version requirements - older versions may work, but you are on your own # version requirements - older versions may work, but you are on your own
set(minBoostVersion 1.65) set(minBoostVersion 1.65)
set(minQtVersion 5.15.2) set(minQt5Version 5.15.2)
set(minQt6Version 6.2)
set(minOpenSSLVersion 1.1.1) set(minOpenSSLVersion 1.1.1)
set(minLibtorrent1Version 1.2.14) set(minLibtorrent1Version 1.2.14)
set(minLibtorrentVersion 2.0.4) 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(CheckCXXSourceCompiles) # TODO: migrate to CheckSourceCompiles in CMake >= 3.19
include(FeatureSummary) include(FeatureSummary)
include(FeatureOptionsSetup) include(FeatureOptionsSetup)
feature_option(QT6 "Use Qt6" OFF)
feature_option(STACKTRACE "Enable stacktraces" ON) feature_option(STACKTRACE "Enable stacktraces" ON)
feature_option(GUI "Build GUI application" ON) feature_option(GUI "Build GUI application" ON)
feature_option(WEBUI "Enables built-in HTTP server for headless use" ON) feature_option(WEBUI "Enables built-in HTTP server for headless use" ON)

36
src/CMakeLists.txt

@ -43,13 +43,24 @@ set_property(CACHE LibtorrentRasterbar_DIR PROPERTY TYPE PATH)
find_package(Boost ${minBoostVersion} REQUIRED) find_package(Boost ${minBoostVersion} REQUIRED)
find_package(OpenSSL ${minOpenSSLVersion} REQUIRED) find_package(OpenSSL ${minOpenSSLVersion} REQUIRED)
find_package(ZLIB ${minZlibVersion} REQUIRED) find_package(ZLIB ${minZlibVersion} REQUIRED)
find_package(Qt5 ${minQtVersion} REQUIRED COMPONENTS Core Network Sql Xml LinguistTools) if (QT6)
if (DBUS) find_package(Qt6 ${minQt6Version} REQUIRED COMPONENTS Core Network Sql Xml LinguistTools)
find_package(Qt5 ${minQtVersion} REQUIRED COMPONENTS DBus) if (DBUS)
set_package_properties(Qt5DBus PROPERTIES find_package(Qt6 ${minQt6Version} REQUIRED COMPONENTS DBus)
DESCRIPTION "Qt5 module for inter-process communication over the D-Bus protocol" set_package_properties(Qt6DBus PROPERTIES
PURPOSE "Required by the DBUS feature" 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() endif()
# automatically call Qt moc, rcc and uic as needed for all targets by default # 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) add_subdirectory(base)
if (GUI) if (GUI)
find_package(Qt5 ${minQtVersion} REQUIRED COMPONENTS Widgets Svg) if (QT6)
if (CMAKE_SYSTEM_NAME STREQUAL "Windows") find_package(Qt6 ${minQt6Version} REQUIRED COMPONENTS Widgets Svg)
find_package(Qt5 ${minQtVersion} REQUIRED COMPONENTS WinExtras) else()
find_package(Qt5 ${minQt5Version} REQUIRED COMPONENTS Widgets Svg)
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
find_package(Qt5 ${minQt5Version} REQUIRED COMPONENTS WinExtras)
endif()
endif() endif()
add_subdirectory(gui) add_subdirectory(gui)
endif() endif()

6
src/app/CMakeLists.txt

@ -4,14 +4,14 @@
# Based on https://gist.github.com/giraldeau/546ba5512a74dfe9d8ea0862d66db412 # Based on https://gist.github.com/giraldeau/546ba5512a74dfe9d8ea0862d66db412
file(GLOB QBT_TS_FILES "${qBittorrent_SOURCE_DIR}/src/lang/*.ts") 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") 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) configure_file("${qBittorrent_SOURCE_DIR}/src/lang/lang.qrc" "${qBittorrent_BINARY_DIR}/src/lang/lang.qrc" COPYONLY)
if (WEBUI) if (WEBUI)
file(GLOB QBT_WEBUI_TS_FILES "${qBittorrent_SOURCE_DIR}/src/webui/www/translations/*.ts") file(GLOB QBT_WEBUI_TS_FILES "${qBittorrent_SOURCE_DIR}/src/webui/www/translations/*.ts")
set_source_files_properties(${QBT_WEBUI_TS_FILES} set_source_files_properties(${QBT_WEBUI_TS_FILES}
PROPERTIES OUTPUT_LOCATION "${qBittorrent_BINARY_DIR}/src/webui/www/translations") 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" configure_file("${qBittorrent_SOURCE_DIR}/src/webui/www/translations/webui_translations.qrc"
"${qBittorrent_BINARY_DIR}/src/webui/www/translations/webui_translations.qrc" COPYONLY) "${qBittorrent_BINARY_DIR}/src/webui/www/translations/webui_translations.qrc" COPYONLY)
endif() endif()
@ -139,7 +139,7 @@ endif()
if (GUI) if (GUI)
target_link_libraries(qbt_app PRIVATE qbt_gui) target_link_libraries(qbt_app PRIVATE qbt_gui)
if ((CMAKE_SYSTEM_NAME STREQUAL "Windows") OR (CMAKE_SYSTEM_NAME STREQUAL "Darwin")) 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()
endif() endif()

4
src/base/CMakeLists.txt

@ -177,7 +177,7 @@ target_link_libraries(qbt_base
ZLIB::ZLIB ZLIB::ZLIB
PUBLIC PUBLIC
LibtorrentRasterbar::torrent-rasterbar LibtorrentRasterbar::torrent-rasterbar
Qt5::Core Qt5::Network Qt5::Sql Qt5::Xml Qt::Core Qt::Network Qt::Sql Qt::Xml
qbt_common_cfg qbt_common_cfg
) )
@ -204,5 +204,5 @@ if (NOT WEBUI)
endif() endif()
if (DBUS) if (DBUS)
target_link_libraries(qbt_base PUBLIC Qt5::DBus) target_link_libraries(qbt_base PUBLIC Qt::DBus)
endif() endif()

14
src/gui/CMakeLists.txt

@ -199,7 +199,7 @@ target_link_libraries(qbt_gui
PRIVATE PRIVATE
qbt_base qbt_base
PUBLIC PUBLIC
Qt5::Gui Qt5::Widgets Qt::Gui Qt::Widgets
) )
if (DBUS) if (DBUS)
@ -219,10 +219,10 @@ if ((CMAKE_SYSTEM_NAME STREQUAL "Windows") OR (CMAKE_SYSTEM_NAME STREQUAL "Darwi
endif() endif()
if (CMAKE_SYSTEM_NAME STREQUAL "Windows") if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
target_link_libraries(qbt_gui PRIVATE target_link_libraries(qbt_gui PRIVATE PowrProf)
Qt5::WinExtras if (NOT QT6)
PowrProf target_link_libraries(qbt_gui PRIVATE Qt5::WinExtras)
) endif()
endif() endif()
if (CMAKE_SYSTEM_NAME STREQUAL "Darwin") if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
@ -230,7 +230,5 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
macutilities.h macutilities.h
macutilities.mm macutilities.mm
) )
target_link_libraries(qbt_gui PRIVATE target_link_libraries(qbt_gui PRIVATE objc)
objc
)
endif() endif()

1
src/gui/mainwindow.cpp

@ -55,7 +55,6 @@
#include "base/bittorrent/session.h" #include "base/bittorrent/session.h"
#include "base/bittorrent/sessionstatus.h" #include "base/bittorrent/sessionstatus.h"
#include "base/bittorrent/torrent.h"
#include "base/global.h" #include "base/global.h"
#include "base/logger.h" #include "base/logger.h"
#include "base/net/downloadmanager.h" #include "base/net/downloadmanager.h"

7
src/gui/mainwindow.h

@ -35,6 +35,8 @@
#include <QSystemTrayIcon> #include <QSystemTrayIcon>
#endif #endif
#include "base/bittorrent/torrent.h"
class QCloseEvent; class QCloseEvent;
class QFileSystemWatcher; class QFileSystemWatcher;
class QSplitter; class QSplitter;
@ -57,11 +59,6 @@ class TorrentCreatorDialog;
class TransferListFiltersWidget; class TransferListFiltersWidget;
class TransferListWidget; class TransferListWidget;
namespace BitTorrent
{
class Torrent;
}
namespace Net namespace Net
{ {
struct DownloadResult; struct DownloadResult;

2
src/gui/transferlistfilterswidget.cpp

@ -38,10 +38,8 @@
#include <QUrl> #include <QUrl>
#include <QVBoxLayout> #include <QVBoxLayout>
#include "base/bittorrent/infohash.h"
#include "base/bittorrent/session.h" #include "base/bittorrent/session.h"
#include "base/bittorrent/torrent.h" #include "base/bittorrent/torrent.h"
#include "base/bittorrent/trackerentry.h"
#include "base/global.h" #include "base/global.h"
#include "base/logger.h" #include "base/logger.h"
#include "base/net/downloadmanager.h" #include "base/net/downloadmanager.h"

5
src/gui/transferlistfilterswidget.h

@ -32,6 +32,9 @@
#include <QListWidget> #include <QListWidget>
#include <QtContainerFwd> #include <QtContainerFwd>
#include "base/bittorrent/infohash.h"
#include "base/bittorrent/trackerentry.h"
class QCheckBox; class QCheckBox;
class QResizeEvent; class QResizeEvent;
@ -40,8 +43,6 @@ class TransferListWidget;
namespace BitTorrent namespace BitTorrent
{ {
class Torrent; class Torrent;
class TorrentID;
struct TrackerEntry;
} }
namespace Net namespace Net

1
src/gui/transferlistwidget.cpp

@ -44,7 +44,6 @@
#include <QWheelEvent> #include <QWheelEvent>
#include "base/bittorrent/common.h" #include "base/bittorrent/common.h"
#include "base/bittorrent/infohash.h"
#include "base/bittorrent/session.h" #include "base/bittorrent/session.h"
#include "base/bittorrent/torrent.h" #include "base/bittorrent/torrent.h"
#include "base/bittorrent/trackerentry.h" #include "base/bittorrent/trackerentry.h"

4
src/gui/transferlistwidget.h

@ -29,9 +29,12 @@
#pragma once #pragma once
#include <functional> #include <functional>
#include <QtContainerFwd> #include <QtContainerFwd>
#include <QTreeView> #include <QTreeView>
#include "base/bittorrent/infohash.h"
class MainWindow; class MainWindow;
class TransferListModel; class TransferListModel;
class TransferListSortModel; class TransferListSortModel;
@ -39,7 +42,6 @@ class TransferListSortModel;
namespace BitTorrent namespace BitTorrent
{ {
class Torrent; class Torrent;
class TorrentID;
} }
enum class CopyInfohashPolicy enum class CopyInfohashPolicy

2
src/src.pro

@ -23,7 +23,7 @@ nogui {
DEFINES += QBT_STATIC_QT DEFINES += QBT_STATIC_QT
QTPLUGIN += qico QTPLUGIN += qico
} }
win32 { win32: lessThan(QT_VERSION_MAJOR, 6) {
QT += winextras QT += winextras
} }
macx { macx {

Loading…
Cancel
Save