Merge pull request #15029 from glassez/qt-5.14

Raise minimum Qt version to 5.14
This commit is contained in:
Vladimir Golovnev 2021-06-14 16:48:15 +03:00 committed by GitHub
commit 5c0378a684
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
38 changed files with 101 additions and 153 deletions

View file

@ -13,8 +13,8 @@ environment:
REPO_DIR: &REPO_DIR c:\qbittorrent
CACHE_DIR: &CACHE_DIR c:\qbt_cache
QBT_VER_URL: https://builds.shiki.hu/appveyor/version
QBT_LIB_URL: https://builds.shiki.hu/appveyor/qbt_libraries.7z
QBT_VER_URL: https://builds.shiki.hu/appveyor/version_64
QBT_LIB_URL: https://builds.shiki.hu/appveyor/qbt_libraries_64.7z
# project directory
clone_folder: *REPO_DIR
@ -38,12 +38,12 @@ install:
appveyor DownloadFile "%QBT_LIB_URL%" -FileName "c:\qbt_lib.7z" && 7z x "c:\qbt_lib.7z" -o"%CACHE_DIR%" > nul &&
COPY "c:\version_new" "%CACHE_DIR%\version")
# Qt stay compressed in cache
- 7z x "%CACHE_DIR%\qt5_32.7z" -o"c:\qbt" > nul
- 7z x "%CACHE_DIR%\qt5_64.7z" -o"c:\qbt" > nul
before_build:
# setup env
- CALL "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars32.bat"
- SET PATH=%PATH%;c:\qbt\qt5_32\bin;%CACHE_DIR%\jom;
- CALL "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"
- SET PATH=%PATH%;c:\qbt\qt5_64\bin;%CACHE_DIR%\jom;
# setup project
- COPY /Y "%CACHE_DIR%\conf.pri" "%REPO_DIR%"
# workarounds

View file

@ -39,8 +39,15 @@ jobs:
sudo apt install \
build-essential cmake git ninja-build pkg-config \
libssl-dev libgeoip-dev zlib1g-dev \
libboost-dev libboost-chrono-dev libboost-random-dev libboost-system-dev \
libqt5svg5-dev qtbase5-dev qttools5-dev
libboost-dev libboost-chrono-dev libboost-random-dev libboost-system-dev
# sudo apt install libqt5svg5-dev qtbase5-dev qttools5-dev # the Qt version in the standard repositories is too old...
# this will be installed under /opt/qt514. CMake will still find it automatically without additional hints
# to speed up the process, only the required components are installed rather than the full qt514-meta-full metapackage
- name: install Qt 5.14.2 from an external PPA
run: |
sudo add-apt-repository ppa:beineri/opt-qt-5.14.2-focal
sudo apt install qt514base qt514svg qt514tools
- name: install libtorrent from source
run: |

View file

@ -47,12 +47,13 @@ addons:
# sources list: https://github.com/travis-ci/apt-source-safelist/blob/master/ubuntu.json
- sourceline: 'deb https://apt.kitware.com/ubuntu/ focal main'
key_url: 'https://apt.kitware.com/keys/kitware-archive-latest.asc'
- sourceline: 'ppa:beineri/opt-qt-5.14.2-focal'
packages:
# packages list: https://github.com/travis-ci/apt-package-safelist/blob/master/ubuntu-trusty
- [autoconf, automake, cmake, colormake]
- [libboost-dev, libboost-system-dev]
- libssl-dev
- [qtbase5-dev, libqt5svg5-dev, qttools5-dev]
- [qt514base, qt514svg, qt514tools]
- zlib1g-dev
before_install:
@ -75,6 +76,11 @@ before_install:
# if they don't call the new binary directly
alias cmake="/usr/bin/cmake"
# Qt 5.14.2
PATH="/opt/qt514/bin:$PATH"
qmake_conf="$qmake_conf PKG_CONFIG_PATH=/opt/qt514/lib/pkgconfig:$PKG_CONFIG_PATH"
cmake_conf="$cmake_conf PKG_CONFIG_PATH=/opt/qt514/lib/pkgconfig:$PKG_CONFIG_PATH"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/lib"
fi
- |

View file

@ -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)

View file

@ -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

42
configure vendored
View file

@ -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

View file

@ -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"],

View file

@ -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])

View file

@ -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()

View file

@ -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)

View file

@ -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);

View file

@ -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();

View file

@ -1260,7 +1260,7 @@ QVector<int> TorrentImpl::pieceAvailability() const
std::vector<int> avail;
m_nativeHandle.piece_availability(avail);
return Vector::fromStdVector(avail);
return {avail.cbegin(), avail.cend()};
}
qreal TorrentImpl::distributedCopies() const
@ -1865,9 +1865,9 @@ void TorrentImpl::handleFileRenamedAlert(const lt::file_renamed_alert *p)
if (m_oldPath[p->index].isEmpty())
m_oldPath.remove(p->index);
QVector<QStringRef> oldPathParts = oldFilePath.splitRef('/', QString::SkipEmptyParts);
QVector<QStringRef> oldPathParts = oldFilePath.splitRef('/', Qt::SkipEmptyParts);
oldPathParts.removeLast(); // drop file name part
QVector<QStringRef> newPathParts = newFilePath.splitRef('/', QString::SkipEmptyParts);
QVector<QStringRef> newPathParts = newFilePath.splitRef('/', Qt::SkipEmptyParts);
newPathParts.removeLast(); // drop file name part
#if defined(Q_OS_WIN)

View file

@ -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 <typename T>
constexpr typename std::add_const<T>::type &asConst(T &t) noexcept { return t; }
constexpr typename std::add_const_t<T> &asConst(T &t) noexcept { return t; }
// Forward rvalue as const
template <typename T>
constexpr typename std::add_const<T>::type asConst(T &&t) noexcept { return std::move(t); }
constexpr typename std::add_const_t<T> asConst(T &&t) noexcept { return std::move(t); }
// Prevent const rvalue arguments
template <typename T>
void asConst(const T &&) = delete;
namespace List
{
// Replacement for the deprecated`QSet<T> QSet::fromList(const QList<T> &list)`
template <typename T>
QSet<T> toSet(const QList<T> &list)
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
return {list.cbegin(), list.cend()};
#else
return QSet<T>::fromList(list);
#endif
}
}
namespace Vector
{
// Replacement for the deprecated `QVector<T> QVector::fromStdVector(const std::vector<T> &vector)`
template <typename T>
QVector<T> fromStdVector(const std::vector<T> &vector)
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
return {vector.cbegin(), vector.cend()};
#else
return QVector<T>::fromStdVector(vector);
#endif
}
}

View file

@ -161,7 +161,7 @@ bool Connection::acceptsGzipEncoding(QString codings)
return false;
};
const QVector<QStringRef> list = codings.remove(' ').remove('\t').splitRef(',', QString::SkipEmptyParts);
const QVector<QStringRef> list = codings.remove(' ').remove('\t').splitRef(',', Qt::SkipEmptyParts);
if (list.isEmpty())
return false;

View file

@ -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<QStringRef> lines = data.splitRef(CRLF, QString::SkipEmptyParts);
const QVector<QStringRef> 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<QByteArray> multipart = splitToViews(data, dashDelimiter, QString::SkipEmptyParts);
QVector<QByteArray> 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<QByteArray> list = splitToViews(data, EOH, QString::KeepEmptyParts);
const QVector<QByteArray> 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<QStringRef> headerLines = headers.splitRef(CRLF, QString::SkipEmptyParts);
const QVector<QStringRef> 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<QStringRef> directives = line.split(';', QString::SkipEmptyParts);
const QVector<QStringRef> directives = line.split(';', Qt::SkipEmptyParts);
for (const auto &directive : directives)
{

View file

@ -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...";

View file

@ -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)};

View file

@ -516,14 +516,14 @@ void SearchPluginManager::parseVersionInfo(const QByteArray &info)
QHash<QString, PluginVersion> updateInfo;
int numCorrectData = 0;
const QVector<QByteArray> lines = Utils::ByteArray::splitToViews(info, "\n", QString::SkipEmptyParts);
const QVector<QByteArray> 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<QByteArray> list = Utils::ByteArray::splitToViews(line, ":", QString::SkipEmptyParts);
const QVector<QByteArray> list = Utils::ByteArray::splitToViews(line, ":", Qt::SkipEmptyParts);
if (list.size() != 2) continue;
const QString pluginName = list.first().trimmed();

View file

@ -31,13 +31,13 @@
#include <QByteArray>
#include <QVector>
QVector<QByteArray> Utils::ByteArray::splitToViews(const QByteArray &in, const QByteArray &sep, const QString::SplitBehavior behavior)
QVector<QByteArray> Utils::ByteArray::splitToViews(const QByteArray &in, const QByteArray &sep, const Qt::SplitBehavior behavior)
{
if (sep.isEmpty())
return {in};
QVector<QByteArray> 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<QByteArray> 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();

View file

@ -36,7 +36,7 @@ class QByteArray;
namespace Utils::ByteArray
{
// Mimic QString::splitRef(sep, behavior)
QVector<QByteArray> splitToViews(const QByteArray &in, const QByteArray &sep, const QString::SplitBehavior behavior = QString::KeepEmptyParts);
QVector<QByteArray> 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

View file

@ -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<QByteArray> outputSplit = Utils::ByteArray::splitToViews(procOutput, " ", QString::SkipEmptyParts);
const QVector<QByteArray> outputSplit = Utils::ByteArray::splitToViews(procOutput, " ", Qt::SkipEmptyParts);
if (outputSplit.size() <= 1)
return false;

View file

@ -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()

View file

@ -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<QByteArray> list = ByteArray::splitToViews(secret, ":", QString::SkipEmptyParts);
const QVector<QByteArray> list = ByteArray::splitToViews(secret, ":", Qt::SkipEmptyParts);
if (list.size() != 2)
return false;

View file

@ -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);
}
}

View file

@ -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<QStringRef> components = input.splitRef(QDir::separator(), QString::KeepEmptyParts);
QVector<QStringRef> components = input.splitRef(QDir::separator(), Qt::KeepEmptyParts);
// find index of the component that contains pos
int componentWithCursorIndex = 0;
int pathLength = 0;

View file

@ -1163,7 +1163,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)
{

View file

@ -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();

View file

@ -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;
}

View file

@ -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);
}
}

View file

@ -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<QStringRef> pathFolders = path.splitRef('/', QString::SkipEmptyParts);
QVector<QStringRef> pathFolders = path.splitRef('/', Qt::SkipEmptyParts);
pathFolders.removeLast();
for (const QStringRef &pathPartRef : asConst(pathFolders))

View file

@ -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

View file

@ -632,9 +632,9 @@ QSet<BitTorrent::TorrentID> 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));
}

View file

@ -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;
}

View file

@ -48,10 +48,6 @@
#include <QWidget>
#include <QWindow>
#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) && defined(Q_OS_WIN)
#include <QDesktopWidget>
#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<qreal>(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)

View file

@ -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());

View file

@ -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<bool> 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());
}

View file

@ -76,7 +76,7 @@ namespace
{
// [rfc6265] 4.2.1. Syntax
QStringMap ret;
const QVector<QStringRef> cookies = cookieStr.splitRef(';', QString::SkipEmptyParts);
const QVector<QStringRef> 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<QStringRef> customHeaderLines = customHeaders.splitRef('\n', QString::SkipEmptyParts);
const QVector<QStringRef> customHeaderLines = customHeaders.splitRef('\n', Qt::SkipEmptyParts);
for (const QStringRef &line : customHeaderLines)
{