Browse Source

Drop support of Qt 5

Also remove usage of some deprecated stuff.

PR #19338.
adaptive-webui-19844
Vladimir Golovnev 1 year ago committed by GitHub
parent
commit
dbe79484d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 22
      .github/workflows/ci_macos.yaml
  2. 22
      .github/workflows/ci_ubuntu.yaml
  3. 1
      .github/workflows/ci_windows.yaml
  4. 1
      .github/workflows/coverity-scan.yaml
  5. 2
      CMakeLists.txt
  6. 2
      INSTALL
  7. 11
      cmake/Modules/CheckPackages.cmake
  8. 11
      src/app/application.cpp
  9. 3
      src/app/filelogger.cpp
  10. 13
      src/app/main.cpp
  11. 1
      src/base/CMakeLists.txt
  12. 2
      src/base/bittorrent/customstorage.h
  13. 2
      src/base/bittorrent/dbresumedatastorage.cpp
  14. 4
      src/base/bittorrent/infohash.cpp
  15. 4
      src/base/bittorrent/infohash.h
  16. 51
      src/base/bittorrent/ltqhash.h
  17. 7
      src/base/bittorrent/peeraddress.cpp
  18. 4
      src/base/bittorrent/peeraddress.h
  19. 65
      src/base/bittorrent/sessionimpl.cpp
  20. 13
      src/base/bittorrent/sessionimpl.h
  21. 4
      src/base/bittorrent/torrent.cpp
  22. 4
      src/base/bittorrent/torrent.h
  23. 1
      src/base/bittorrent/torrentimpl.cpp
  24. 4
      src/base/bittorrent/tracker.cpp
  25. 4
      src/base/bittorrent/tracker.h
  26. 4
      src/base/bittorrent/trackerentry.cpp
  27. 4
      src/base/bittorrent/trackerentry.h
  28. 8
      src/base/digest32.h
  29. 4
      src/base/global.h
  30. 7
      src/base/net/downloadmanager.cpp
  31. 4
      src/base/net/downloadmanager.h
  32. 4
      src/base/net/geoipdatabase.cpp
  33. 4
      src/base/path.cpp
  34. 4
      src/base/path.h
  35. 56
      src/base/preferences.cpp
  36. 4
      src/base/settingsstorage.cpp
  37. 2
      src/base/torrentfileswatcher.cpp
  38. 18
      src/base/utils/string.cpp
  39. 10
      src/gui/CMakeLists.txt
  40. 14
      src/gui/addnewtorrentdialog.cpp
  41. 4
      src/gui/cookiesdialog.cpp
  42. 2
      src/gui/fspathedit.cpp
  43. 4
      src/gui/mainwindow.cpp
  44. 4
      src/gui/previewselectdialog.cpp
  45. 7
      src/gui/properties/peerlistwidget.cpp
  46. 4
      src/gui/properties/piecesbar.cpp
  47. 4
      src/gui/properties/piecesbar.h
  48. 12
      src/gui/properties/proptabbar.cpp
  49. 5
      src/gui/rss/automatedrssdownloader.cpp
  50. 4
      src/gui/rss/feedlistwidget.cpp
  51. 7
      src/gui/torrentcontentmodel.cpp
  52. 6
      src/gui/transferlistwidget.cpp
  53. 10
      src/webui/api/synccontroller.cpp
  54. 8
      src/webui/api/torrentscontroller.cpp
  55. 4
      test/CMakeLists.txt

22
.github/workflows/ci_macos.yaml

@ -19,7 +19,7 @@ jobs:
matrix: matrix:
libt_version: ["2.0.9", "1.2.19"] libt_version: ["2.0.9", "1.2.19"]
qbt_gui: ["GUI=ON", "GUI=OFF"] qbt_gui: ["GUI=ON", "GUI=OFF"]
qt_version: ["5.15.2", "6.5.0"] qt_version: ["6.5.0"]
exclude: exclude:
- libt_version: "1.2.19" - libt_version: "1.2.19"
qt_version: "6.5.0" qt_version: "6.5.0"
@ -88,25 +88,6 @@ jobs:
cmake --build build cmake --build build
sudo cmake --install 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) - name: Build qBittorrent (Qt6)
if: startsWith(matrix.qt_version, 6) if: startsWith(matrix.qt_version, 6)
run: | run: |
@ -119,7 +100,6 @@ jobs:
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DBOOST_ROOT="${{ env.boost_path }}" \ -DBOOST_ROOT="${{ env.boost_path }}" \
-DOPENSSL_ROOT_DIR="${{ env.openssl_root }}" \ -DOPENSSL_ROOT_DIR="${{ env.openssl_root }}" \
-DQT6=ON \
-DTESTING=ON \ -DTESTING=ON \
-DVERBOSE_CONFIGURE=ON \ -DVERBOSE_CONFIGURE=ON \
-D${{ matrix.qbt_gui }} -D${{ matrix.qbt_gui }}

22
.github/workflows/ci_ubuntu.yaml

@ -20,7 +20,7 @@ jobs:
matrix: matrix:
libt_version: ["2.0.9", "1.2.19"] libt_version: ["2.0.9", "1.2.19"]
qbt_gui: ["GUI=ON", "GUI=OFF"] qbt_gui: ["GUI=ON", "GUI=OFF"]
qt_version: ["5.15.2", "6.2.0"] qt_version: ["6.2.0"]
exclude: exclude:
- libt_version: "1.2.19" - libt_version: "1.2.19"
qt_version: "6.2.0" qt_version: "6.2.0"
@ -75,25 +75,6 @@ jobs:
config-file: ./.github/workflows/helper/codeql/cpp.yaml config-file: ./.github/workflows/helper/codeql/cpp.yaml
languages: cpp 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) - name: Build qBittorrent (Qt6)
if: startsWith(matrix.qt_version, 6) if: startsWith(matrix.qt_version, 6)
run: | run: |
@ -105,7 +86,6 @@ jobs:
-DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCMAKE_INSTALL_PREFIX="/usr" \ -DCMAKE_INSTALL_PREFIX="/usr" \
-DQT6=ON \
-DTESTING=ON \ -DTESTING=ON \
-DVERBOSE_CONFIGURE=ON \ -DVERBOSE_CONFIGURE=ON \
-D${{ matrix.qbt_gui }} -D${{ matrix.qbt_gui }}

1
.github/workflows/ci_windows.yaml

@ -118,7 +118,6 @@ jobs:
-DBOOST_ROOT="${{ env.boost_path }}" ` -DBOOST_ROOT="${{ env.boost_path }}" `
-DLibtorrentRasterbar_DIR="${{ env.libtorrent_path }}/lib/cmake/LibtorrentRasterbar" ` -DLibtorrentRasterbar_DIR="${{ env.libtorrent_path }}/lib/cmake/LibtorrentRasterbar" `
-DMSVC_RUNTIME_DYNAMIC=OFF ` -DMSVC_RUNTIME_DYNAMIC=OFF `
-DQT6=ON `
-DTESTING=ON ` -DTESTING=ON `
-DVCPKG_TARGET_TRIPLET=x64-windows-static-release ` -DVCPKG_TARGET_TRIPLET=x64-windows-static-release `
-DVERBOSE_CONFIGURE=ON ` -DVERBOSE_CONFIGURE=ON `

1
.github/workflows/coverity-scan.yaml

@ -62,7 +62,6 @@ jobs:
-G "Ninja" \ -G "Ninja" \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DGUI=ON \ -DGUI=ON \
-DQT6=ON \
-DVERBOSE_CONFIGURE=ON -DVERBOSE_CONFIGURE=ON
export PATH="$(pwd)/coverity_tool/bin:$PATH" export PATH="$(pwd)/coverity_tool/bin:$PATH"
cov-build --dir cov-int cmake --build build cov-build --dir cov-int cmake --build build

2
CMakeLists.txt

@ -8,7 +8,6 @@ project(qBittorrent
# 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.71) set(minBoostVersion 1.71)
set(minQt5Version 5.15.2)
set(minQt6Version 6.2) set(minQt6Version 6.2)
set(minOpenSSLVersion 1.1.1) set(minOpenSSLVersion 1.1.1)
set(minLibtorrent1Version 1.2.19) set(minLibtorrent1Version 1.2.19)
@ -25,7 +24,6 @@ include(FeatureOptionsSetup)
# features, list is loosely sorted by user's interests # features, list is loosely sorted by user's interests
feature_option(GUI "Build GUI application" ON) feature_option(GUI "Build GUI application" ON)
feature_option(WEBUI "Enable built-in HTTP server for remote control" 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(STACKTRACE "Enable stacktrace support" ON)
feature_option(TESTING "Build internal testing suite" OFF) 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) 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)

2
INSTALL

@ -11,7 +11,7 @@ qBittorrent - A BitTorrent client in C++ / Qt
- OpenSSL >= 1.1.1 - 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 - zlib >= 1.2.11

11
cmake/Modules/CheckPackages.cmake

@ -46,7 +46,6 @@ 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)
if (QT6)
find_package(Qt6 ${minQt6Version} REQUIRED COMPONENTS Core Network Sql Xml LinguistTools) find_package(Qt6 ${minQt6Version} REQUIRED COMPONENTS Core Network Sql Xml LinguistTools)
if (DBUS) if (DBUS)
find_package(Qt6 ${minQt6Version} REQUIRED COMPONENTS DBus) find_package(Qt6 ${minQt6Version} REQUIRED COMPONENTS DBus)
@ -55,13 +54,3 @@ if (QT6)
PURPOSE "Required by the DBUS feature" PURPOSE "Required by the DBUS feature"
) )
endif() 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()

11
src/app/application.cpp

@ -248,9 +248,6 @@ Application::Application(int &argc, char **argv)
setOrganizationDomain(u"qbittorrent.org"_s); setOrganizationDomain(u"qbittorrent.org"_s);
#if !defined(DISABLE_GUI) #if !defined(DISABLE_GUI)
setDesktopFileName(u"org.qbittorrent.qBittorrent"_s); 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); setQuitOnLastWindowClosed(false);
QPixmapCache::setCacheLimit(PIXMAP_CACHE_SIZE); QPixmapCache::setCacheLimit(PIXMAP_CACHE_SIZE);
#endif #endif
@ -1037,11 +1034,15 @@ void Application::initializeTranslation()
// Load translation // Load translation
const QString localeStr = pref->getLocale(); const QString localeStr = pref->getLocale();
if (m_qtTranslator.load((u"qtbase_" + localeStr), QLibraryInfo::location(QLibraryInfo::TranslationsPath)) || if (m_qtTranslator.load((u"qtbase_" + localeStr), QLibraryInfo::path(QLibraryInfo::TranslationsPath))
m_qtTranslator.load((u"qt_" + localeStr), QLibraryInfo::location(QLibraryInfo::TranslationsPath))) || m_qtTranslator.load((u"qt_" + localeStr), QLibraryInfo::path(QLibraryInfo::TranslationsPath)))
{
qDebug("Qt %s locale recognized, using translation.", qUtf8Printable(localeStr)); qDebug("Qt %s locale recognized, using translation.", qUtf8Printable(localeStr));
}
else else
{
qDebug("Qt %s locale unrecognized, using default (en).", qUtf8Printable(localeStr)); qDebug("Qt %s locale unrecognized, using default (en).", qUtf8Printable(localeStr));
}
installTranslator(&m_qtTranslator); installTranslator(&m_qtTranslator);

3
src/app/filelogger.cpp

@ -127,9 +127,6 @@ void FileLogger::addLogMessage(const Log::Msg &msg)
if (!m_logFile.isOpen()) return; if (!m_logFile.isOpen()) return;
QTextStream stream(&m_logFile); QTextStream stream(&m_logFile);
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
stream.setCodec("UTF-8");
#endif
switch (msg.type) switch (msg.type)
{ {

13
src/app/main.cpp

@ -105,15 +105,6 @@ int main(int argc, char *argv[])
// We must save it here because QApplication constructor may change it // We must save it here because QApplication constructor may change it
bool isOneArg = (argc == 2); 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 try
{ {
// Create Application // Create Application
@ -212,10 +203,6 @@ int main(int argc, char *argv[])
// 3. https://bugreports.qt.io/browse/QTBUG-46015 // 3. https://bugreports.qt.io/browse/QTBUG-46015
qputenv("QT_BEARER_POLL_TIMEOUT", QByteArray::number(-1)); 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 #endif // Q_OS_WIN
#ifdef Q_OS_MACOS #ifdef Q_OS_MACOS

1
src/base/CMakeLists.txt

@ -20,7 +20,6 @@ add_library(qbt_base STATIC
bittorrent/infohash.h bittorrent/infohash.h
bittorrent/loadtorrentparams.h bittorrent/loadtorrentparams.h
bittorrent/ltqbitarray.h bittorrent/ltqbitarray.h
bittorrent/ltqhash.h
bittorrent/lttypecast.h bittorrent/lttypecast.h
bittorrent/magneturi.h bittorrent/magneturi.h
bittorrent/nativesessionextension.h bittorrent/nativesessionextension.h

2
src/base/bittorrent/customstorage.h

@ -41,8 +41,6 @@
#include <libtorrent/io_context.hpp> #include <libtorrent/io_context.hpp>
#include <QHash> #include <QHash>
#include "ltqhash.h"
#else #else
#include <libtorrent/storage.hpp> #include <libtorrent/storage.hpp>
#endif #endif

2
src/base/bittorrent/dbresumedatastorage.cpp

@ -848,7 +848,7 @@ namespace
query.bindValue(DB_COLUMN_NAME.placeholder, m_resumeData.name); query.bindValue(DB_COLUMN_NAME.placeholder, m_resumeData.name);
query.bindValue(DB_COLUMN_CATEGORY.placeholder, m_resumeData.category); query.bindValue(DB_COLUMN_CATEGORY.placeholder, m_resumeData.category);
query.bindValue(DB_COLUMN_TAGS.placeholder, (m_resumeData.tags.isEmpty() 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_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_RATIO_LIMIT.placeholder, static_cast<int>(m_resumeData.ratioLimit * 1000));
query.bindValue(DB_COLUMN_SEEDING_TIME_LIMIT.placeholder, m_resumeData.seedingTimeLimit); query.bindValue(DB_COLUMN_SEEDING_TIME_LIMIT.placeholder, m_resumeData.seedingTimeLimit);

4
src/base/bittorrent/infohash.cpp

@ -111,11 +111,7 @@ BitTorrent::TorrentID BitTorrent::TorrentID::fromSHA256Hash(const SHA256Hash &ha
return BaseType::UnderlyingType(static_cast<typename SHA256Hash::UnderlyingType>(hash).data()); 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) 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); return ::qHash(static_cast<TorrentID::BaseType>(key), seed);
} }

4
src/base/bittorrent/infohash.h

@ -87,11 +87,7 @@ namespace BitTorrent
WrappedType m_nativeHash; WrappedType m_nativeHash;
}; };
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
std::size_t qHash(const TorrentID &key, std::size_t seed = 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);
bool operator!=(const InfoHash &left, const InfoHash &right); bool operator!=(const InfoHash &left, const InfoHash &right);

51
src/base/bittorrent/ltqhash.h

@ -1,51 +0,0 @@
/*
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2020 Vladimir Golovnev <glassez@yandex.ru>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition, as a special exception, the copyright holders give permission to
* link this program with the OpenSSL project's "OpenSSL" library (or with
* modified versions of it that use the same license as the "OpenSSL" library),
* and distribute the linked executables. You must obey the GNU General Public
* License in all respects for all of the code used other than "OpenSSL". If you
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*/
#pragma once
#include <QtGlobal>
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
#include <functional>
#include <libtorrent/units.hpp>
#include <QHash>
namespace libtorrent
{
namespace aux
{
template <typename T, typename Tag>
uint qHash(const strong_typedef<T, Tag> &key, const uint seed = 0)
{
return ::qHash((std::hash<strong_typedef<T, Tag>> {})(key), seed);
}
}
}
#endif

7
src/base/bittorrent/peeraddress.cpp

@ -77,14 +77,7 @@ bool BitTorrent::operator==(const BitTorrent::PeerAddress &left, const BitTorren
return (left.ip == right.ip) && (left.port == right.port); 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) std::size_t BitTorrent::qHash(const BitTorrent::PeerAddress &addr, const std::size_t seed)
{ {
return qHashMulti(seed, addr.ip, addr.port); 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
src/base/bittorrent/peeraddress.h

@ -45,9 +45,5 @@ namespace BitTorrent
}; };
bool operator==(const PeerAddress &left, const PeerAddress &right); 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); std::size_t qHash(const PeerAddress &addr, std::size_t seed = 0);
#else
uint qHash(const PeerAddress &addr, uint seed = 0);
#endif
} }

65
src/base/bittorrent/sessionimpl.cpp

@ -66,9 +66,6 @@
#include <QJsonObject> #include <QJsonObject>
#include <QJsonValue> #include <QJsonValue>
#include <QNetworkAddressEntry> #include <QNetworkAddressEntry>
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
#include <QNetworkConfigurationManager>
#endif
#include <QNetworkInterface> #include <QNetworkInterface>
#include <QRegularExpression> #include <QRegularExpression>
#include <QString> #include <QString>
@ -118,24 +115,6 @@ const Path CATEGORIES_FILE_NAME {u"categories.json"_s};
const int MAX_PROCESSING_RESUMEDATA_COUNT = 50; const int MAX_PROCESSING_RESUMEDATA_COUNT = 50;
const int STATISTICS_SAVE_INTERVAL = std::chrono::milliseconds(15min).count(); const int STATISTICS_SAVE_INTERVAL = std::chrono::milliseconds(15min).count();
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
namespace std
{
uint qHash(const std::string &key, uint seed = 0)
{
return ::qHash(std::hash<std::string> {}(key), seed);
}
}
namespace libtorrent
{
uint qHash(const libtorrent::torrent_handle &key)
{
return static_cast<uint>(libtorrent::hash_value(key));
}
}
#endif
namespace namespace
{ {
const char PEER_ID[] = "qB"; const char PEER_ID[] = "qB";
@ -537,9 +516,6 @@ SessionImpl::SessionImpl(QObject *parent)
, m_ioThread {new QThread} , m_ioThread {new QThread}
, m_asyncWorker {new QThreadPool(this)} , m_asyncWorker {new QThreadPool(this)}
, m_recentErroredTorrentsTimer {new QTimer(this)} , m_recentErroredTorrentsTimer {new QTimer(this)}
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
, m_networkManager {new QNetworkConfigurationManager(this)}
#endif
{ {
// It is required to perform async access to libtorrent sequentially // It is required to perform async access to libtorrent sequentially
m_asyncWorker->setMaxThreadCount(1); m_asyncWorker->setMaxThreadCount(1);
@ -580,14 +556,6 @@ SessionImpl::SessionImpl(QObject *parent)
, &Net::ProxyConfigurationManager::proxyConfigurationChanged , &Net::ProxyConfigurationManager::proxyConfigurationChanged
, this, &SessionImpl::configureDeferred); , this, &SessionImpl::configureDeferred);
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
// Network configuration monitor
connect(m_networkManager, &QNetworkConfigurationManager::onlineStateChanged, this, &SessionImpl::networkOnlineStateChanged);
connect(m_networkManager, &QNetworkConfigurationManager::configurationAdded, this, &SessionImpl::networkConfigurationChange);
connect(m_networkManager, &QNetworkConfigurationManager::configurationRemoved, this, &SessionImpl::networkConfigurationChange);
connect(m_networkManager, &QNetworkConfigurationManager::configurationChanged, this, &SessionImpl::networkConfigurationChange);
#endif
m_fileSearcher = new FileSearcher; m_fileSearcher = new FileSearcher;
m_fileSearcher->moveToThread(m_ioThread.get()); m_fileSearcher->moveToThread(m_ioThread.get());
connect(m_ioThread.get(), &QThread::finished, m_fileSearcher, &QObject::deleteLater); connect(m_ioThread.get(), &QThread::finished, m_fileSearcher, &QObject::deleteLater);
@ -3148,13 +3116,7 @@ void SessionImpl::saveResumeData()
// clear queued storage move jobs except the current ongoing one // clear queued storage move jobs except the current ongoing one
if (m_moveStorageQueue.size() > 1) if (m_moveStorageQueue.size() > 1)
{
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
m_moveStorageQueue = m_moveStorageQueue.mid(0, 1);
#else
m_moveStorageQueue.resize(1); m_moveStorageQueue.resize(1);
#endif
}
QElapsedTimer timer; QElapsedTimer timer;
timer.start(); timer.start();
@ -3277,29 +3239,6 @@ void SessionImpl::setDownloadPath(const Path &path)
torrent->handleCategoryOptionsChanged(); torrent->handleCategoryOptionsChanged();
} }
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
void SessionImpl::networkOnlineStateChanged(const bool online)
{
LogMsg(tr("System network status changed to %1", "e.g: System network status changed to ONLINE").arg(online ? tr("ONLINE") : tr("OFFLINE")), Log::INFO);
}
void SessionImpl::networkConfigurationChange(const QNetworkConfiguration &cfg)
{
const QString configuredInterfaceName = networkInterface();
// Empty means "Any Interface". In this case libtorrent has binded to 0.0.0.0 so any change to any interface will
// be automatically picked up. Otherwise we would rebinding here to 0.0.0.0 again.
if (configuredInterfaceName.isEmpty()) return;
const QString changedInterface = cfg.name();
if (configuredInterfaceName == changedInterface)
{
LogMsg(tr("Network configuration of %1 has changed, refreshing session binding", "e.g: Network configuration of tun0 has changed, refreshing session binding").arg(changedInterface), Log::INFO);
configureListeningInterface();
}
}
#endif
QStringList SessionImpl::getListeningIPs() const QStringList SessionImpl::getListeningIPs() const
{ {
QStringList IPs; QStringList IPs;
@ -6201,12 +6140,8 @@ void SessionImpl::processTrackerStatuses()
const QMap<TrackerEntry::Endpoint, int> &updateInfo = updatedTrackersIter.value(); const QMap<TrackerEntry::Endpoint, int> &updateInfo = updatedTrackersIter.value();
TrackerEntry trackerEntry = torrent->updateTrackerEntry(announceEntry, updateInfo); TrackerEntry trackerEntry = torrent->updateTrackerEntry(announceEntry, updateInfo);
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
updatedTrackerEntries[trackerEntry.url] = std::move(trackerEntry);
#else
const QString url = trackerEntry.url; const QString url = trackerEntry.url;
updatedTrackerEntries.emplace(url, std::move(trackerEntry)); updatedTrackerEntries.emplace(url, std::move(trackerEntry));
#endif
} }
emit trackerEntriesUpdated(torrent, updatedTrackerEntries); emit trackerEntriesUpdated(torrent, updatedTrackerEntries);

13
src/base/bittorrent/sessionimpl.h

@ -57,10 +57,6 @@
#include "torrentinfo.h" #include "torrentinfo.h"
#include "trackerentry.h" #include "trackerentry.h"
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
class QNetworkConfiguration;
class QNetworkConfigurationManager;
#endif
class QString; class QString;
class QThread; class QThread;
class QThreadPool; class QThreadPool;
@ -486,12 +482,6 @@ namespace BitTorrent
void handleDownloadFinished(const Net::DownloadResult &result); void handleDownloadFinished(const Net::DownloadResult &result);
void fileSearchFinished(const TorrentID &id, const Path &savePath, const PathList &fileNames); void fileSearchFinished(const TorrentID &id, const Path &savePath, const PathList &fileNames);
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
// Session reconfiguration triggers
void networkOnlineStateChanged(bool online);
void networkConfigurationChange(const QNetworkConfiguration &);
#endif
private: private:
struct ResumeSessionContext; struct ResumeSessionContext;
@ -778,9 +768,6 @@ namespace BitTorrent
SessionStatus m_status; SessionStatus m_status;
CacheStatus m_cacheStatus; CacheStatus m_cacheStatus;
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
QNetworkConfigurationManager *m_networkManager = nullptr;
#endif
QList<MoveStorageJob> m_moveStorageQueue; QList<MoveStorageJob> m_moveStorageQueue;

4
src/base/bittorrent/torrent.cpp

@ -35,11 +35,7 @@
namespace BitTorrent namespace BitTorrent
{ {
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
std::size_t qHash(const TorrentState key, const std::size_t seed) std::size_t qHash(const TorrentState key, const std::size_t seed)
#else
uint qHash(const TorrentState key, const uint seed)
#endif
{ {
return ::qHash(static_cast<std::underlying_type_t<TorrentState>>(key), seed); return ::qHash(static_cast<std::underlying_type_t<TorrentState>>(key), seed);
} }

4
src/base/bittorrent/torrent.h

@ -100,11 +100,7 @@ namespace BitTorrent
Error Error
}; };
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
std::size_t qHash(TorrentState key, std::size_t seed = 0); std::size_t qHash(TorrentState key, std::size_t seed = 0);
#else
uint qHash(TorrentState key, uint seed = 0);
#endif
class Torrent : public TorrentContentHandler class Torrent : public TorrentContentHandler
{ {

1
src/base/bittorrent/torrentimpl.cpp

@ -62,7 +62,6 @@
#include "extensiondata.h" #include "extensiondata.h"
#include "loadtorrentparams.h" #include "loadtorrentparams.h"
#include "ltqbitarray.h" #include "ltqbitarray.h"
#include "ltqhash.h"
#include "lttypecast.h" #include "lttypecast.h"
#include "peeraddress.h" #include "peeraddress.h"
#include "peerinfo.h" #include "peerinfo.h"

4
src/base/bittorrent/tracker.cpp

@ -140,11 +140,7 @@ namespace BitTorrent
return !(left == right); return !(left == right);
} }
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
std::size_t qHash(const Peer &key, const std::size_t seed) std::size_t qHash(const Peer &key, const std::size_t seed)
#else
uint qHash(const Peer &key, const uint seed)
#endif
{ {
return qHash(key.uniqueID(), seed); return qHash(key.uniqueID(), seed);
} }

4
src/base/bittorrent/tracker.h

@ -65,11 +65,7 @@ namespace BitTorrent
bool operator==(const Peer &left, const Peer &right); bool operator==(const Peer &left, const Peer &right);
bool operator!=(const Peer &left, const Peer &right); bool operator!=(const Peer &left, const Peer &right);
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
std::size_t qHash(const Peer &key, std::size_t seed = 0); std::size_t qHash(const Peer &key, std::size_t seed = 0);
#else
uint qHash(const Peer &key, uint seed = 0);
#endif
// *Basic* Bittorrent tracker implementation // *Basic* Bittorrent tracker implementation
// [BEP-3] The BitTorrent Protocol Specification // [BEP-3] The BitTorrent Protocol Specification

4
src/base/bittorrent/trackerentry.cpp

@ -61,11 +61,7 @@ bool BitTorrent::operator==(const TrackerEntry &left, const TrackerEntry &right)
return (left.url == right.url); return (left.url == right.url);
} }
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
std::size_t BitTorrent::qHash(const TrackerEntry &key, const std::size_t seed) std::size_t BitTorrent::qHash(const TrackerEntry &key, const std::size_t seed)
#else
uint BitTorrent::qHash(const TrackerEntry &key, const uint seed)
#endif
{ {
return ::qHash(key.url, seed); return ::qHash(key.url, seed);
} }

4
src/base/bittorrent/trackerentry.h

@ -79,9 +79,5 @@ namespace BitTorrent
QVector<TrackerEntry> parseTrackerEntries(QStringView str); QVector<TrackerEntry> parseTrackerEntries(QStringView str);
bool operator==(const TrackerEntry &left, const TrackerEntry &right); bool operator==(const TrackerEntry &left, const TrackerEntry &right);
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
std::size_t qHash(const TrackerEntry &key, std::size_t seed = 0); std::size_t qHash(const TrackerEntry &key, std::size_t seed = 0);
#else
uint qHash(const TrackerEntry &key, uint seed = 0);
#endif
} }

8
src/base/digest32.h

@ -157,16 +157,8 @@ bool operator<(const Digest32<N> &left, const Digest32<N> &right)
< static_cast<typename Digest32<N>::UnderlyingType>(right); < static_cast<typename Digest32<N>::UnderlyingType>(right);
} }
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
template <int N> template <int N>
std::size_t qHash(const Digest32<N> &key, const std::size_t seed = 0) std::size_t qHash(const Digest32<N> &key, const std::size_t seed = 0)
{ {
return ::qHash(static_cast<typename Digest32<N>::UnderlyingType>(key), seed); return ::qHash(static_cast<typename Digest32<N>::UnderlyingType>(key), seed);
} }
#else
template <int N>
uint qHash(const Digest32<N> &key, const uint seed = 0)
{
return ::qHash(std::hash<typename Digest32<N>::UnderlyingType> {}(key), seed);
}
#endif

4
src/base/global.h

@ -50,11 +50,7 @@ void asConst(const T &&) = delete;
// https://doc.qt.io/qt-6/qstring.html#operator-22-22_s // https://doc.qt.io/qt-6/qstring.html#operator-22-22_s
inline QString operator"" _s(const char16_t *str, const std::size_t size) inline QString operator"" _s(const char16_t *str, const std::size_t size)
{ {
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
return QString::fromRawData(reinterpret_cast<const QChar *>(str), static_cast<int>(size));
#else
return operator""_qs(str, size); return operator""_qs(str, size);
#endif
} }
#else #else
using namespace Qt::Literals::StringLiterals; using namespace Qt::Literals::StringLiterals;

7
src/base/net/downloadmanager.cpp

@ -376,17 +376,10 @@ Net::ServiceID Net::ServiceID::fromURL(const QUrl &url)
return {url.host(), url.port(80)}; return {url.host(), url.port(80)};
} }
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
std::size_t Net::qHash(const ServiceID &serviceID, const std::size_t seed) std::size_t Net::qHash(const ServiceID &serviceID, const std::size_t seed)
{ {
return qHashMulti(seed, serviceID.hostName, serviceID.port); return qHashMulti(seed, serviceID.hostName, serviceID.port);
} }
#else
uint Net::qHash(const ServiceID &serviceID, const uint seed)
{
return ::qHash(serviceID.hostName, seed) ^ ::qHash(serviceID.port);
}
#endif
bool Net::operator==(const ServiceID &lhs, const ServiceID &rhs) bool Net::operator==(const ServiceID &lhs, const ServiceID &rhs)
{ {

4
src/base/net/downloadmanager.h

@ -54,11 +54,7 @@ namespace Net
static ServiceID fromURL(const QUrl &url); static ServiceID fromURL(const QUrl &url);
}; };
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
std::size_t qHash(const ServiceID &serviceID, std::size_t seed = 0); std::size_t qHash(const ServiceID &serviceID, std::size_t seed = 0);
#else
uint qHash(const ServiceID &serviceID, uint seed = 0);
#endif
bool operator==(const ServiceID &lhs, const ServiceID &rhs); bool operator==(const ServiceID &lhs, const ServiceID &rhs);
enum class DownloadStatus enum class DownloadStatus

4
src/base/net/geoipdatabase.cpp

@ -484,7 +484,7 @@ QVariant GeoIPDatabase::readMapValue(quint32 &offset, const quint32 count) const
const QString key = field.toString(); const QString key = field.toString();
field = readDataField(offset); field = readDataField(offset);
if (field.userType() == QVariant::Invalid) if (field.userType() == QMetaType::UnknownType)
return {}; return {};
map[key] = field; map[key] = field;
@ -500,7 +500,7 @@ QVariant GeoIPDatabase::readArrayValue(quint32 &offset, const quint32 count) con
for (quint32 i = 0; i < count; ++i) for (quint32 i = 0; i < count; ++i)
{ {
const QVariant field = readDataField(offset); const QVariant field = readDataField(offset);
if (field.userType() == QVariant::Invalid) if (field.userType() == QMetaType::UnknownType)
return {}; return {};
array.append(field); array.append(field);

4
src/base/path.cpp

@ -377,11 +377,7 @@ QDataStream &operator>>(QDataStream &in, Path &path)
return in; return in;
} }
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
std::size_t qHash(const Path &key, const std::size_t seed) std::size_t qHash(const Path &key, const std::size_t seed)
#else
uint qHash(const Path &key, const uint seed)
#endif
{ {
return ::qHash(key.data(), seed); return ::qHash(key.data(), seed);
} }

4
src/base/path.h

@ -101,8 +101,4 @@ Path operator+(const Path &lhs, QStringView rhs);
QDataStream &operator<<(QDataStream &out, const Path &path); QDataStream &operator<<(QDataStream &out, const Path &path);
QDataStream &operator>>(QDataStream &in, Path &path); QDataStream &operator>>(QDataStream &in, Path &path);
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
std::size_t qHash(const Path &key, std::size_t seed = 0); std::size_t qHash(const Path &key, std::size_t seed = 0);
#else
uint qHash(const Path &key, uint seed = 0);
#endif

56
src/base/preferences.cpp

@ -1671,11 +1671,7 @@ void Preferences::setMainLastDir(const Path &path)
QByteArray Preferences::getPeerListState() const QByteArray Preferences::getPeerListState() const
{ {
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
return value<QByteArray>(u"GUI/Qt6/TorrentProperties/PeerListState"_s); return value<QByteArray>(u"GUI/Qt6/TorrentProperties/PeerListState"_s);
#else
return value<QByteArray>(u"TorrentProperties/Peers/qt5/PeerListState"_s);
#endif
} }
void Preferences::setPeerListState(const QByteArray &state) void Preferences::setPeerListState(const QByteArray &state)
@ -1683,11 +1679,7 @@ void Preferences::setPeerListState(const QByteArray &state)
if (state == getPeerListState()) if (state == getPeerListState())
return; return;
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
setValue(u"GUI/Qt6/TorrentProperties/PeerListState"_s, state); setValue(u"GUI/Qt6/TorrentProperties/PeerListState"_s, state);
#else
setValue(u"TorrentProperties/Peers/qt5/PeerListState"_s, state);
#endif
} }
QString Preferences::getPropSplitterSizes() const QString Preferences::getPropSplitterSizes() const
@ -1705,11 +1697,7 @@ void Preferences::setPropSplitterSizes(const QString &sizes)
QByteArray Preferences::getPropFileListState() const QByteArray Preferences::getPropFileListState() const
{ {
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
return value<QByteArray>(u"GUI/Qt6/TorrentProperties/FilesListState"_s); return value<QByteArray>(u"GUI/Qt6/TorrentProperties/FilesListState"_s);
#else
return value<QByteArray>(u"TorrentProperties/qt5/FilesListState"_s);
#endif
} }
void Preferences::setPropFileListState(const QByteArray &state) void Preferences::setPropFileListState(const QByteArray &state)
@ -1717,11 +1705,7 @@ void Preferences::setPropFileListState(const QByteArray &state)
if (state == getPropFileListState()) if (state == getPropFileListState())
return; return;
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
setValue(u"GUI/Qt6/TorrentProperties/FilesListState"_s, state); setValue(u"GUI/Qt6/TorrentProperties/FilesListState"_s, state);
#else
setValue(u"TorrentProperties/qt5/FilesListState"_s, state);
#endif
} }
int Preferences::getPropCurTab() const int Preferences::getPropCurTab() const
@ -1752,11 +1736,7 @@ void Preferences::setPropVisible(const bool visible)
QByteArray Preferences::getPropTrackerListState() const QByteArray Preferences::getPropTrackerListState() const
{ {
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
return value<QByteArray>(u"GUI/Qt6/TorrentProperties/TrackerListState"_s); return value<QByteArray>(u"GUI/Qt6/TorrentProperties/TrackerListState"_s);
#else
return value<QByteArray>(u"TorrentProperties/Trackers/qt5/TrackerListState"_s);
#endif
} }
void Preferences::setPropTrackerListState(const QByteArray &state) void Preferences::setPropTrackerListState(const QByteArray &state)
@ -1764,11 +1744,7 @@ void Preferences::setPropTrackerListState(const QByteArray &state)
if (state == getPropTrackerListState()) if (state == getPropTrackerListState())
return; return;
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
setValue(u"GUI/Qt6/TorrentProperties/TrackerListState"_s, state); setValue(u"GUI/Qt6/TorrentProperties/TrackerListState"_s, state);
#else
setValue(u"TorrentProperties/Trackers/qt5/TrackerListState"_s, state);
#endif
} }
QStringList Preferences::getRssOpenFolders() const QStringList Preferences::getRssOpenFolders() const
@ -1786,11 +1762,7 @@ void Preferences::setRssOpenFolders(const QStringList &folders)
QByteArray Preferences::getRssSideSplitterState() const QByteArray Preferences::getRssSideSplitterState() const
{ {
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
return value<QByteArray>(u"GUI/Qt6/RSSWidget/SideSplitterState"_s); return value<QByteArray>(u"GUI/Qt6/RSSWidget/SideSplitterState"_s);
#else
return value<QByteArray>(u"GUI/RSSWidget/qt5/splitter_h"_s);
#endif
} }
void Preferences::setRssSideSplitterState(const QByteArray &state) void Preferences::setRssSideSplitterState(const QByteArray &state)
@ -1798,20 +1770,12 @@ void Preferences::setRssSideSplitterState(const QByteArray &state)
if (state == getRssSideSplitterState()) if (state == getRssSideSplitterState())
return; return;
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
setValue(u"GUI/Qt6/RSSWidget/SideSplitterState"_s, state); setValue(u"GUI/Qt6/RSSWidget/SideSplitterState"_s, state);
#else
setValue(u"GUI/RSSWidget/qt5/splitter_h"_s, state);
#endif
} }
QByteArray Preferences::getRssMainSplitterState() const QByteArray Preferences::getRssMainSplitterState() const
{ {
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
return value<QByteArray>(u"GUI/Qt6/RSSWidget/MainSplitterState"_s); return value<QByteArray>(u"GUI/Qt6/RSSWidget/MainSplitterState"_s);
#else
return value<QByteArray>(u"GUI/RSSWidget/qt5/splitterMain"_s);
#endif
} }
void Preferences::setRssMainSplitterState(const QByteArray &state) void Preferences::setRssMainSplitterState(const QByteArray &state)
@ -1819,20 +1783,12 @@ void Preferences::setRssMainSplitterState(const QByteArray &state)
if (state == getRssMainSplitterState()) if (state == getRssMainSplitterState())
return; return;
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
setValue(u"GUI/Qt6/RSSWidget/MainSplitterState"_s, state); setValue(u"GUI/Qt6/RSSWidget/MainSplitterState"_s, state);
#else
setValue(u"GUI/RSSWidget/qt5/splitterMain"_s, state);
#endif
} }
QByteArray Preferences::getSearchTabHeaderState() const QByteArray Preferences::getSearchTabHeaderState() const
{ {
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
return value<QByteArray>(u"GUI/Qt6/SearchTab/HeaderState"_s); return value<QByteArray>(u"GUI/Qt6/SearchTab/HeaderState"_s);
#else
return value<QByteArray>(u"SearchTab/qt5/HeaderState"_s);
#endif
} }
void Preferences::setSearchTabHeaderState(const QByteArray &state) void Preferences::setSearchTabHeaderState(const QByteArray &state)
@ -1840,11 +1796,7 @@ void Preferences::setSearchTabHeaderState(const QByteArray &state)
if (state == getSearchTabHeaderState()) if (state == getSearchTabHeaderState())
return; return;
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
setValue(u"GUI/Qt6/SearchTab/HeaderState"_s, state); setValue(u"GUI/Qt6/SearchTab/HeaderState"_s, state);
#else
setValue(u"SearchTab/qt5/HeaderState"_s, state);
#endif
} }
bool Preferences::getRegexAsFilteringPatternForSearchJob() const bool Preferences::getRegexAsFilteringPatternForSearchJob() const
@ -1979,11 +1931,7 @@ void Preferences::setHideZeroStatusFilters(const bool hide)
QByteArray Preferences::getTransHeaderState() const QByteArray Preferences::getTransHeaderState() const
{ {
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
return value<QByteArray>(u"GUI/Qt6/TransferList/HeaderState"_s); return value<QByteArray>(u"GUI/Qt6/TransferList/HeaderState"_s);
#else
return value<QByteArray>(u"TransferList/qt5/HeaderState"_s);
#endif
} }
void Preferences::setTransHeaderState(const QByteArray &state) void Preferences::setTransHeaderState(const QByteArray &state)
@ -1991,11 +1939,7 @@ void Preferences::setTransHeaderState(const QByteArray &state)
if (state == getTransHeaderState()) if (state == getTransHeaderState())
return; return;
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
setValue(u"GUI/Qt6/TransferList/HeaderState"_s, state); setValue(u"GUI/Qt6/TransferList/HeaderState"_s, state);
#else
setValue(u"TransferList/qt5/HeaderState"_s, state);
#endif
} }
bool Preferences::getRegexAsFilteringPatternForTransferList() const bool Preferences::getRegexAsFilteringPatternForTransferList() const

4
src/base/settingsstorage.cpp

@ -212,11 +212,7 @@ bool SettingsStorage::writeNativeSettings() const
void SettingsStorage::removeValue(const QString &key) void SettingsStorage::removeValue(const QString &key)
{ {
const QWriteLocker locker(&m_lock); const QWriteLocker locker(&m_lock);
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
if (m_data.remove(key)) if (m_data.remove(key))
#else
if (m_data.remove(key) > 0)
#endif
{ {
m_dirty = true; m_dirty = true;
m_timer.start(); m_timer.start();

2
src/base/torrentfileswatcher.cpp

@ -233,7 +233,7 @@ void TorrentFilesWatcher::loadLegacy()
{ {
const Path watchedFolder {it.key()}; const Path watchedFolder {it.key()};
BitTorrent::AddTorrentParams params; BitTorrent::AddTorrentParams params;
if (it.value().type() == QVariant::Int) if (it.value().userType() == QMetaType::Int)
{ {
if (it.value().toInt() == 0) if (it.value().toInt() == 0)
{ {

18
src/base/utils/string.cpp

@ -32,15 +32,10 @@
#include <cmath> #include <cmath>
#include <QLocale> #include <QLocale>
#include <QRegularExpression>
#include <QStringList> #include <QStringList>
#include <QVector> #include <QVector>
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
#include <QRegularExpression>
#else
#include <QRegExp>
#endif
// to send numbers instead of strings with suffixes // to send numbers instead of strings with suffixes
QString Utils::String::fromDouble(const double n, const int precision) QString Utils::String::fromDouble(const double n, const int precision)
{ {
@ -54,21 +49,10 @@ QString Utils::String::fromDouble(const double n, const int precision)
return QLocale::system().toString(std::floor(n * prec) / prec, 'f', precision); return QLocale::system().toString(std::floor(n * prec) / prec, 'f', precision);
} }
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
QString Utils::String::wildcardToRegexPattern(const QString &pattern) QString Utils::String::wildcardToRegexPattern(const QString &pattern)
{ {
return QRegularExpression::wildcardToRegularExpression(pattern, QRegularExpression::UnanchoredWildcardConversion); return QRegularExpression::wildcardToRegularExpression(pattern, QRegularExpression::UnanchoredWildcardConversion);
} }
#else
// This is marked as internal in QRegExp.cpp, but is exported. The alternative would be to
// copy the code from QRegExp::wc2rx().
QString qt_regexp_toCanonical(const QString &pattern, QRegExp::PatternSyntax patternSyntax);
QString Utils::String::wildcardToRegexPattern(const QString &pattern)
{
return qt_regexp_toCanonical(pattern, QRegExp::Wildcard);
}
#endif
QStringList Utils::String::splitCommand(const QString &command) QStringList Utils::String::splitCommand(const QString &command)
{ {

10
src/gui/CMakeLists.txt

@ -1,11 +1,4 @@
if (QT6)
find_package(Qt6 ${minQt6Version} REQUIRED COMPONENTS Widgets Svg) 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()
# CMAKE_AUTO_UI causes unnecessary rebuilds # CMAKE_AUTO_UI causes unnecessary rebuilds
qt_wrap_ui(UI_HEADERS qt_wrap_ui(UI_HEADERS
@ -276,9 +269,6 @@ endif()
if (CMAKE_SYSTEM_NAME STREQUAL "Windows") if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
target_link_libraries(qbt_gui PRIVATE PowrProf) target_link_libraries(qbt_gui PRIVATE PowrProf)
if (NOT QT6)
target_link_libraries(qbt_gui PRIVATE Qt5::WinExtras)
endif()
endif() endif()
if (CMAKE_SYSTEM_NAME STREQUAL "Darwin") if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")

14
src/gui/addnewtorrentdialog.cpp

@ -153,16 +153,7 @@ public:
: BitTorrent::TorrentContentLayout::Subfolder); : BitTorrent::TorrentContentLayout::Subfolder);
if (!m_filePriorities.isEmpty()) if (!m_filePriorities.isEmpty())
{
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
const int currentSize = m_filePriorities.size();
m_filePriorities.resize(filesCount());
for (int i = currentSize; i < filesCount(); ++i)
m_filePriorities[i] = BitTorrent::DownloadPriority::Normal;
#else
m_filePriorities.resize(filesCount(), BitTorrent::DownloadPriority::Normal); m_filePriorities.resize(filesCount(), BitTorrent::DownloadPriority::Normal);
#endif
}
} }
bool hasMetadata() const override bool hasMetadata() const override
@ -289,13 +280,8 @@ AddNewTorrentDialog::AddNewTorrentDialog(const BitTorrent::AddTorrentParams &inP
, m_storeDialogSize(SETTINGS_KEY(u"DialogSize"_s)) , m_storeDialogSize(SETTINGS_KEY(u"DialogSize"_s))
, m_storeDefaultCategory(SETTINGS_KEY(u"DefaultCategory"_s)) , m_storeDefaultCategory(SETTINGS_KEY(u"DefaultCategory"_s))
, m_storeRememberLastSavePath(SETTINGS_KEY(u"RememberLastSavePath"_s)) , m_storeRememberLastSavePath(SETTINGS_KEY(u"RememberLastSavePath"_s))
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
, m_storeTreeHeaderState(u"GUI/Qt6/" SETTINGS_KEY(u"TreeHeaderState"_s)) , m_storeTreeHeaderState(u"GUI/Qt6/" SETTINGS_KEY(u"TreeHeaderState"_s))
, m_storeSplitterState(u"GUI/Qt6/" SETTINGS_KEY(u"SplitterState"_s)) , m_storeSplitterState(u"GUI/Qt6/" SETTINGS_KEY(u"SplitterState"_s))
#else
, m_storeTreeHeaderState(SETTINGS_KEY(u"TreeHeaderState"_s))
, m_storeSplitterState(SETTINGS_KEY(u"SplitterState"_s))
#endif
{ {
// TODO: set dialog file properties using m_torrentParams.filePriorities // TODO: set dialog file properties using m_torrentParams.filePriorities
m_ui->setupUi(this); m_ui->setupUi(this);

4
src/gui/cookiesdialog.cpp

@ -44,11 +44,7 @@ CookiesDialog::CookiesDialog(QWidget *parent)
, m_ui(new Ui::CookiesDialog) , m_ui(new Ui::CookiesDialog)
, m_cookiesModel(new CookiesModel(Net::DownloadManager::instance()->allCookies(), this)) , m_cookiesModel(new CookiesModel(Net::DownloadManager::instance()->allCookies(), this))
, m_storeDialogSize(SETTINGS_KEY(u"Size"_s)) , m_storeDialogSize(SETTINGS_KEY(u"Size"_s))
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
, m_storeViewState("GUI/Qt6/" SETTINGS_KEY(u"ViewState"_s)) , m_storeViewState("GUI/Qt6/" SETTINGS_KEY(u"ViewState"_s))
#else
, m_storeViewState(SETTINGS_KEY(u"CookiesViewState"_s))
#endif
{ {
m_ui->setupUi(this); m_ui->setupUi(this);

2
src/gui/fspathedit.cpp

@ -98,7 +98,7 @@ FileSystemPathEdit::FileSystemPathEditPrivate::FileSystemPathEditPrivate(
, m_validator {new Private::FileSystemPathValidator(q)} , m_validator {new Private::FileSystemPathValidator(q)}
{ {
m_browseAction->setIconText(browseButtonBriefText.tr()); m_browseAction->setIconText(browseButtonBriefText.tr());
m_browseAction->setShortcut(Qt::CTRL + Qt::Key_B); m_browseAction->setShortcut(Qt::CTRL | Qt::Key_B);
m_browseAction->setToolTip(browseButtonFullText.tr().remove(u'&')); m_browseAction->setToolTip(browseButtonFullText.tr().remove(u'&'));
m_browseBtn->setDefaultAction(m_browseAction); m_browseBtn->setDefaultAction(m_browseAction);

4
src/gui/mainwindow.cpp

@ -39,6 +39,7 @@
#include <versionhelpers.h> // must follow after Windows.h #include <versionhelpers.h> // must follow after Windows.h
#endif #endif
#include <QAction>
#include <QActionGroup> #include <QActionGroup>
#include <QClipboard> #include <QClipboard>
#include <QCloseEvent> #include <QCloseEvent>
@ -49,6 +50,7 @@
#include <QFileSystemWatcher> #include <QFileSystemWatcher>
#include <QKeyEvent> #include <QKeyEvent>
#include <QLabel> #include <QLabel>
#include <QMenu>
#include <QMessageBox> #include <QMessageBox>
#include <QMetaObject> #include <QMetaObject>
#include <QMimeData> #include <QMimeData>
@ -870,7 +872,7 @@ void MainWindow::createKeyboardShortcuts()
m_ui->actionIncreaseQueuePos->setShortcut(Qt::CTRL | Qt::Key_Plus); m_ui->actionIncreaseQueuePos->setShortcut(Qt::CTRL | Qt::Key_Plus);
m_ui->actionTopQueuePos->setShortcut(Qt::CTRL | Qt::SHIFT | Qt::Key_Plus); m_ui->actionTopQueuePos->setShortcut(Qt::CTRL | Qt::SHIFT | Qt::Key_Plus);
#ifdef Q_OS_MACOS #ifdef Q_OS_MACOS
m_ui->actionMinimize->setShortcut(Qt::CTRL + Qt::Key_M); m_ui->actionMinimize->setShortcut(Qt::CTRL | Qt::Key_M);
addAction(m_ui->actionMinimize); addAction(m_ui->actionMinimize);
#endif #endif
} }

4
src/gui/previewselectdialog.cpp

@ -52,11 +52,7 @@ PreviewSelectDialog::PreviewSelectDialog(QWidget *parent, const BitTorrent::Torr
, m_ui(new Ui::PreviewSelectDialog) , m_ui(new Ui::PreviewSelectDialog)
, m_torrent(torrent) , m_torrent(torrent)
, m_storeDialogSize(SETTINGS_KEY(u"Size"_s)) , m_storeDialogSize(SETTINGS_KEY(u"Size"_s))
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
, m_storeTreeHeaderState(u"GUI/Qt6/" SETTINGS_KEY(u"HeaderState"_s)) , m_storeTreeHeaderState(u"GUI/Qt6/" SETTINGS_KEY(u"HeaderState"_s))
#else
, m_storeTreeHeaderState(SETTINGS_KEY(u"HeaderState"_s))
#endif
{ {
m_ui->setupUi(this); m_ui->setupUi(this);

7
src/gui/properties/peerlistwidget.cpp

@ -74,17 +74,10 @@ bool operator==(const PeerEndpoint &left, const PeerEndpoint &right)
return (left.address == right.address) && (left.connectionType == right.connectionType); return (left.address == right.address) && (left.connectionType == right.connectionType);
} }
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
std::size_t qHash(const PeerEndpoint &peerEndpoint, const std::size_t seed = 0) std::size_t qHash(const PeerEndpoint &peerEndpoint, const std::size_t seed = 0)
{ {
return qHashMulti(seed, peerEndpoint.address, peerEndpoint.connectionType); return qHashMulti(seed, peerEndpoint.address, peerEndpoint.connectionType);
} }
#else
uint qHash(const PeerEndpoint &peerEndpoint, const uint seed = 0)
{
return (qHash(peerEndpoint.address, seed) ^ ::qHash(peerEndpoint.connectionType));
}
#endif
namespace namespace
{ {

4
src/gui/properties/piecesbar.cpp

@ -144,11 +144,7 @@ bool PiecesBar::event(QEvent *e)
return base::event(e); return base::event(e);
} }
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
void PiecesBar::enterEvent(QEnterEvent *e) void PiecesBar::enterEvent(QEnterEvent *e)
#else
void PiecesBar::enterEvent(QEvent *e)
#endif
{ {
m_hovered = true; m_hovered = true;
base::enterEvent(e); base::enterEvent(e);

4
src/gui/properties/piecesbar.h

@ -59,11 +59,7 @@ public:
protected: protected:
// QWidget interface // QWidget interface
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
void enterEvent(QEnterEvent *e) override; void enterEvent(QEnterEvent *e) override;
#else
void enterEvent(QEvent *e) override;
#endif
void leaveEvent(QEvent *e) override; void leaveEvent(QEvent *e) override;
void mouseMoveEvent(QMouseEvent *e) override; void mouseMoveEvent(QMouseEvent *e) override;

12
src/gui/properties/proptabbar.cpp

@ -48,7 +48,7 @@ PropTabBar::PropTabBar(QWidget *parent)
UIThemeManager::instance()->getIcon(u"help-about"_s, u"document-properties"_s), UIThemeManager::instance()->getIcon(u"help-about"_s, u"document-properties"_s),
#endif #endif
tr("General"), parent); tr("General"), parent);
mainInfosButton->setShortcut(Qt::ALT + Qt::Key_G); mainInfosButton->setShortcut(Qt::ALT | Qt::Key_G);
addWidget(mainInfosButton); addWidget(mainInfosButton);
m_btnGroup->addButton(mainInfosButton, MainTab); m_btnGroup->addButton(mainInfosButton, MainTab);
// Trackers tab // Trackers tab
@ -57,7 +57,7 @@ PropTabBar::PropTabBar(QWidget *parent)
UIThemeManager::instance()->getIcon(u"trackers"_s, u"network-server"_s), UIThemeManager::instance()->getIcon(u"trackers"_s, u"network-server"_s),
#endif #endif
tr("Trackers"), parent); tr("Trackers"), parent);
trackersButton->setShortcut(Qt::ALT + Qt::Key_C); trackersButton->setShortcut(Qt::ALT | Qt::Key_C);
addWidget(trackersButton); addWidget(trackersButton);
m_btnGroup->addButton(trackersButton, TrackersTab); m_btnGroup->addButton(trackersButton, TrackersTab);
// Peers tab // Peers tab
@ -66,7 +66,7 @@ PropTabBar::PropTabBar(QWidget *parent)
UIThemeManager::instance()->getIcon(u"peers"_s), UIThemeManager::instance()->getIcon(u"peers"_s),
#endif #endif
tr("Peers"), parent); tr("Peers"), parent);
peersButton->setShortcut(Qt::ALT + Qt::Key_R); peersButton->setShortcut(Qt::ALT | Qt::Key_R);
addWidget(peersButton); addWidget(peersButton);
m_btnGroup->addButton(peersButton, PeersTab); m_btnGroup->addButton(peersButton, PeersTab);
// URL seeds tab // URL seeds tab
@ -75,7 +75,7 @@ PropTabBar::PropTabBar(QWidget *parent)
UIThemeManager::instance()->getIcon(u"network-server"_s), UIThemeManager::instance()->getIcon(u"network-server"_s),
#endif #endif
tr("HTTP Sources"), parent); tr("HTTP Sources"), parent);
URLSeedsButton->setShortcut(Qt::ALT + Qt::Key_B); URLSeedsButton->setShortcut(Qt::ALT | Qt::Key_B);
addWidget(URLSeedsButton); addWidget(URLSeedsButton);
m_btnGroup->addButton(URLSeedsButton, URLSeedsTab); m_btnGroup->addButton(URLSeedsButton, URLSeedsTab);
// Files tab // Files tab
@ -84,7 +84,7 @@ PropTabBar::PropTabBar(QWidget *parent)
UIThemeManager::instance()->getIcon(u"directory"_s), UIThemeManager::instance()->getIcon(u"directory"_s),
#endif #endif
tr("Content"), parent); tr("Content"), parent);
filesButton->setShortcut(Qt::ALT + Qt::Key_Z); filesButton->setShortcut(Qt::ALT | Qt::Key_Z);
addWidget(filesButton); addWidget(filesButton);
m_btnGroup->addButton(filesButton, FilesTab); m_btnGroup->addButton(filesButton, FilesTab);
// Spacer // Spacer
@ -95,7 +95,7 @@ PropTabBar::PropTabBar(QWidget *parent)
UIThemeManager::instance()->getIcon(u"chart-line"_s), UIThemeManager::instance()->getIcon(u"chart-line"_s),
#endif #endif
tr("Speed"), parent); tr("Speed"), parent);
speedButton->setShortcut(Qt::ALT + Qt::Key_D); speedButton->setShortcut(Qt::ALT | Qt::Key_D);
addWidget(speedButton); addWidget(speedButton);
m_btnGroup->addButton(speedButton, SpeedTab); m_btnGroup->addButton(speedButton, SpeedTab);
// SIGNAL/SLOT // SIGNAL/SLOT

5
src/gui/rss/automatedrssdownloader.cpp

@ -67,13 +67,8 @@ AutomatedRssDownloader::AutomatedRssDownloader(QWidget *parent)
, m_ui {new Ui::AutomatedRssDownloader} , m_ui {new Ui::AutomatedRssDownloader}
, m_addTorrentParamsWidget {new AddTorrentParamsWidget} , m_addTorrentParamsWidget {new AddTorrentParamsWidget}
, m_storeDialogSize {u"RssFeedDownloader/geometrySize"_s} , m_storeDialogSize {u"RssFeedDownloader/geometrySize"_s}
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
, m_storeMainSplitterState {u"GUI/Qt6/RSSFeedDownloader/HSplitterSizes"_s} , m_storeMainSplitterState {u"GUI/Qt6/RSSFeedDownloader/HSplitterSizes"_s}
, m_storeRuleDefSplitterState {u"GUI/Qt6/RSSFeedDownloader/RuleDefSplitterState"_s} , m_storeRuleDefSplitterState {u"GUI/Qt6/RSSFeedDownloader/RuleDefSplitterState"_s}
#else
, m_storeMainSplitterState {u"RssFeedDownloader/qt5/hsplitterSizes"_s}
, m_storeRuleDefSplitterState {u"RssFeedDownloader/qt5/RuleDefSplitterState"_s}
#endif
{ {
m_ui->setupUi(this); m_ui->setupUi(this);

4
src/gui/rss/feedlistwidget.cpp

@ -242,7 +242,7 @@ void FeedListWidget::dragMoveEvent(QDragMoveEvent *event)
{ {
QTreeWidget::dragMoveEvent(event); QTreeWidget::dragMoveEvent(event);
QTreeWidgetItem *item = itemAt(event->pos()); QTreeWidgetItem *item = itemAt(event->position().toPoint());
if ((item == m_unreadStickyItem) // Prohibit dropping onto global unread counter if ((item == m_unreadStickyItem) // Prohibit dropping onto global unread counter
|| selectedItems().contains(m_unreadStickyItem) // Prohibit dragging of global unread counter || selectedItems().contains(m_unreadStickyItem) // Prohibit dragging of global unread counter
|| (item && isFeed(item))) // Prohibit dropping onto feeds || (item && isFeed(item))) // Prohibit dropping onto feeds
@ -253,7 +253,7 @@ void FeedListWidget::dragMoveEvent(QDragMoveEvent *event)
void FeedListWidget::dropEvent(QDropEvent *event) void FeedListWidget::dropEvent(QDropEvent *event)
{ {
QTreeWidgetItem *destFolderItem = itemAt(event->pos()); QTreeWidgetItem *destFolderItem = itemAt(event->position().toPoint());
RSS::Folder *destFolder = (destFolderItem RSS::Folder *destFolder = (destFolderItem
? static_cast<RSS::Folder *>(getRSSItem(destFolderItem)) ? static_cast<RSS::Folder *>(getRSSItem(destFolderItem))
: RSS::Session::instance()->rootFolder()); : RSS::Session::instance()->rootFolder());

7
src/gui/torrentcontentmodel.cpp

@ -40,9 +40,6 @@
#if defined(Q_OS_WIN) #if defined(Q_OS_WIN)
#include <Windows.h> #include <Windows.h>
#include <Shellapi.h> #include <Shellapi.h>
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
#include <QtWin>
#endif
#else #else
#include <QMimeDatabase> #include <QMimeDatabase>
#include <QMimeType> #include <QMimeType>
@ -133,11 +130,7 @@ namespace
if (FAILED(hr)) if (FAILED(hr))
return {}; return {};
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
const auto iconPixmap = QPixmap::fromImage(QImage::fromHICON(sfi.hIcon)); const auto iconPixmap = QPixmap::fromImage(QImage::fromHICON(sfi.hIcon));
#else
const QPixmap iconPixmap = QtWin::fromHICON(sfi.hIcon);
#endif
::DestroyIcon(sfi.hIcon); ::DestroyIcon(sfi.hIcon);
return iconPixmap; return iconPixmap;
} }

6
src/gui/transferlistwidget.cpp

@ -217,15 +217,15 @@ TransferListWidget::TransferListWidget(QWidget *parent, MainWindow *mainWindow)
connect(editHotkey, &QShortcut::activated, this, &TransferListWidget::renameSelectedTorrent); connect(editHotkey, &QShortcut::activated, this, &TransferListWidget::renameSelectedTorrent);
const auto *deleteHotkey = new QShortcut(QKeySequence::Delete, this, nullptr, nullptr, Qt::WidgetShortcut); const auto *deleteHotkey = new QShortcut(QKeySequence::Delete, this, nullptr, nullptr, Qt::WidgetShortcut);
connect(deleteHotkey, &QShortcut::activated, this, &TransferListWidget::softDeleteSelectedTorrents); connect(deleteHotkey, &QShortcut::activated, this, &TransferListWidget::softDeleteSelectedTorrents);
const auto *permDeleteHotkey = new QShortcut(Qt::SHIFT + Qt::Key_Delete, this, nullptr, nullptr, Qt::WidgetShortcut); const auto *permDeleteHotkey = new QShortcut((Qt::SHIFT | Qt::Key_Delete), this, nullptr, nullptr, Qt::WidgetShortcut);
connect(permDeleteHotkey, &QShortcut::activated, this, &TransferListWidget::permDeleteSelectedTorrents); connect(permDeleteHotkey, &QShortcut::activated, this, &TransferListWidget::permDeleteSelectedTorrents);
const auto *doubleClickHotkeyReturn = new QShortcut(Qt::Key_Return, this, nullptr, nullptr, Qt::WidgetShortcut); const auto *doubleClickHotkeyReturn = new QShortcut(Qt::Key_Return, this, nullptr, nullptr, Qt::WidgetShortcut);
connect(doubleClickHotkeyReturn, &QShortcut::activated, this, &TransferListWidget::torrentDoubleClicked); connect(doubleClickHotkeyReturn, &QShortcut::activated, this, &TransferListWidget::torrentDoubleClicked);
const auto *doubleClickHotkeyEnter = new QShortcut(Qt::Key_Enter, this, nullptr, nullptr, Qt::WidgetShortcut); const auto *doubleClickHotkeyEnter = new QShortcut(Qt::Key_Enter, this, nullptr, nullptr, Qt::WidgetShortcut);
connect(doubleClickHotkeyEnter, &QShortcut::activated, this, &TransferListWidget::torrentDoubleClicked); connect(doubleClickHotkeyEnter, &QShortcut::activated, this, &TransferListWidget::torrentDoubleClicked);
const auto *recheckHotkey = new QShortcut(Qt::CTRL + Qt::Key_R, this, nullptr, nullptr, Qt::WidgetShortcut); const auto *recheckHotkey = new QShortcut((Qt::CTRL | Qt::Key_R), this, nullptr, nullptr, Qt::WidgetShortcut);
connect(recheckHotkey, &QShortcut::activated, this, &TransferListWidget::recheckSelectedTorrents); connect(recheckHotkey, &QShortcut::activated, this, &TransferListWidget::recheckSelectedTorrents);
const auto *forceStartHotkey = new QShortcut(Qt::CTRL + Qt::Key_M, this, nullptr, nullptr, Qt::WidgetShortcut); const auto *forceStartHotkey = new QShortcut((Qt::CTRL | Qt::Key_M), this, nullptr, nullptr, Qt::WidgetShortcut);
connect(forceStartHotkey, &QShortcut::activated, this, &TransferListWidget::forceStartSelectedTorrents); connect(forceStartHotkey, &QShortcut::activated, this, &TransferListWidget::forceStartSelectedTorrents);
} }

10
src/webui/api/synccontroller.cpp

@ -186,7 +186,7 @@ namespace
const QVariant &value = i.value(); const QVariant &value = i.value();
QVariantList removedItems; QVariantList removedItems;
switch (static_cast<QMetaType::Type>(value.type())) switch (value.userType())
{ {
case QMetaType::QVariantMap: case QMetaType::QVariantMap:
{ {
@ -232,7 +232,7 @@ namespace
default: default:
Q_ASSERT_X(false, "processMap" Q_ASSERT_X(false, "processMap"
, u"Unexpected type: %1"_s , u"Unexpected type: %1"_s
.arg(QString::fromLatin1(QMetaType::typeName(static_cast<QMetaType::Type>(value.type())))) .arg(QString::fromLatin1(value.metaType().name()))
.toUtf8().constData()); .toUtf8().constData());
} }
} }
@ -257,9 +257,9 @@ namespace
{ {
for (auto i = data.cbegin(); i != data.cend(); ++i) for (auto i = data.cbegin(); i != data.cend(); ++i)
{ {
switch (i.value().type()) switch (i.value().userType())
{ {
case QVariant::Map: case QMetaType::QVariantMap:
if (!prevData.contains(i.key())) if (!prevData.contains(i.key()))
{ {
// new list item found - append it to syncData // new list item found - append it to syncData
@ -278,7 +278,7 @@ namespace
} }
} }
break; break;
case QVariant::StringList: case QMetaType::QStringList:
if (!prevData.contains(i.key())) if (!prevData.contains(i.key()))
{ {
// new list item found - append it to syncData // new list item found - append it to syncData

8
src/webui/api/torrentscontroller.cpp

@ -302,9 +302,9 @@ void TorrentsController::infoAction()
const auto lessThan = [](const QVariant &left, const QVariant &right) -> bool const auto lessThan = [](const QVariant &left, const QVariant &right) -> bool
{ {
Q_ASSERT(left.type() == right.type()); Q_ASSERT(left.userType() == right.userType());
switch (static_cast<QMetaType::Type>(left.type())) switch (left.userType())
{ {
case QMetaType::Bool: case QMetaType::Bool:
return left.value<bool>() < right.value<bool>(); return left.value<bool>() < right.value<bool>();
@ -319,8 +319,8 @@ void TorrentsController::infoAction()
case QMetaType::QString: case QMetaType::QString:
return left.value<QString>() < right.value<QString>(); return left.value<QString>() < right.value<QString>();
default: default:
qWarning("Unhandled QVariant comparison, type: %d, name: %s", left.type() qWarning("Unhandled QVariant comparison, type: %d, name: %s"
, QMetaType::typeName(left.type())); , left.userType(), left.metaType().name());
break; break;
} }
return false; return false;

4
test/CMakeLists.txt

@ -1,8 +1,4 @@
if (QT6)
find_package(Qt6 REQUIRED COMPONENTS Test) find_package(Qt6 REQUIRED COMPONENTS Test)
else()
find_package(Qt5 REQUIRED COMPONENTS Test)
endif()
enable_testing(true) enable_testing(true)
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure) add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure)

Loading…
Cancel
Save