From 97c7f3bc672e479c6c671ffb1e631daa886b5afb Mon Sep 17 00:00:00 2001 From: "Vladimir Golovnev (Glassez)" Date: Tue, 25 May 2021 19:58:43 +0300 Subject: [PATCH] Raise minimum Qt version to 5.14 --- CMakeLists.txt | 2 +- INSTALL | 2 +- configure | 42 ++++++++++++------------- configure.ac | 2 +- m4/qbittorrent.m4 | 10 +++--- src/app/CMakeLists.txt | 6 +--- src/app/application.cpp | 2 +- src/app/main.cpp | 2 +- src/base/bittorrent/session.cpp | 3 +- src/base/bittorrent/torrentimpl.cpp | 6 ++-- src/base/global.h | 36 +++------------------ src/base/http/connection.cpp | 2 +- src/base/http/requestparser.cpp | 10 +++--- src/base/net/smtp.cpp | 2 +- src/base/rss/rss_autodownloadrule.cpp | 2 +- src/base/search/searchpluginmanager.cpp | 4 +-- src/base/utils/bytearray.cpp | 6 ++-- src/base/utils/bytearray.h | 2 +- src/base/utils/foreignapps.cpp | 2 +- src/base/utils/misc.cpp | 2 +- src/base/utils/password.cpp | 2 +- src/gui/fspathedit.cpp | 2 +- src/gui/fspathedit_p.cpp | 2 +- src/gui/mainwindow.cpp | 2 +- src/gui/optionsdialog.cpp | 2 +- src/gui/properties/peerlistwidget.cpp | 6 ---- src/gui/search/searchsortmodel.cpp | 2 +- src/gui/torrentcontentmodel.cpp | 2 +- src/gui/torrentcreatordialog.cpp | 2 +- src/gui/transferlistfilterswidget.cpp | 4 +-- src/gui/transferlistwidget.cpp | 8 +---- src/gui/utils.cpp | 22 ------------- src/webui/api/appcontroller.cpp | 4 +-- src/webui/api/torrentscontroller.cpp | 12 +++---- src/webui/webapplication.cpp | 8 ++--- 35 files changed, 80 insertions(+), 145 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8bd11a665..588cade5e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,7 @@ project(qBittorrent set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON) # version requirements - older vesions may work, but you are on your own set(minBoostVersion 1.65) -set(minQtVersion 5.12) +set(minQtVersion 5.14) set(minOpenSSLVersion 1.1.1) set(minLibtorrentVersion 1.2.13) set(minZlibVersion 1.2.11) diff --git a/INSTALL b/INSTALL index ff2eb3dc6..13b07b763 100644 --- a/INSTALL +++ b/INSTALL @@ -11,7 +11,7 @@ qBittorrent - A BitTorrent client in C++ / Qt - OpenSSL >= 1.1.1 - - Qt >= 5.12 + - Qt >= 5.14 - zlib >= 1.2.11 diff --git a/configure b/configure index 767a1d1d5..f58b66aac 100755 --- a/configure +++ b/configure @@ -1450,7 +1450,7 @@ Some influential environment variables: directories to add to pkg-config's search path PKG_CONFIG_LIBDIR path overriding pkg-config's built-in search path - QT_QMAKE value of host_bins for Qt5Core >= 5.12, overriding pkg-config + QT_QMAKE value of host_bins for Qt5Core >= 5.14, overriding pkg-config Qt5Svg_CFLAGS C compiler flags for Qt5Svg, overriding pkg-config Qt5Svg_LIBS linker flags for Qt5Svg, overriding pkg-config @@ -5456,8 +5456,8 @@ printf "%s\n" "$enable_webui" >&6; } esac if test -n "$PKG_CONFIG" && \ - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"Qt5Core >= 5.12\""; } >&5 - ($PKG_CONFIG --exists --print-errors "Qt5Core >= 5.12") 2>&5 + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"Qt5Core >= 5.14\""; } >&5 + ($PKG_CONFIG --exists --print-errors "Qt5Core >= 5.14") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then @@ -5466,12 +5466,12 @@ if test -n "$QT_QMAKE"; then pkg_cv_QT_QMAKE="$QT_QMAKE" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"Qt5Core >= 5.12\""; } >&5 - ($PKG_CONFIG --exists --print-errors "Qt5Core >= 5.12") 2>&5 + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"Qt5Core >= 5.14\""; } >&5 + ($PKG_CONFIG --exists --print-errors "Qt5Core >= 5.14") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then - pkg_cv_QT_QMAKE=`$PKG_CONFIG --variable="host_bins" "Qt5Core >= 5.12" 2>/dev/null` + pkg_cv_QT_QMAKE=`$PKG_CONFIG --variable="host_bins" "Qt5Core >= 5.14" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes @@ -5501,8 +5501,8 @@ fi fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for Qt5 qmake >= 5.12" >&5 -printf %s "checking for Qt5 qmake >= 5.12... " >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for Qt5 qmake >= 5.14" >&5 +printf %s "checking for Qt5 qmake >= 5.14... " >&6; } if test "x$QT_QMAKE" != "x" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $QT_QMAKE" >&5 @@ -5529,12 +5529,12 @@ if test -n "$Qt5Svg_CFLAGS"; then pkg_cv_Qt5Svg_CFLAGS="$Qt5Svg_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"Qt5Svg >= 5.12\""; } >&5 - ($PKG_CONFIG --exists --print-errors "Qt5Svg >= 5.12") 2>&5 + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"Qt5Svg >= 5.14\""; } >&5 + ($PKG_CONFIG --exists --print-errors "Qt5Svg >= 5.14") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then - pkg_cv_Qt5Svg_CFLAGS=`$PKG_CONFIG --cflags "Qt5Svg >= 5.12" 2>/dev/null` + pkg_cv_Qt5Svg_CFLAGS=`$PKG_CONFIG --cflags "Qt5Svg >= 5.14" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes @@ -5546,12 +5546,12 @@ if test -n "$Qt5Svg_LIBS"; then pkg_cv_Qt5Svg_LIBS="$Qt5Svg_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"Qt5Svg >= 5.12\""; } >&5 - ($PKG_CONFIG --exists --print-errors "Qt5Svg >= 5.12") 2>&5 + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"Qt5Svg >= 5.14\""; } >&5 + ($PKG_CONFIG --exists --print-errors "Qt5Svg >= 5.14") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then - pkg_cv_Qt5Svg_LIBS=`$PKG_CONFIG --libs "Qt5Svg >= 5.12" 2>/dev/null` + pkg_cv_Qt5Svg_LIBS=`$PKG_CONFIG --libs "Qt5Svg >= 5.14" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes @@ -5572,14 +5572,14 @@ else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then - Qt5Svg_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "Qt5Svg >= 5.12" 2>&1` + Qt5Svg_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "Qt5Svg >= 5.14" 2>&1` else - Qt5Svg_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "Qt5Svg >= 5.12" 2>&1` + Qt5Svg_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "Qt5Svg >= 5.14" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$Qt5Svg_PKG_ERRORS" >&5 - as_fn_error $? "Package requirements (Qt5Svg >= 5.12) were not met: + as_fn_error $? "Package requirements (Qt5Svg >= 5.14) were not met: $Qt5Svg_PKG_ERRORS @@ -5619,11 +5619,11 @@ case "x$enable_qt_dbus" in #( "xyes") : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for Qt5DBus >= 5.12" >&5 -printf %s "checking for Qt5DBus >= 5.12... " >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for Qt5DBus >= 5.14" >&5 +printf %s "checking for Qt5DBus >= 5.14... " >&6; } if test -n "$PKG_CONFIG" && \ - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"Qt5DBus >= 5.12\""; } >&5 - ($PKG_CONFIG --exists --print-errors "Qt5DBus >= 5.12") 2>&5 + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"Qt5DBus >= 5.14\""; } >&5 + ($PKG_CONFIG --exists --print-errors "Qt5DBus >= 5.14") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then diff --git a/configure.ac b/configure.ac index 5d84b41a0..14eca7223 100644 --- a/configure.ac +++ b/configure.ac @@ -141,7 +141,7 @@ AS_IF([test "x$QT_QMAKE" = "x"], [AC_MSG_ERROR([Could not find qmake]) ]) AS_IF([test "x$enable_gui" = "xyes"], - [PKG_CHECK_MODULES(Qt5Svg, [Qt5Svg >= 5.12]) + [PKG_CHECK_MODULES(Qt5Svg, [Qt5Svg >= 5.14]) ]) AC_MSG_CHECKING([whether QtDBus should be enabled]) AS_CASE(["x$enable_qt_dbus"], diff --git a/m4/qbittorrent.m4 b/m4/qbittorrent.m4 index 3526bb4fa..56bdadaaa 100644 --- a/m4/qbittorrent.m4 +++ b/m4/qbittorrent.m4 @@ -5,9 +5,9 @@ # Sets the QT_QMAKE variable to the path of Qt5 qmake if found. # -------------------------------------- AC_DEFUN([FIND_QT5], -[PKG_CHECK_EXISTS([Qt5Core >= 5.12], +[PKG_CHECK_EXISTS([Qt5Core >= 5.14], [PKG_CHECK_VAR(QT_QMAKE, - [Qt5Core >= 5.12], + [Qt5Core >= 5.14], [host_bins]) ]) @@ -18,7 +18,7 @@ AS_IF([test -f "$QT_QMAKE/qmake"], [QT_QMAKE=""]) ]) -AC_MSG_CHECKING([for Qt5 qmake >= 5.12]) +AC_MSG_CHECKING([for Qt5 qmake >= 5.14]) AS_IF([test "x$QT_QMAKE" != "x"], [AC_MSG_RESULT([$QT_QMAKE])], [AC_MSG_RESULT([not found])] @@ -29,8 +29,8 @@ AS_IF([test "x$QT_QMAKE" != "x"], # Sets the HAVE_QTDBUS variable to true or false. # -------------------------------------- AC_DEFUN([FIND_QTDBUS], - [AC_MSG_CHECKING([for Qt5DBus >= 5.12]) - PKG_CHECK_EXISTS([Qt5DBus >= 5.12], + [AC_MSG_CHECKING([for Qt5DBus >= 5.14]) + PKG_CHECK_EXISTS([Qt5DBus >= 5.14], [AC_MSG_RESULT([found]) HAVE_QTDBUS=[true]], [AC_MSG_RESULT([not found]) diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt index 665fe7f0a..c43600fdd 100644 --- a/src/app/CMakeLists.txt +++ b/src/app/CMakeLists.txt @@ -139,11 +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")) - if (Qt5_VERSION VERSION_LESS 5.14) - set_property(TARGET qbt_app APPEND PROPERTY QT_PLUGINS Qt5::QSvgIconPlugin Qt5::QSvgPlugin) - else() - qt_import_plugins(qbt_app INCLUDE Qt5::QSvgIconPlugin Qt5::QSvgPlugin) - endif() + qt_import_plugins(qbt_app INCLUDE Qt5::QSvgIconPlugin Qt5::QSvgPlugin) endif() endif() diff --git a/src/app/application.cpp b/src/app/application.cpp index b0ceef11b..6e001baa4 100644 --- a/src/app/application.cpp +++ b/src/app/application.cpp @@ -302,7 +302,7 @@ void Application::setFileLoggerAgeType(const int value) void Application::processMessage(const QString &message) { - const QStringList params = message.split(PARAMS_SEPARATOR, QString::SkipEmptyParts); + const QStringList params = message.split(PARAMS_SEPARATOR, Qt::SkipEmptyParts); // If Application is not running (i.e., other // components are not ready) store params if (m_running) diff --git a/src/app/main.cpp b/src/app/main.cpp index 11b37e2e1..270c4e421 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -134,7 +134,7 @@ int main(int argc, char *argv[]) // We must save it here because QApplication constructor may change it bool isOneArg = (argc == 2); -#if !defined(DISABLE_GUI) && (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) +#if !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); diff --git a/src/base/bittorrent/session.cpp b/src/base/bittorrent/session.cpp index 26371c8e9..39d02bdf5 100644 --- a/src/base/bittorrent/session.cpp +++ b/src/base/bittorrent/session.cpp @@ -479,7 +479,8 @@ Session::Session(QObject *parent) m_storedCategories = map_cast(m_categories); } - m_tags = List::toSet(m_storedTags.get()); + const QStringList storedTags = m_storedTags.get(); + m_tags = {storedTags.cbegin(), storedTags.cend()}; enqueueRefresh(); updateSeedingLimitTimer(); diff --git a/src/base/bittorrent/torrentimpl.cpp b/src/base/bittorrent/torrentimpl.cpp index ecb44432e..ee69576e0 100644 --- a/src/base/bittorrent/torrentimpl.cpp +++ b/src/base/bittorrent/torrentimpl.cpp @@ -1252,7 +1252,7 @@ QVector TorrentImpl::pieceAvailability() const std::vector avail; m_nativeHandle.piece_availability(avail); - return Vector::fromStdVector(avail); + return {avail.cbegin(), avail.cend()}; } qreal TorrentImpl::distributedCopies() const @@ -1857,9 +1857,9 @@ void TorrentImpl::handleFileRenamedAlert(const lt::file_renamed_alert *p) if (m_oldPath[p->index].isEmpty()) m_oldPath.remove(p->index); - QVector oldPathParts = oldFilePath.splitRef('/', QString::SkipEmptyParts); + QVector oldPathParts = oldFilePath.splitRef('/', Qt::SkipEmptyParts); oldPathParts.removeLast(); // drop file name part - QVector newPathParts = newFilePath.splitRef('/', QString::SkipEmptyParts); + QVector newPathParts = newFilePath.splitRef('/', Qt::SkipEmptyParts); newPathParts.removeLast(); // drop file name part #if defined(Q_OS_WIN) diff --git a/src/base/global.h b/src/base/global.h index 323d44c3f..5fa8b2617 100644 --- a/src/base/global.h +++ b/src/base/global.h @@ -35,44 +35,16 @@ #define QBT_APP_64BIT #endif -const char C_TORRENT_FILE_EXTENSION[] = ".torrent"; -const int MAX_TORRENT_SIZE = 100 * 1024 * 1024; // 100 MiB +inline const char C_TORRENT_FILE_EXTENSION[] = ".torrent"; +inline const int MAX_TORRENT_SIZE = 100 * 1024 * 1024; // 100 MiB template -constexpr typename std::add_const::type &asConst(T &t) noexcept { return t; } +constexpr typename std::add_const_t &asConst(T &t) noexcept { return t; } // Forward rvalue as const template -constexpr typename std::add_const::type asConst(T &&t) noexcept { return std::move(t); } +constexpr typename std::add_const_t asConst(T &&t) noexcept { return std::move(t); } // Prevent const rvalue arguments template void asConst(const T &&) = delete; - -namespace List -{ - // Replacement for the deprecated`QSet QSet::fromList(const QList &list)` - template - QSet toSet(const QList &list) - { -#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) - return {list.cbegin(), list.cend()}; -#else - return QSet::fromList(list); -#endif - } -} - -namespace Vector -{ - // Replacement for the deprecated `QVector QVector::fromStdVector(const std::vector &vector)` - template - QVector fromStdVector(const std::vector &vector) - { -#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) - return {vector.cbegin(), vector.cend()}; -#else - return QVector::fromStdVector(vector); -#endif - } -} diff --git a/src/base/http/connection.cpp b/src/base/http/connection.cpp index 64a3f6a3e..a27b68a1f 100644 --- a/src/base/http/connection.cpp +++ b/src/base/http/connection.cpp @@ -161,7 +161,7 @@ bool Connection::acceptsGzipEncoding(QString codings) return false; }; - const QVector list = codings.remove(' ').remove('\t').splitRef(',', QString::SkipEmptyParts); + const QVector list = codings.remove(' ').remove('\t').splitRef(',', Qt::SkipEmptyParts); if (list.isEmpty()) return false; diff --git a/src/base/http/requestparser.cpp b/src/base/http/requestparser.cpp index 549cb1c91..284783c3f 100644 --- a/src/base/http/requestparser.cpp +++ b/src/base/http/requestparser.cpp @@ -148,7 +148,7 @@ RequestParser::ParseResult RequestParser::doParse(const QByteArray &data) bool RequestParser::parseStartLines(const QString &data) { // we don't handle malformed request which uses `LF` for newline - const QVector lines = data.splitRef(CRLF, QString::SkipEmptyParts); + const QVector lines = data.splitRef(CRLF, Qt::SkipEmptyParts); // [rfc7230] 3.2.2. Field Order QStringList requestLines; @@ -276,7 +276,7 @@ bool RequestParser::parsePostMessage(const QByteArray &data) // split data by "dash-boundary" const QByteArray dashDelimiter = QByteArray("--") + delimiter + CRLF; - QVector multipart = splitToViews(data, dashDelimiter, QString::SkipEmptyParts); + QVector multipart = splitToViews(data, dashDelimiter, Qt::SkipEmptyParts); if (multipart.isEmpty()) { qWarning() << Q_FUNC_INFO << "multipart empty"; @@ -299,7 +299,7 @@ bool RequestParser::parsePostMessage(const QByteArray &data) bool RequestParser::parseFormData(const QByteArray &data) { - const QVector list = splitToViews(data, EOH, QString::KeepEmptyParts); + const QVector list = splitToViews(data, EOH, Qt::KeepEmptyParts); if (list.size() != 2) { @@ -311,13 +311,13 @@ bool RequestParser::parseFormData(const QByteArray &data) const QByteArray payload = viewWithoutEndingWith(list[1], CRLF); HeaderMap headersMap; - const QVector headerLines = headers.splitRef(CRLF, QString::SkipEmptyParts); + const QVector headerLines = headers.splitRef(CRLF, Qt::SkipEmptyParts); for (const auto &line : headerLines) { if (line.trimmed().startsWith(HEADER_CONTENT_DISPOSITION, Qt::CaseInsensitive)) { // extract out filename & name - const QVector directives = line.split(';', QString::SkipEmptyParts); + const QVector directives = line.split(';', Qt::SkipEmptyParts); for (const auto &directive : directives) { diff --git a/src/base/net/smtp.cpp b/src/base/net/smtp.cpp index 01b554504..df5f157f0 100644 --- a/src/base/net/smtp.cpp +++ b/src/base/net/smtp.cpp @@ -456,7 +456,7 @@ void Smtp::authenticate() // AUTH extension is supported, check which // authentication modes are supported by // the server - const QStringList auth = m_extensions["AUTH"].toUpper().split(' ', QString::SkipEmptyParts); + const QStringList auth = m_extensions["AUTH"].toUpper().split(' ', Qt::SkipEmptyParts); if (auth.contains("CRAM-MD5")) { qDebug() << "Using CRAM-MD5 authentication..."; diff --git a/src/base/rss/rss_autodownloadrule.cpp b/src/base/rss/rss_autodownloadrule.cpp index 32f79937e..3c701ba91 100644 --- a/src/base/rss/rss_autodownloadrule.cpp +++ b/src/base/rss/rss_autodownloadrule.cpp @@ -238,7 +238,7 @@ bool AutoDownloadRule::matchesExpression(const QString &articleTitle, const QStr // Only match if every wildcard token (separated by spaces) is present in the article name. // Order of wildcard tokens is unimportant (if order is important, they should have used *). - const QStringList wildcards {expression.split(whitespace, QString::SplitBehavior::SkipEmptyParts)}; + const QStringList wildcards {expression.split(whitespace, Qt::SkipEmptyParts)}; for (const QString &wildcard : wildcards) { const QRegularExpression reg {cachedRegex(wildcard, false)}; diff --git a/src/base/search/searchpluginmanager.cpp b/src/base/search/searchpluginmanager.cpp index a7027a716..214a329ab 100644 --- a/src/base/search/searchpluginmanager.cpp +++ b/src/base/search/searchpluginmanager.cpp @@ -516,14 +516,14 @@ void SearchPluginManager::parseVersionInfo(const QByteArray &info) QHash updateInfo; int numCorrectData = 0; - const QVector lines = Utils::ByteArray::splitToViews(info, "\n", QString::SkipEmptyParts); + const QVector lines = Utils::ByteArray::splitToViews(info, "\n", Qt::SkipEmptyParts); for (QByteArray line : lines) { line = line.trimmed(); if (line.isEmpty()) continue; if (line.startsWith('#')) continue; - const QVector list = Utils::ByteArray::splitToViews(line, ":", QString::SkipEmptyParts); + const QVector list = Utils::ByteArray::splitToViews(line, ":", Qt::SkipEmptyParts); if (list.size() != 2) continue; const QString pluginName = list.first().trimmed(); diff --git a/src/base/utils/bytearray.cpp b/src/base/utils/bytearray.cpp index 79eed420a..86d70aa97 100644 --- a/src/base/utils/bytearray.cpp +++ b/src/base/utils/bytearray.cpp @@ -31,13 +31,13 @@ #include #include -QVector Utils::ByteArray::splitToViews(const QByteArray &in, const QByteArray &sep, const QString::SplitBehavior behavior) +QVector Utils::ByteArray::splitToViews(const QByteArray &in, const QByteArray &sep, const Qt::SplitBehavior behavior) { if (sep.isEmpty()) return {in}; QVector ret; - ret.reserve((behavior == QString::KeepEmptyParts) + ret.reserve((behavior == Qt::KeepEmptyParts) ? (1 + (in.size() / sep.size())) : (1 + (in.size() / (sep.size() + 1)))); int head = 0; @@ -49,7 +49,7 @@ QVector Utils::ByteArray::splitToViews(const QByteArray &in, const Q // omit empty parts const QByteArray part = QByteArray::fromRawData((in.constData() + head), (end - head)); - if (!part.isEmpty() || (behavior == QString::KeepEmptyParts)) + if (!part.isEmpty() || (behavior == Qt::KeepEmptyParts)) ret += part; head = end + sep.size(); diff --git a/src/base/utils/bytearray.h b/src/base/utils/bytearray.h index c61afb931..2b49f2082 100644 --- a/src/base/utils/bytearray.h +++ b/src/base/utils/bytearray.h @@ -36,7 +36,7 @@ class QByteArray; namespace Utils::ByteArray { // Mimic QString::splitRef(sep, behavior) - QVector splitToViews(const QByteArray &in, const QByteArray &sep, const QString::SplitBehavior behavior = QString::KeepEmptyParts); + QVector splitToViews(const QByteArray &in, const QByteArray &sep, const Qt::SplitBehavior behavior = Qt::KeepEmptyParts); // Mimic QByteArray::mid(pos, len) but instead of returning a full-copy, // we only return a partial view diff --git a/src/base/utils/foreignapps.cpp b/src/base/utils/foreignapps.cpp index c517d0942..9020bac2a 100644 --- a/src/base/utils/foreignapps.cpp +++ b/src/base/utils/foreignapps.cpp @@ -63,7 +63,7 @@ namespace // Software 'Anaconda' installs its own python interpreter // and `python --version` returns a string like this: // "Python 3.4.3 :: Anaconda 2.3.0 (64-bit)" - const QVector outputSplit = Utils::ByteArray::splitToViews(procOutput, " ", QString::SkipEmptyParts); + const QVector outputSplit = Utils::ByteArray::splitToViews(procOutput, " ", Qt::SkipEmptyParts); if (outputSplit.size() <= 1) return false; diff --git a/src/base/utils/misc.cpp b/src/base/utils/misc.cpp index e48b1db91..e560f9e75 100644 --- a/src/base/utils/misc.cpp +++ b/src/base/utils/misc.cpp @@ -498,7 +498,7 @@ QString Utils::Misc::opensslVersionString() #else static const auto version {QString::fromLatin1(SSLeay_version(SSLEAY_VERSION))}; #endif - return version.splitRef(' ', QString::SkipEmptyParts)[1].toString(); + return version.splitRef(' ', Qt::SkipEmptyParts)[1].toString(); } QString Utils::Misc::zlibVersionString() diff --git a/src/base/utils/password.cpp b/src/base/utils/password.cpp index 4b1ee81cc..0351aff64 100644 --- a/src/base/utils/password.cpp +++ b/src/base/utils/password.cpp @@ -99,7 +99,7 @@ bool Utils::Password::PBKDF2::verify(const QByteArray &secret, const QString &pa bool Utils::Password::PBKDF2::verify(const QByteArray &secret, const QByteArray &password) { - const QVector list = ByteArray::splitToViews(secret, ":", QString::SkipEmptyParts); + const QVector list = ByteArray::splitToViews(secret, ":", Qt::SkipEmptyParts); if (list.size() != 2) return false; diff --git a/src/gui/fspathedit.cpp b/src/gui/fspathedit.cpp index f4e0ac07e..29190a8c1 100644 --- a/src/gui/fspathedit.cpp +++ b/src/gui/fspathedit.cpp @@ -241,7 +241,7 @@ void FileSystemPathEdit::setFileNameFilter(const QString &val) } else { - QStringList filters = filterString.split(QLatin1Char(' '), QString::SkipEmptyParts); + QStringList filters = filterString.split(QLatin1Char(' '), Qt::SkipEmptyParts); d->m_editor->setFilenameFilters(filters); } } diff --git a/src/gui/fspathedit_p.cpp b/src/gui/fspathedit_p.cpp index 6612fed60..1cc63c384 100644 --- a/src/gui/fspathedit_p.cpp +++ b/src/gui/fspathedit_p.cpp @@ -107,7 +107,7 @@ QValidator::State Private::FileSystemPathValidator::validate(QString &input, int // we test path components from beginning to the one with cursor location in strict mode // and the one with cursor and beyond in non-strict mode - QVector components = input.splitRef(QDir::separator(), QString::KeepEmptyParts); + QVector components = input.splitRef(QDir::separator(), Qt::KeepEmptyParts); // find index of the component that contains pos int componentWithCursorIndex = 0; int pathLength = 0; diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 23135e964..bb8d7e4cf 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -1154,7 +1154,7 @@ void MainWindow::keyPressEvent(QKeyEvent *event) if (mimeData->hasText()) { const bool useTorrentAdditionDialog {AddNewTorrentDialog::isEnabled()}; - const QStringList lines {mimeData->text().split('\n', QString::SkipEmptyParts)}; + const QStringList lines {mimeData->text().split('\n', Qt::SkipEmptyParts)}; for (QString line : lines) { diff --git a/src/gui/optionsdialog.cpp b/src/gui/optionsdialog.cpp index 0468527d0..438f647a6 100644 --- a/src/gui/optionsdialog.cpp +++ b/src/gui/optionsdialog.cpp @@ -718,7 +718,7 @@ void OptionsDialog::saveOptions() RSS::Session::instance()->setMaxArticlesPerFeed(m_ui->spinRSSMaxArticlesPerFeed->value()); RSS::Session::instance()->setProcessingEnabled(m_ui->checkRSSEnable->isChecked()); RSS::AutoDownloader::instance()->setProcessingEnabled(m_ui->checkRSSAutoDownloaderEnable->isChecked()); - RSS::AutoDownloader::instance()->setSmartEpisodeFilters(m_ui->textSmartEpisodeFilters->toPlainText().split('\n', QString::SplitBehavior::SkipEmptyParts)); + RSS::AutoDownloader::instance()->setSmartEpisodeFilters(m_ui->textSmartEpisodeFilters->toPlainText().split('\n', Qt::SkipEmptyParts)); RSS::AutoDownloader::instance()->setDownloadRepacks(m_ui->checkSmartFilterDownloadRepacks->isChecked()); auto session = BitTorrent::Session::instance(); diff --git a/src/gui/properties/peerlistwidget.cpp b/src/gui/properties/peerlistwidget.cpp index d031e3917..9f9402528 100644 --- a/src/gui/properties/peerlistwidget.cpp +++ b/src/gui/properties/peerlistwidget.cpp @@ -502,15 +502,9 @@ void PeerListWidget::wheelEvent(QWheelEvent *event) { // Shift + scroll = horizontal scroll event->accept(); - -#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) QWheelEvent scrollHEvent(event->position(), event->globalPosition() , event->pixelDelta(), event->angleDelta().transposed(), event->buttons() , event->modifiers(), event->phase(), event->inverted(), event->source()); -#else - QWheelEvent scrollHEvent(event->pos(), event->globalPos() - , event->delta(), event->buttons(), event->modifiers(), Qt::Horizontal); -#endif QTreeView::wheelEvent(&scrollHEvent); return; } diff --git a/src/gui/search/searchsortmodel.cpp b/src/gui/search/searchsortmodel.cpp index 1af053634..6ab343632 100644 --- a/src/gui/search/searchsortmodel.cpp +++ b/src/gui/search/searchsortmodel.cpp @@ -59,7 +59,7 @@ void SearchSortModel::setNameFilter(const QString &searchTerm) } else { - m_searchTermWords = searchTerm.split(QLatin1Char(' '), QString::SkipEmptyParts); + m_searchTermWords = searchTerm.split(QLatin1Char(' '), Qt::SkipEmptyParts); } } diff --git a/src/gui/torrentcontentmodel.cpp b/src/gui/torrentcontentmodel.cpp index 0f661baef..c26f2c9bd 100644 --- a/src/gui/torrentcontentmodel.cpp +++ b/src/gui/torrentcontentmodel.cpp @@ -503,7 +503,7 @@ void TorrentContentModel::setupModelData(const BitTorrent::TorrentInfo &info) const QString path = Utils::Fs::toUniformPath(info.filePath(i)); // Iterate of parts of the path to create necessary folders - QVector pathFolders = path.splitRef('/', QString::SkipEmptyParts); + QVector pathFolders = path.splitRef('/', Qt::SkipEmptyParts); pathFolders.removeLast(); for (const QStringRef &pathPartRef : asConst(pathFolders)) diff --git a/src/gui/torrentcreatordialog.cpp b/src/gui/torrentcreatordialog.cpp index bce90be65..4665494a3 100644 --- a/src/gui/torrentcreatordialog.cpp +++ b/src/gui/torrentcreatordialog.cpp @@ -212,7 +212,7 @@ void TorrentCreatorDialog::onCreateButtonClicked() , m_ui->txtComment->toPlainText() , m_ui->lineEditSource->text() , trackers - , m_ui->URLSeedsList->toPlainText().split('\n', QString::SkipEmptyParts) + , m_ui->URLSeedsList->toPlainText().split('\n', Qt::SkipEmptyParts) }; // run the creator thread diff --git a/src/gui/transferlistfilterswidget.cpp b/src/gui/transferlistfilterswidget.cpp index 6de04b7e8..fc457241c 100644 --- a/src/gui/transferlistfilterswidget.cpp +++ b/src/gui/transferlistfilterswidget.cpp @@ -632,9 +632,9 @@ QSet TrackerFiltersList::getTorrentIDs(const int row) con case TRACKERLESS_ROW: return m_trackers.value(NULL_HOST); case ERROR_ROW: - return List::toSet(m_errors.keys()); + return {m_errors.keyBegin(), m_errors.keyEnd()}; case WARNING_ROW: - return List::toSet(m_warnings.keys()); + return {m_warnings.keyBegin(), m_warnings.keyEnd()}; default: return m_trackers.value(trackerFromRow(row)); } diff --git a/src/gui/transferlistwidget.cpp b/src/gui/transferlistwidget.cpp index ff3408428..d1db63212 100644 --- a/src/gui/transferlistwidget.cpp +++ b/src/gui/transferlistwidget.cpp @@ -721,7 +721,7 @@ QStringList TransferListWidget::askTagsForSelection(const QString &dialogTitle) this, dialogTitle, tr("Comma-separated tags:"), QLineEdit::Normal, "", &ok).trimmed(); if (!ok || tagsInput.isEmpty()) return {}; - tags = tagsInput.split(',', QString::SkipEmptyParts); + tags = tagsInput.split(',', Qt::SkipEmptyParts); for (QString &tag : tags) { tag = tag.trimmed(); @@ -1163,15 +1163,9 @@ void TransferListWidget::wheelEvent(QWheelEvent *event) { // Shift + scroll = horizontal scroll event->accept(); - -#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) QWheelEvent scrollHEvent(event->position(), event->globalPosition() , event->pixelDelta(), event->angleDelta().transposed(), event->buttons() , event->modifiers(), event->phase(), event->inverted(), event->source()); -#else - QWheelEvent scrollHEvent(event->pos(), event->globalPos() - , event->delta(), event->buttons(), event->modifiers(), Qt::Horizontal); -#endif QTreeView::wheelEvent(&scrollHEvent); return; } diff --git a/src/gui/utils.cpp b/src/gui/utils.cpp index 48c391cd0..c29c165ee 100644 --- a/src/gui/utils.cpp +++ b/src/gui/utils.cpp @@ -48,10 +48,6 @@ #include #include -#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) && defined(Q_OS_WIN) -#include -#endif - #include "base/utils/fs.h" #include "base/utils/version.h" @@ -65,26 +61,8 @@ void Utils::Gui::resize(QWidget *widget, const QSize &newSize) qreal Utils::Gui::screenScalingFactor(const QWidget *widget) { -#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) Q_UNUSED(widget); return 1; -#else - if (!widget) - return 1; - -#ifdef Q_OS_WIN - const int screenNumber = qApp->desktop()->screenNumber(widget); - const QScreen *screen = QApplication::screens()[screenNumber]; - // Workaround for QScreen::physicalDotsPerInch() that could return - // values that are smaller than the normal 96 DPI on Windows - const qreal physicalDPI = qMax(screen->physicalDotsPerInch(), 96); - return (screen->logicalDotsPerInch() / physicalDPI); -#elif defined(Q_OS_MACOS) - return 1; -#else - return widget->devicePixelRatioF(); -#endif // Q_OS_WIN -#endif // QT_VERSION } QPixmap Utils::Gui::scaledPixmap(const QIcon &icon, const QWidget *widget, const int height) diff --git a/src/webui/api/appcontroller.cpp b/src/webui/api/appcontroller.cpp index 590d30147..6cbb5c2d6 100644 --- a/src/webui/api/appcontroller.cpp +++ b/src/webui/api/appcontroller.cpp @@ -523,7 +523,7 @@ void AppController::setPreferencesAction() if (hasKey("ip_filter_trackers")) session->setTrackerFilteringEnabled(it.value().toBool()); if (hasKey("banned_IPs")) - session->setBannedIPs(it.value().toString().split('\n', QString::SkipEmptyParts)); + session->setBannedIPs(it.value().toString().split('\n', Qt::SkipEmptyParts)); // Speed // Global Rate Limits @@ -653,7 +653,7 @@ void AppController::setPreferencesAction() if (hasKey("bypass_auth_subnet_whitelist")) { // recognize new lines and commas as delimiters - pref->setWebUiAuthSubnetWhitelist(it.value().toString().split(QRegularExpression("\n|,"), QString::SkipEmptyParts)); + pref->setWebUiAuthSubnetWhitelist(it.value().toString().split(QRegularExpression("\n|,"), Qt::SkipEmptyParts)); } if (hasKey("web_ui_max_auth_fail_count")) pref->setWebUIMaxAuthFailCount(it.value().toInt()); diff --git a/src/webui/api/torrentscontroller.cpp b/src/webui/api/torrentscontroller.cpp index 8b4d03250..adbcd8e1b 100644 --- a/src/webui/api/torrentscontroller.cpp +++ b/src/webui/api/torrentscontroller.cpp @@ -259,7 +259,7 @@ void TorrentsController::infoAction() const bool reverse {parseBool(params()["reverse"]).value_or(false)}; int limit {params()["limit"].toInt()}; int offset {params()["offset"].toInt()}; - const QStringList hashes {params()["hashes"].split('|', QString::SkipEmptyParts)}; + const QStringList hashes {params()["hashes"].split('|', Qt::SkipEmptyParts)}; TorrentIDSet idSet; for (const QString &hash : hashes) @@ -637,7 +637,7 @@ void TorrentsController::addAction() const std::optional addPaused = parseBool(params()["paused"]); const QString savepath = params()["savepath"].trimmed(); const QString category = params()["category"]; - const QStringList tags = params()["tags"].split(',', QString::SkipEmptyParts); + const QStringList tags = params()["tags"].split(',', Qt::SkipEmptyParts); const QString torrentName = params()["rename"].trimmed(); const int upLimit = parseInt(params()["upLimit"]).value_or(-1); const int dlLimit = parseInt(params()["dlLimit"]).value_or(-1); @@ -1215,7 +1215,7 @@ void TorrentsController::addTagsAction() requireParams({"hashes", "tags"}); const QStringList hashes {params()["hashes"].split('|')}; - const QStringList tags {params()["tags"].split(',', QString::SkipEmptyParts)}; + const QStringList tags {params()["tags"].split(',', Qt::SkipEmptyParts)}; for (const QString &tag : tags) { @@ -1232,7 +1232,7 @@ void TorrentsController::removeTagsAction() requireParams({"hashes"}); const QStringList hashes {params()["hashes"].split('|')}; - const QStringList tags {params()["tags"].split(',', QString::SkipEmptyParts)}; + const QStringList tags {params()["tags"].split(',', Qt::SkipEmptyParts)}; for (const QString &tag : tags) { @@ -1256,7 +1256,7 @@ void TorrentsController::createTagsAction() { requireParams({"tags"}); - const QStringList tags {params()["tags"].split(',', QString::SkipEmptyParts)}; + const QStringList tags {params()["tags"].split(',', Qt::SkipEmptyParts)}; for (const QString &tag : tags) BitTorrent::Session::instance()->addTag(tag.trimmed()); @@ -1266,7 +1266,7 @@ void TorrentsController::deleteTagsAction() { requireParams({"tags"}); - const QStringList tags {params()["tags"].split(',', QString::SkipEmptyParts)}; + const QStringList tags {params()["tags"].split(',', Qt::SkipEmptyParts)}; for (const QString &tag : tags) BitTorrent::Session::instance()->removeTag(tag.trimmed()); } diff --git a/src/webui/webapplication.cpp b/src/webui/webapplication.cpp index 18acade46..4333cee9e 100644 --- a/src/webui/webapplication.cpp +++ b/src/webui/webapplication.cpp @@ -76,7 +76,7 @@ namespace { // [rfc6265] 4.2.1. Syntax QStringMap ret; - const QVector cookies = cookieStr.splitRef(';', QString::SkipEmptyParts); + const QVector cookies = cookieStr.splitRef(';', Qt::SkipEmptyParts); for (const auto &cookie : cookies) { @@ -143,7 +143,7 @@ WebApplication::~WebApplication() void WebApplication::sendWebUIFile() { - const QStringList pathItems {request().path.split('/', QString::SkipEmptyParts)}; + const QStringList pathItems {request().path.split('/', Qt::SkipEmptyParts)}; if (pathItems.contains(".") || pathItems.contains("..")) throw InternalServerErrorHTTPError(); @@ -356,7 +356,7 @@ void WebApplication::configure() m_authSubnetWhitelist = pref->getWebUiAuthSubnetWhitelist(); m_sessionTimeout = pref->getWebUISessionTimeout(); - m_domainList = pref->getServerDomains().split(';', QString::SkipEmptyParts); + m_domainList = pref->getServerDomains().split(';', Qt::SkipEmptyParts); std::for_each(m_domainList.begin(), m_domainList.end(), [](QString &entry) { entry = entry.trimmed(); }); m_isCSRFProtectionEnabled = pref->isWebUiCSRFProtectionEnabled(); @@ -387,7 +387,7 @@ void WebApplication::configure() if (pref->isWebUICustomHTTPHeadersEnabled()) { const QString customHeaders = pref->getWebUICustomHTTPHeaders().trimmed(); - const QVector customHeaderLines = customHeaders.splitRef('\n', QString::SkipEmptyParts); + const QVector customHeaderLines = customHeaders.splitRef('\n', Qt::SkipEmptyParts); for (const QStringRef &line : customHeaderLines) {