Skip to content

Commit

Permalink
Drop support of Qt 5
Browse files Browse the repository at this point in the history
Also remove usage of some deprecated stuff.

PR qbittorrent#19338.
  • Loading branch information
glassez authored Jul 20, 2023
1 parent 5e610cf commit dbe7948
Show file tree
Hide file tree
Showing 55 changed files with 48 additions and 462 deletions.
22 changes: 1 addition & 21 deletions .github/workflows/ci_macos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
matrix:
libt_version: ["2.0.9", "1.2.19"]
qbt_gui: ["GUI=ON", "GUI=OFF"]
qt_version: ["5.15.2", "6.5.0"]
qt_version: ["6.5.0"]
exclude:
- libt_version: "1.2.19"
qt_version: "6.5.0"
Expand Down Expand Up @@ -88,25 +88,6 @@ jobs:
cmake --build build
sudo cmake --install build
- name: Build qBittorrent (Qt5)
if: startsWith(matrix.qt_version, 5)
run: |
CXXFLAGS="$CXXFLAGS -Werror -Wno-error=deprecated-declarations" \
LDFLAGS="$LDFLAGS -gz" \
cmake \
-B build \
-G "Ninja" \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DBOOST_ROOT="${{ env.boost_path }}" \
-DOPENSSL_ROOT_DIR="${{ env.openssl_root }}" \
-DTESTING=ON \
-DVERBOSE_CONFIGURE=ON \
-D${{ matrix.qbt_gui }}
cmake --build build --target qbt_update_translations
cmake --build build
cmake --build build --target check
- name: Build qBittorrent (Qt6)
if: startsWith(matrix.qt_version, 6)
run: |
Expand All @@ -119,7 +100,6 @@ jobs:
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DBOOST_ROOT="${{ env.boost_path }}" \
-DOPENSSL_ROOT_DIR="${{ env.openssl_root }}" \
-DQT6=ON \
-DTESTING=ON \
-DVERBOSE_CONFIGURE=ON \
-D${{ matrix.qbt_gui }}
Expand Down
22 changes: 1 addition & 21 deletions .github/workflows/ci_ubuntu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
matrix:
libt_version: ["2.0.9", "1.2.19"]
qbt_gui: ["GUI=ON", "GUI=OFF"]
qt_version: ["5.15.2", "6.2.0"]
qt_version: ["6.2.0"]
exclude:
- libt_version: "1.2.19"
qt_version: "6.2.0"
Expand Down Expand Up @@ -75,25 +75,6 @@ jobs:
config-file: ./.github/workflows/helper/codeql/cpp.yaml
languages: cpp

- name: Build qBittorrent (Qt5)
if: startsWith(matrix.qt_version, 5)
run: |
CXXFLAGS="$CXXFLAGS -Werror -Wno-error=deprecated-declarations" \
LDFLAGS="$LDFLAGS -gz" \
cmake \
-B build \
-G "Ninja" \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCMAKE_INSTALL_PREFIX="/usr" \
-DTESTING=ON \
-DVERBOSE_CONFIGURE=ON \
-D${{ matrix.qbt_gui }}
cmake --build build --target qbt_update_translations
cmake --build build
cmake --build build --target check
DESTDIR="qbittorrent" cmake --install build
- name: Build qBittorrent (Qt6)
if: startsWith(matrix.qt_version, 6)
run: |
Expand All @@ -105,7 +86,6 @@ jobs:
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCMAKE_INSTALL_PREFIX="/usr" \
-DQT6=ON \
-DTESTING=ON \
-DVERBOSE_CONFIGURE=ON \
-D${{ matrix.qbt_gui }}
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/ci_windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ jobs:
-DBOOST_ROOT="${{ env.boost_path }}" `
-DLibtorrentRasterbar_DIR="${{ env.libtorrent_path }}/lib/cmake/LibtorrentRasterbar" `
-DMSVC_RUNTIME_DYNAMIC=OFF `
-DQT6=ON `
-DTESTING=ON `
-DVCPKG_TARGET_TRIPLET=x64-windows-static-release `
-DVERBOSE_CONFIGURE=ON `
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/coverity-scan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ jobs:
-G "Ninja" \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DGUI=ON \
-DQT6=ON \
-DVERBOSE_CONFIGURE=ON
export PATH="$(pwd)/coverity_tool/bin:$PATH"
cov-build --dir cov-int cmake --build build
Expand Down
2 changes: 0 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ project(qBittorrent

# version requirements - older versions may work, but you are on your own
set(minBoostVersion 1.71)
set(minQt5Version 5.15.2)
set(minQt6Version 6.2)
set(minOpenSSLVersion 1.1.1)
set(minLibtorrent1Version 1.2.19)
Expand All @@ -25,7 +24,6 @@ include(FeatureOptionsSetup)
# features, list is loosely sorted by user's interests
feature_option(GUI "Build GUI application" ON)
feature_option(WEBUI "Enable built-in HTTP server for remote control" ON)
feature_option(QT6 "Build with Qt 6 instead of Qt 5" OFF)
feature_option(STACKTRACE "Enable stacktrace support" ON)
feature_option(TESTING "Build internal testing suite" OFF)
feature_option(VERBOSE_CONFIGURE "Show information about PACKAGES_FOUND and PACKAGES_NOT_FOUND in the configure output (only useful for debugging the CMake build scripts)" OFF)
Expand Down
2 changes: 1 addition & 1 deletion INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ qBittorrent - A BitTorrent client in C++ / Qt

- OpenSSL >= 1.1.1

- Qt 5.15.2 - 5.x || 6.2.0 - 6.x
- Qt 6.2.0 - 6.x

- zlib >= 1.2.11

Expand Down
25 changes: 7 additions & 18 deletions cmake/Modules/CheckPackages.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,11 @@ set_property(CACHE LibtorrentRasterbar_DIR PROPERTY TYPE PATH)
find_package(Boost ${minBoostVersion} REQUIRED)
find_package(OpenSSL ${minOpenSSLVersion} REQUIRED)
find_package(ZLIB ${minZlibVersion} REQUIRED)
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()
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()
13 changes: 7 additions & 6 deletions src/app/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,6 @@ Application::Application(int &argc, char **argv)
setOrganizationDomain(u"qbittorrent.org"_s);
#if !defined(DISABLE_GUI)
setDesktopFileName(u"org.qbittorrent.qBittorrent"_s);
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
setAttribute(Qt::AA_UseHighDpiPixmaps, true); // opt-in to the high DPI pixmap support
#endif
setQuitOnLastWindowClosed(false);
QPixmapCache::setCacheLimit(PIXMAP_CACHE_SIZE);
#endif
Expand Down Expand Up @@ -1037,11 +1034,15 @@ void Application::initializeTranslation()
// Load translation
const QString localeStr = pref->getLocale();

if (m_qtTranslator.load((u"qtbase_" + localeStr), QLibraryInfo::location(QLibraryInfo::TranslationsPath)) ||
m_qtTranslator.load((u"qt_" + localeStr), QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
qDebug("Qt %s locale recognized, using translation.", qUtf8Printable(localeStr));
if (m_qtTranslator.load((u"qtbase_" + localeStr), QLibraryInfo::path(QLibraryInfo::TranslationsPath))
|| m_qtTranslator.load((u"qt_" + localeStr), QLibraryInfo::path(QLibraryInfo::TranslationsPath)))
{
qDebug("Qt %s locale recognized, using translation.", qUtf8Printable(localeStr));
}
else
{
qDebug("Qt %s locale unrecognized, using default (en).", qUtf8Printable(localeStr));
}

installTranslator(&m_qtTranslator);

Expand Down
3 changes: 0 additions & 3 deletions src/app/filelogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,6 @@ void FileLogger::addLogMessage(const Log::Msg &msg)
if (!m_logFile.isOpen()) return;

QTextStream stream(&m_logFile);
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
stream.setCodec("UTF-8");
#endif

switch (msg.type)
{
Expand Down
13 changes: 0 additions & 13 deletions src/app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,6 @@ int main(int argc, char *argv[])
// We must save it here because QApplication constructor may change it
bool isOneArg = (argc == 2);

#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) && !defined(DISABLE_GUI)
// Attribute Qt::AA_EnableHighDpiScaling must be set before QCoreApplication is created
if (qgetenv("QT_ENABLE_HIGHDPI_SCALING").isEmpty() && qgetenv("QT_AUTO_SCREEN_SCALE_FACTOR").isEmpty())
Application::setAttribute(Qt::AA_EnableHighDpiScaling, true);
// HighDPI scale factor policy must be set before QGuiApplication is created
if (qgetenv("QT_SCALE_FACTOR_ROUNDING_POLICY").isEmpty())
Application::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
#endif

try
{
// Create Application
Expand Down Expand Up @@ -212,10 +203,6 @@ int main(int argc, char *argv[])
// 3. https://bugreports.qt.io/browse/QTBUG-46015

qputenv("QT_BEARER_POLL_TIMEOUT", QByteArray::number(-1));
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) && !defined(DISABLE_GUI)
// this is the default in Qt6
app->setAttribute(Qt::AA_DisableWindowContextHelpButton);
#endif
#endif // Q_OS_WIN

#ifdef Q_OS_MACOS
Expand Down
1 change: 0 additions & 1 deletion src/base/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ add_library(qbt_base STATIC
bittorrent/infohash.h
bittorrent/loadtorrentparams.h
bittorrent/ltqbitarray.h
bittorrent/ltqhash.h
bittorrent/lttypecast.h
bittorrent/magneturi.h
bittorrent/nativesessionextension.h
Expand Down
2 changes: 0 additions & 2 deletions src/base/bittorrent/customstorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@
#include <libtorrent/io_context.hpp>

#include <QHash>

#include "ltqhash.h"
#else
#include <libtorrent/storage.hpp>
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/base/bittorrent/dbresumedatastorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,7 @@ namespace
query.bindValue(DB_COLUMN_NAME.placeholder, m_resumeData.name);
query.bindValue(DB_COLUMN_CATEGORY.placeholder, m_resumeData.category);
query.bindValue(DB_COLUMN_TAGS.placeholder, (m_resumeData.tags.isEmpty()
? QVariant(QVariant::String) : m_resumeData.tags.join(u","_s)));
? QString() : m_resumeData.tags.join(u","_s)));
query.bindValue(DB_COLUMN_CONTENT_LAYOUT.placeholder, Utils::String::fromEnum(m_resumeData.contentLayout));
query.bindValue(DB_COLUMN_RATIO_LIMIT.placeholder, static_cast<int>(m_resumeData.ratioLimit * 1000));
query.bindValue(DB_COLUMN_SEEDING_TIME_LIMIT.placeholder, m_resumeData.seedingTimeLimit);
Expand Down
4 changes: 0 additions & 4 deletions src/base/bittorrent/infohash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,7 @@ BitTorrent::TorrentID BitTorrent::TorrentID::fromSHA256Hash(const SHA256Hash &ha
return BaseType::UnderlyingType(static_cast<typename SHA256Hash::UnderlyingType>(hash).data());
}

#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
std::size_t BitTorrent::qHash(const BitTorrent::TorrentID &key, const std::size_t seed)
#else
uint BitTorrent::qHash(const BitTorrent::TorrentID &key, const uint seed)
#endif
{
return ::qHash(static_cast<TorrentID::BaseType>(key), seed);
}
Expand Down
4 changes: 0 additions & 4 deletions src/base/bittorrent/infohash.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,7 @@ namespace BitTorrent
WrappedType m_nativeHash;
};

#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
std::size_t qHash(const TorrentID &key, std::size_t seed = 0);
#else
uint qHash(const TorrentID &key, uint seed = 0);
#endif

bool operator==(const InfoHash &left, const InfoHash &right);
bool operator!=(const InfoHash &left, const InfoHash &right);
Expand Down
51 changes: 0 additions & 51 deletions src/base/bittorrent/ltqhash.h

This file was deleted.

7 changes: 0 additions & 7 deletions src/base/bittorrent/peeraddress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,7 @@ bool BitTorrent::operator==(const BitTorrent::PeerAddress &left, const BitTorren
return (left.ip == right.ip) && (left.port == right.port);
}

#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
std::size_t BitTorrent::qHash(const BitTorrent::PeerAddress &addr, const std::size_t seed)
{
return qHashMulti(seed, addr.ip, addr.port);
}
#else
uint BitTorrent::qHash(const BitTorrent::PeerAddress &addr, const uint seed)
{
return (::qHash(addr.ip, seed) ^ ::qHash(addr.port));
}
#endif
4 changes: 0 additions & 4 deletions src/base/bittorrent/peeraddress.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,5 @@ namespace BitTorrent
};

bool operator==(const PeerAddress &left, const PeerAddress &right);
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
std::size_t qHash(const PeerAddress &addr, std::size_t seed = 0);
#else
uint qHash(const PeerAddress &addr, uint seed = 0);
#endif
}
Loading

0 comments on commit dbe7948

Please sign in to comment.