Browse Source

Merge pull request #14427 from glassez/qt-5.12

Raise minimum Qt version to 5.12
adaptive-webui-19844
Vladimir Golovnev 4 years ago committed by GitHub
parent
commit
a8ae97ba91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      .github/workflows/ci.yaml
  2. 2
      CMakeLists.txt
  3. 42
      configure
  4. 2
      configure.ac
  5. 10
      m4/qbittorrent.m4
  6. 10
      src/app/CMakeLists.txt
  7. 4
      src/app/application.cpp
  8. 6
      src/app/main.cpp
  9. 5
      src/base/asyncfilestorage.cpp
  10. 39
      src/base/bittorrent/session.cpp
  11. 5
      src/base/bittorrent/session.h
  12. 4
      src/base/bittorrent/torrentinfo.cpp
  13. 2
      src/base/preferences.cpp
  14. 2
      src/base/preferences.h
  15. 5
      src/base/rss/rss_parser.cpp
  16. 4
      src/base/utils/fs.cpp
  17. 12
      src/gui/autoexpandabledialog.cpp
  18. 4
      src/gui/log/loglistview.cpp
  19. 4
      src/gui/optionsdialog.cpp
  20. 16
      src/gui/properties/speedplotview.cpp
  21. 2
      src/gui/rss/automatedrssdownloader.cpp
  22. 2
      src/gui/torrentcontentmodel.cpp
  23. 4
      src/webui/api/synccontroller.cpp

2
.github/workflows/ci.yaml

@ -23,7 +23,7 @@ jobs:
strategy: strategy:
matrix: matrix:
os: [ubuntu-20.04, ubuntu-18.04] os: [ubuntu-20.04]
qbt_gui: ["GUI=ON", "GUI=OFF"] qbt_gui: ["GUI=ON", "GUI=OFF"]
fail-fast: false fail-fast: false

2
CMakeLists.txt

@ -12,7 +12,7 @@ project(qBittorrent
set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON) set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON)
# version requirements - older vesions may work, but you are on your own # version requirements - older vesions may work, but you are on your own
set(minBoostVersion 1.65) set(minBoostVersion 1.65)
set(minQtVersion 5.9.5) set(minQtVersion 5.12)
set(minOpenSSLVersion 1.1.1) set(minOpenSSLVersion 1.1.1)
set(minLibtorrentVersion 1.2.12) set(minLibtorrentVersion 1.2.12)
set(minZlibVersion 1.2.11) set(minZlibVersion 1.2.11)

42
configure vendored

@ -1455,7 +1455,7 @@ Some influential environment variables:
directories to add to pkg-config's search path directories to add to pkg-config's search path
PKG_CONFIG_LIBDIR PKG_CONFIG_LIBDIR
path overriding pkg-config's built-in search path path overriding pkg-config's built-in search path
QT_QMAKE value of host_bins for Qt5Core >= 5.9.5, overriding pkg-config QT_QMAKE value of host_bins for Qt5Core >= 5.12, overriding pkg-config
Qt5Svg_CFLAGS Qt5Svg_CFLAGS
C compiler flags for Qt5Svg, overriding pkg-config C compiler flags for Qt5Svg, overriding pkg-config
Qt5Svg_LIBS linker flags for Qt5Svg, overriding pkg-config Qt5Svg_LIBS linker flags for Qt5Svg, overriding pkg-config
@ -5525,8 +5525,8 @@ printf "%s\n" "$enable_webui" >&6; }
esac esac
if test -n "$PKG_CONFIG" && \ if test -n "$PKG_CONFIG" && \
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"Qt5Core >= 5.9.5\""; } >&5 { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"Qt5Core >= 5.12\""; } >&5
($PKG_CONFIG --exists --print-errors "Qt5Core >= 5.9.5") 2>&5 ($PKG_CONFIG --exists --print-errors "Qt5Core >= 5.12") 2>&5
ac_status=$? ac_status=$?
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then test $ac_status = 0; }; then
@ -5535,12 +5535,12 @@ if test -n "$QT_QMAKE"; then
pkg_cv_QT_QMAKE="$QT_QMAKE" pkg_cv_QT_QMAKE="$QT_QMAKE"
elif test -n "$PKG_CONFIG"; then elif test -n "$PKG_CONFIG"; then
if test -n "$PKG_CONFIG" && \ if test -n "$PKG_CONFIG" && \
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"Qt5Core >= 5.9.5\""; } >&5 { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"Qt5Core >= 5.12\""; } >&5
($PKG_CONFIG --exists --print-errors "Qt5Core >= 5.9.5") 2>&5 ($PKG_CONFIG --exists --print-errors "Qt5Core >= 5.12") 2>&5
ac_status=$? ac_status=$?
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then test $ac_status = 0; }; then
pkg_cv_QT_QMAKE=`$PKG_CONFIG --variable="host_bins" "Qt5Core >= 5.9.5" 2>/dev/null` pkg_cv_QT_QMAKE=`$PKG_CONFIG --variable="host_bins" "Qt5Core >= 5.12" 2>/dev/null`
test "x$?" != "x0" && pkg_failed=yes test "x$?" != "x0" && pkg_failed=yes
else else
pkg_failed=yes pkg_failed=yes
@ -5570,8 +5570,8 @@ fi
fi fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for Qt5 qmake >= 5.9.5" >&5 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for Qt5 qmake >= 5.12" >&5
printf %s "checking for Qt5 qmake >= 5.9.5... " >&6; } printf %s "checking for Qt5 qmake >= 5.12... " >&6; }
if test "x$QT_QMAKE" != "x" if test "x$QT_QMAKE" != "x"
then : then :
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $QT_QMAKE" >&5 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $QT_QMAKE" >&5
@ -5598,12 +5598,12 @@ if test -n "$Qt5Svg_CFLAGS"; then
pkg_cv_Qt5Svg_CFLAGS="$Qt5Svg_CFLAGS" pkg_cv_Qt5Svg_CFLAGS="$Qt5Svg_CFLAGS"
elif test -n "$PKG_CONFIG"; then elif test -n "$PKG_CONFIG"; then
if test -n "$PKG_CONFIG" && \ if test -n "$PKG_CONFIG" && \
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"Qt5Svg >= 5.5.1\""; } >&5 { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"Qt5Svg >= 5.12\""; } >&5
($PKG_CONFIG --exists --print-errors "Qt5Svg >= 5.5.1") 2>&5 ($PKG_CONFIG --exists --print-errors "Qt5Svg >= 5.12") 2>&5
ac_status=$? ac_status=$?
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then test $ac_status = 0; }; then
pkg_cv_Qt5Svg_CFLAGS=`$PKG_CONFIG --cflags "Qt5Svg >= 5.5.1" 2>/dev/null` pkg_cv_Qt5Svg_CFLAGS=`$PKG_CONFIG --cflags "Qt5Svg >= 5.12" 2>/dev/null`
test "x$?" != "x0" && pkg_failed=yes test "x$?" != "x0" && pkg_failed=yes
else else
pkg_failed=yes pkg_failed=yes
@ -5615,12 +5615,12 @@ if test -n "$Qt5Svg_LIBS"; then
pkg_cv_Qt5Svg_LIBS="$Qt5Svg_LIBS" pkg_cv_Qt5Svg_LIBS="$Qt5Svg_LIBS"
elif test -n "$PKG_CONFIG"; then elif test -n "$PKG_CONFIG"; then
if test -n "$PKG_CONFIG" && \ if test -n "$PKG_CONFIG" && \
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"Qt5Svg >= 5.5.1\""; } >&5 { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"Qt5Svg >= 5.12\""; } >&5
($PKG_CONFIG --exists --print-errors "Qt5Svg >= 5.5.1") 2>&5 ($PKG_CONFIG --exists --print-errors "Qt5Svg >= 5.12") 2>&5
ac_status=$? ac_status=$?
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then test $ac_status = 0; }; then
pkg_cv_Qt5Svg_LIBS=`$PKG_CONFIG --libs "Qt5Svg >= 5.5.1" 2>/dev/null` pkg_cv_Qt5Svg_LIBS=`$PKG_CONFIG --libs "Qt5Svg >= 5.12" 2>/dev/null`
test "x$?" != "x0" && pkg_failed=yes test "x$?" != "x0" && pkg_failed=yes
else else
pkg_failed=yes pkg_failed=yes
@ -5641,14 +5641,14 @@ else
_pkg_short_errors_supported=no _pkg_short_errors_supported=no
fi fi
if test $_pkg_short_errors_supported = yes; then if test $_pkg_short_errors_supported = yes; then
Qt5Svg_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "Qt5Svg >= 5.5.1" 2>&1` Qt5Svg_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "Qt5Svg >= 5.12" 2>&1`
else else
Qt5Svg_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "Qt5Svg >= 5.5.1" 2>&1` Qt5Svg_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "Qt5Svg >= 5.12" 2>&1`
fi fi
# Put the nasty error message in config.log where it belongs # Put the nasty error message in config.log where it belongs
echo "$Qt5Svg_PKG_ERRORS" >&5 echo "$Qt5Svg_PKG_ERRORS" >&5
as_fn_error $? "Package requirements (Qt5Svg >= 5.5.1) were not met: as_fn_error $? "Package requirements (Qt5Svg >= 5.12) were not met:
$Qt5Svg_PKG_ERRORS $Qt5Svg_PKG_ERRORS
@ -5688,11 +5688,11 @@ case "x$enable_qt_dbus" in #(
"xyes") : "xyes") :
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
printf "%s\n" "yes" >&6; } printf "%s\n" "yes" >&6; }
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for Qt5DBus >= 5.9.5" >&5 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for Qt5DBus >= 5.12" >&5
printf %s "checking for Qt5DBus >= 5.9.5... " >&6; } printf %s "checking for Qt5DBus >= 5.12... " >&6; }
if test -n "$PKG_CONFIG" && \ if test -n "$PKG_CONFIG" && \
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"Qt5DBus >= 5.9.5\""; } >&5 { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"Qt5DBus >= 5.12\""; } >&5
($PKG_CONFIG --exists --print-errors "Qt5DBus >= 5.9.5") 2>&5 ($PKG_CONFIG --exists --print-errors "Qt5DBus >= 5.12") 2>&5
ac_status=$? ac_status=$?
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then test $ac_status = 0; }; then

2
configure.ac

@ -141,7 +141,7 @@ AS_IF([test "x$QT_QMAKE" = "x"],
[AC_MSG_ERROR([Could not find qmake]) [AC_MSG_ERROR([Could not find qmake])
]) ])
AS_IF([test "x$enable_gui" = "xyes"], AS_IF([test "x$enable_gui" = "xyes"],
[PKG_CHECK_MODULES(Qt5Svg, [Qt5Svg >= 5.5.1]) [PKG_CHECK_MODULES(Qt5Svg, [Qt5Svg >= 5.12])
]) ])
AC_MSG_CHECKING([whether QtDBus should be enabled]) AC_MSG_CHECKING([whether QtDBus should be enabled])
AS_CASE(["x$enable_qt_dbus"], AS_CASE(["x$enable_qt_dbus"],

10
m4/qbittorrent.m4

@ -5,9 +5,9 @@
# Sets the QT_QMAKE variable to the path of Qt5 qmake if found. # Sets the QT_QMAKE variable to the path of Qt5 qmake if found.
# -------------------------------------- # --------------------------------------
AC_DEFUN([FIND_QT5], AC_DEFUN([FIND_QT5],
[PKG_CHECK_EXISTS([Qt5Core >= 5.9.5], [PKG_CHECK_EXISTS([Qt5Core >= 5.12],
[PKG_CHECK_VAR(QT_QMAKE, [PKG_CHECK_VAR(QT_QMAKE,
[Qt5Core >= 5.9.5], [Qt5Core >= 5.12],
[host_bins]) [host_bins])
]) ])
@ -18,7 +18,7 @@ AS_IF([test -f "$QT_QMAKE/qmake"],
[QT_QMAKE=""]) [QT_QMAKE=""])
]) ])
AC_MSG_CHECKING([for Qt5 qmake >= 5.9.5]) AC_MSG_CHECKING([for Qt5 qmake >= 5.12])
AS_IF([test "x$QT_QMAKE" != "x"], AS_IF([test "x$QT_QMAKE" != "x"],
[AC_MSG_RESULT([$QT_QMAKE])], [AC_MSG_RESULT([$QT_QMAKE])],
[AC_MSG_RESULT([not found])] [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. # Sets the HAVE_QTDBUS variable to true or false.
# -------------------------------------- # --------------------------------------
AC_DEFUN([FIND_QTDBUS], AC_DEFUN([FIND_QTDBUS],
[AC_MSG_CHECKING([for Qt5DBus >= 5.9.5]) [AC_MSG_CHECKING([for Qt5DBus >= 5.12])
PKG_CHECK_EXISTS([Qt5DBus >= 5.9.5], PKG_CHECK_EXISTS([Qt5DBus >= 5.12],
[AC_MSG_RESULT([found]) [AC_MSG_RESULT([found])
HAVE_QTDBUS=[true]], HAVE_QTDBUS=[true]],
[AC_MSG_RESULT([not found]) [AC_MSG_RESULT([not found])

10
src/app/CMakeLists.txt

@ -4,22 +4,14 @@
# Based on https://gist.github.com/giraldeau/546ba5512a74dfe9d8ea0862d66db412 # Based on https://gist.github.com/giraldeau/546ba5512a74dfe9d8ea0862d66db412
file(GLOB QBT_TS_FILES "${qBittorrent_SOURCE_DIR}/src/lang/*.ts") file(GLOB QBT_TS_FILES "${qBittorrent_SOURCE_DIR}/src/lang/*.ts")
set_source_files_properties(${QBT_TS_FILES} PROPERTIES OUTPUT_LOCATION "${qBittorrent_BINARY_DIR}/src/lang") set_source_files_properties(${QBT_TS_FILES} PROPERTIES OUTPUT_LOCATION "${qBittorrent_BINARY_DIR}/src/lang")
if (Qt5_VERSION VERSION_LESS 5.12) qt5_add_translation(QBT_QM_FILES ${QBT_TS_FILES} OPTIONS -silent)
qt5_add_translation(QBT_QM_FILES ${QBT_TS_FILES})
else()
qt5_add_translation(QBT_QM_FILES ${QBT_TS_FILES} OPTIONS -silent)
endif()
configure_file("${qBittorrent_SOURCE_DIR}/src/lang/lang.qrc" "${qBittorrent_BINARY_DIR}/src/lang/lang.qrc" COPYONLY) configure_file("${qBittorrent_SOURCE_DIR}/src/lang/lang.qrc" "${qBittorrent_BINARY_DIR}/src/lang/lang.qrc" COPYONLY)
if (WEBUI) if (WEBUI)
file(GLOB QBT_WEBUI_TS_FILES "${qBittorrent_SOURCE_DIR}/src/webui/www/translations/*.ts") file(GLOB QBT_WEBUI_TS_FILES "${qBittorrent_SOURCE_DIR}/src/webui/www/translations/*.ts")
set_source_files_properties(${QBT_WEBUI_TS_FILES} set_source_files_properties(${QBT_WEBUI_TS_FILES}
PROPERTIES OUTPUT_LOCATION "${qBittorrent_BINARY_DIR}/src/webui/www/translations") PROPERTIES OUTPUT_LOCATION "${qBittorrent_BINARY_DIR}/src/webui/www/translations")
if (Qt5_VERSION VERSION_LESS 5.12)
qt5_add_translation(QBT_WEBUI_QM_FILES ${QBT_WEBUI_TS_FILES})
else()
qt5_add_translation(QBT_WEBUI_QM_FILES ${QBT_WEBUI_TS_FILES} OPTIONS -silent) qt5_add_translation(QBT_WEBUI_QM_FILES ${QBT_WEBUI_TS_FILES} OPTIONS -silent)
endif()
configure_file("${qBittorrent_SOURCE_DIR}/src/webui/www/translations/webui_translations.qrc" configure_file("${qBittorrent_SOURCE_DIR}/src/webui/www/translations/webui_translations.qrc"
"${qBittorrent_BINARY_DIR}/src/webui/www/translations/webui_translations.qrc" COPYONLY) "${qBittorrent_BINARY_DIR}/src/webui/www/translations/webui_translations.qrc" COPYONLY)
endif() endif()

4
src/app/application.cpp

@ -403,7 +403,6 @@ void Application::runExternalProgram(const BitTorrent::Torrent *torrent) const
for (int i = 1; i < argCount; ++i) for (int i = 1; i < argCount; ++i)
argList += QString::fromWCharArray(args[i]); argList += QString::fromWCharArray(args[i]);
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
QProcess proc; QProcess proc;
proc.setProgram(QString::fromWCharArray(args[0])); proc.setProgram(QString::fromWCharArray(args[0]));
proc.setArguments(argList); proc.setArguments(argList);
@ -429,9 +428,6 @@ void Application::runExternalProgram(const BitTorrent::Torrent *torrent) const
args->startupInfo->hStdError = nullptr; args->startupInfo->hStdError = nullptr;
}); });
proc.startDetached(); proc.startDetached();
#else
QProcess::startDetached(QString::fromWCharArray(args[0]), argList);
#endif // QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
#else // Q_OS_WIN #else // Q_OS_WIN
// Cannot give users shell environment by default, as doing so could // Cannot give users shell environment by default, as doing so could
// enable command injection via torrent name and other arguments // enable command injection via torrent name and other arguments

6
src/app/main.cpp

@ -235,7 +235,7 @@ 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(5, 10, 0)) && !defined(DISABLE_GUI) #if !defined(DISABLE_GUI)
// this is the default in Qt6 // this is the default in Qt6
app->setAttribute(Qt::AA_DisableWindowContextHelpButton); app->setAttribute(Qt::AA_DisableWindowContextHelpButton);
#endif #endif
@ -381,11 +381,7 @@ void showSplashScreen()
const QString version = QBT_VERSION; const QString version = QBT_VERSION;
painter.setPen(QPen(Qt::white)); painter.setPen(QPen(Qt::white));
painter.setFont(QFont("Arial", 22, QFont::Black)); painter.setFont(QFont("Arial", 22, QFont::Black));
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
painter.drawText(224 - painter.fontMetrics().horizontalAdvance(version), 270, version); painter.drawText(224 - painter.fontMetrics().horizontalAdvance(version), 270, version);
#else
painter.drawText(224 - painter.fontMetrics().width(version), 270, version);
#endif
QSplashScreen *splash = new QSplashScreen(splashImg); QSplashScreen *splash = new QSplashScreen(splashImg);
splash->show(); splash->show();
QTimer::singleShot(1500, splash, &QObject::deleteLater); QTimer::singleShot(1500, splash, &QObject::deleteLater);

5
src/base/asyncfilestorage.cpp

@ -55,13 +55,8 @@ AsyncFileStorage::~AsyncFileStorage()
void AsyncFileStorage::store(const QString &fileName, const QByteArray &data) void AsyncFileStorage::store(const QString &fileName, const QByteArray &data)
{ {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
QMetaObject::invokeMethod(this, [this, data, fileName]() { store_impl(fileName, data); } QMetaObject::invokeMethod(this, [this, data, fileName]() { store_impl(fileName, data); }
, Qt::QueuedConnection); , Qt::QueuedConnection);
#else
QMetaObject::invokeMethod(this, "store_impl", Qt::QueuedConnection
, Q_ARG(QString, fileName), Q_ARG(QByteArray, data));
#endif
} }
QDir AsyncFileStorage::storageDir() const QDir AsyncFileStorage::storageDir() const

39
src/base/bittorrent/session.cpp

@ -1111,11 +1111,7 @@ void Session::initializeNativeSession()
m_nativeSession->set_alert_notify([this]() m_nativeSession->set_alert_notify([this]()
{ {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
QMetaObject::invokeMethod(this, &Session::readAlerts, Qt::QueuedConnection); QMetaObject::invokeMethod(this, &Session::readAlerts, Qt::QueuedConnection);
#else
QMetaObject::invokeMethod(this, "readAlerts", Qt::QueuedConnection);
#endif
}); });
// Enabling plugins // Enabling plugins
@ -1856,16 +1852,11 @@ bool Session::deleteTorrent(const TorrentID &id, const DeleteOption deleteOption
// Remove it from torrent resume directory // Remove it from torrent resume directory
const QString resumedataFile = QString::fromLatin1("%1.fastresume").arg(torrent->id().toString()); const QString resumedataFile = QString::fromLatin1("%1.fastresume").arg(torrent->id().toString());
const QString metadataFile = QString::fromLatin1("%1.torrent").arg(torrent->id().toString()); const QString metadataFile = QString::fromLatin1("%1.torrent").arg(torrent->id().toString());
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
QMetaObject::invokeMethod(m_resumeDataSavingManager, [this, resumedataFile, metadataFile]() QMetaObject::invokeMethod(m_resumeDataSavingManager, [this, resumedataFile, metadataFile]()
{ {
m_resumeDataSavingManager->remove(resumedataFile); m_resumeDataSavingManager->remove(resumedataFile);
m_resumeDataSavingManager->remove(metadataFile); m_resumeDataSavingManager->remove(metadataFile);
}); });
#else
QMetaObject::invokeMethod(m_resumeDataSavingManager, "remove", Q_ARG(QString, resumedataFile));
QMetaObject::invokeMethod(m_resumeDataSavingManager, "remove", Q_ARG(QString, metadataFile));
#endif
delete torrent; delete torrent;
return true; return true;
@ -2228,16 +2219,10 @@ void Session::findIncompleteFiles(const TorrentInfo &torrentInfo, const QString
const QStringList originalFileNames = torrentInfo.filePaths(); const QStringList originalFileNames = torrentInfo.filePaths();
const QString completeSavePath = savePath; const QString completeSavePath = savePath;
const QString incompleteSavePath = (isTempPathEnabled() ? torrentTempPath(torrentInfo) : QString {}); const QString incompleteSavePath = (isTempPathEnabled() ? torrentTempPath(torrentInfo) : QString {});
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
QMetaObject::invokeMethod(m_fileSearcher, [=]() QMetaObject::invokeMethod(m_fileSearcher, [=]()
{ {
m_fileSearcher->search(searchId, originalFileNames, completeSavePath, incompleteSavePath); m_fileSearcher->search(searchId, originalFileNames, completeSavePath, incompleteSavePath);
}); });
#else
QMetaObject::invokeMethod(m_fileSearcher, "search"
, Q_ARG(BitTorrent::TorrentID, searchId), Q_ARG(QStringList, originalFileNames)
, Q_ARG(QString, completeSavePath), Q_ARG(QString, incompleteSavePath));
#endif
} }
// Add a torrent to libtorrent session in hidden mode // Add a torrent to libtorrent session in hidden mode
@ -2387,24 +2372,15 @@ void Session::saveTorrentsQueue() const
data += (torrentID.toLatin1() + '\n'); data += (torrentID.toLatin1() + '\n');
const QString filename = QLatin1String {"queue"}; const QString filename = QLatin1String {"queue"};
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
QMetaObject::invokeMethod(m_resumeDataSavingManager QMetaObject::invokeMethod(m_resumeDataSavingManager
, [this, data, filename]() { m_resumeDataSavingManager->save(filename, data); }); , [this, data, filename]() { m_resumeDataSavingManager->save(filename, data); });
#else
QMetaObject::invokeMethod(m_resumeDataSavingManager, "save"
, Q_ARG(QString, filename), Q_ARG(QByteArray, data));
#endif
} }
void Session::removeTorrentsQueue() const void Session::removeTorrentsQueue() const
{ {
const QString filename = QLatin1String {"queue"}; const QString filename = QLatin1String {"queue"};
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
QMetaObject::invokeMethod(m_resumeDataSavingManager QMetaObject::invokeMethod(m_resumeDataSavingManager
, [this, filename]() { m_resumeDataSavingManager->remove(filename); }); , [this, filename]() { m_resumeDataSavingManager->remove(filename); });
#else
QMetaObject::invokeMethod(m_resumeDataSavingManager, "remove", Q_ARG(QString, filename));
#endif
} }
void Session::setDefaultSavePath(QString path) void Session::setDefaultSavePath(QString path)
@ -3953,13 +3929,8 @@ void Session::handleTorrentResumeDataReady(TorrentImpl *const torrent, const std
// Copying lt::entry objects around isn't cheap. // Copying lt::entry objects around isn't cheap.
const QString filename = QString::fromLatin1("%1.fastresume").arg(torrent->id().toString()); const QString filename = QString::fromLatin1("%1.fastresume").arg(torrent->id().toString());
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
QMetaObject::invokeMethod(m_resumeDataSavingManager QMetaObject::invokeMethod(m_resumeDataSavingManager
, [this, filename, data]() { m_resumeDataSavingManager->save(filename, data); }); , [this, filename, data]() { m_resumeDataSavingManager->save(filename, data); });
#else
QMetaObject::invokeMethod(m_resumeDataSavingManager, "save"
, Q_ARG(QString, filename), Q_ARG(std::shared_ptr<lt::entry>, data));
#endif
} }
void Session::handleTorrentTrackerReply(TorrentImpl *const torrent, const QString &trackerUrl) void Session::handleTorrentTrackerReply(TorrentImpl *const torrent, const QString &trackerUrl)
@ -4118,15 +4089,9 @@ void Session::configureDeferred()
{ {
if (m_deferredConfigureScheduled) if (m_deferredConfigureScheduled)
return; return;
m_deferredConfigureScheduled = true;
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)) m_deferredConfigureScheduled = true;
QMetaObject::invokeMethod(this QMetaObject::invokeMethod(this, qOverload<>(&Session::configure), Qt::QueuedConnection);
, qOverload<>(&Session::configure)
, Qt::QueuedConnection);
#else
QMetaObject::invokeMethod(this, "configure", Qt::QueuedConnection);
#endif
} }
// Enable IP Filtering // Enable IP Filtering

5
src/base/bittorrent/session.h

@ -790,8 +790,3 @@ namespace BitTorrent
static Session *m_instance; static Session *m_instance;
}; };
} }
#if (QT_VERSION < QT_VERSION_CHECK(5, 10, 0))
Q_DECLARE_METATYPE(std::shared_ptr<lt::entry>)
const int sharedPtrLtEntryTypeID = qRegisterMetaType<std::shared_ptr<lt::entry>>();
#endif

4
src/base/bittorrent/torrentinfo.cpp

@ -492,11 +492,7 @@ void TorrentInfo::addRootFolder()
const QString extension = Utils::Fs::fileExtension(originalName); const QString extension = Utils::Fs::fileExtension(originalName);
const QString rootFolder = extension.isEmpty() const QString rootFolder = extension.isEmpty()
? originalName ? originalName
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
: originalName.chopped(extension.size() + 1); : originalName.chopped(extension.size() + 1);
#else
: originalName.left(originalName.size() - (extension.size() + 1));
#endif
const std::string rootPrefix = Utils::Fs::toNativePath(rootFolder + QLatin1Char {'/'}).toStdString(); const std::string rootPrefix = Utils::Fs::toNativePath(rootFolder + QLatin1Char {'/'}).toStdString();
lt::file_storage files = m_nativeInfo->files(); lt::file_storage files = m_nativeInfo->files();
files.set_name(rootFolder.toStdString()); files.set_name(rootFolder.toStdString());

2
src/base/preferences.cpp

@ -863,7 +863,7 @@ void Preferences::setAutoRunProgram(const QString &program)
setValue("AutoRun/program", program); setValue("AutoRun/program", program);
} }
#if defined(Q_OS_WIN) && (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)) #if defined(Q_OS_WIN)
bool Preferences::isAutoRunConsoleEnabled() const bool Preferences::isAutoRunConsoleEnabled() const
{ {
return value("AutoRun/ConsoleEnabled", false).toBool(); return value("AutoRun/ConsoleEnabled", false).toBool();

2
src/base/preferences.h

@ -248,7 +248,7 @@ public:
void setAutoRunEnabled(bool enabled); void setAutoRunEnabled(bool enabled);
QString getAutoRunProgram() const; QString getAutoRunProgram() const;
void setAutoRunProgram(const QString &program); void setAutoRunProgram(const QString &program);
#if defined(Q_OS_WIN) && (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)) #if defined(Q_OS_WIN)
bool isAutoRunConsoleEnabled() const; bool isAutoRunConsoleEnabled() const;
void setAutoRunConsoleEnabled(bool enabled); void setAutoRunConsoleEnabled(bool enabled);
#endif #endif

5
src/base/rss/rss_parser.cpp

@ -547,13 +547,8 @@ Parser::Parser(const QString lastBuildDate)
void Parser::parse(const QByteArray &feedData) void Parser::parse(const QByteArray &feedData)
{ {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
QMetaObject::invokeMethod(this, [this, feedData]() { parse_impl(feedData); } QMetaObject::invokeMethod(this, [this, feedData]() { parse_impl(feedData); }
, Qt::QueuedConnection); , Qt::QueuedConnection);
#else
QMetaObject::invokeMethod(this, "parse_impl", Qt::QueuedConnection
, Q_ARG(QByteArray, feedData));
#endif
} }
// read and create items from a rss document // read and create items from a rss document

4
src/base/utils/fs.cpp

@ -78,11 +78,7 @@ QString Utils::Fs::toUniformPath(const QString &path)
QString Utils::Fs::fileExtension(const QString &filename) QString Utils::Fs::fileExtension(const QString &filename)
{ {
const QString name = filename.endsWith(QB_EXT) const QString name = filename.endsWith(QB_EXT)
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
? filename.chopped(QB_EXT.length()) ? filename.chopped(QB_EXT.length())
#else
? filename.left(filename.length() - QB_EXT.length())
#endif
: filename; : filename;
return QMimeDatabase().suffixForFileName(name); return QMimeDatabase().suffixForFileName(name);
} }

12
src/gui/autoexpandabledialog.cpp

@ -79,31 +79,19 @@ void AutoExpandableDialog::showEvent(QShowEvent *e)
// Show dialog and resize textbox to fit the text // Show dialog and resize textbox to fit the text
// NOTE: For unknown reason QFontMetrics gets more accurate when called from showEvent. // NOTE: For unknown reason QFontMetrics gets more accurate when called from showEvent.
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
int wd = m_ui->textEdit->fontMetrics().horizontalAdvance(m_ui->textEdit->text()) + 4; int wd = m_ui->textEdit->fontMetrics().horizontalAdvance(m_ui->textEdit->text()) + 4;
#else
int wd = m_ui->textEdit->fontMetrics().width(m_ui->textEdit->text()) + 4;
#endif
if (!windowTitle().isEmpty()) if (!windowTitle().isEmpty())
{ {
// not really the font metrics in window title, so we enlarge it a bit, // not really the font metrics in window title, so we enlarge it a bit,
// including the small icon and close button width // including the small icon and close button width
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
int w = fontMetrics().horizontalAdvance(windowTitle()) * 1.8; int w = fontMetrics().horizontalAdvance(windowTitle()) * 1.8;
#else
int w = fontMetrics().width(windowTitle()) * 1.8;
#endif
wd = std::max(wd, w); wd = std::max(wd, w);
} }
if (!m_ui->textLabel->text().isEmpty()) if (!m_ui->textLabel->text().isEmpty())
{ {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
int w = m_ui->textLabel->fontMetrics().horizontalAdvance(m_ui->textLabel->text()); int w = m_ui->textLabel->fontMetrics().horizontalAdvance(m_ui->textLabel->text());
#else
int w = m_ui->textLabel->fontMetrics().width(m_ui->textLabel->text());
#endif
wd = std::max(wd, w); wd = std::max(wd, w);
} }

4
src/gui/log/loglistview.cpp

@ -46,11 +46,7 @@ namespace
int horizontalAdvance(const QFontMetrics &fontMetrics, const QString &text) int horizontalAdvance(const QFontMetrics &fontMetrics, const QString &text)
{ {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
return fontMetrics.horizontalAdvance(text); return fontMetrics.horizontalAdvance(text);
#else
return fontMetrics.width(text);
#endif
} }
QString logText(const QModelIndex &index) QString logText(const QModelIndex &index)

4
src/gui/optionsdialog.cpp

@ -753,7 +753,7 @@ void OptionsDialog::saveOptions()
pref->setMailNotificationSMTPPassword(m_ui->mailNotifPassword->text()); pref->setMailNotificationSMTPPassword(m_ui->mailNotifPassword->text());
pref->setAutoRunEnabled(m_ui->autoRunBox->isChecked()); pref->setAutoRunEnabled(m_ui->autoRunBox->isChecked());
pref->setAutoRunProgram(m_ui->lineEditAutoRun->text().trimmed()); pref->setAutoRunProgram(m_ui->lineEditAutoRun->text().trimmed());
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)) && defined(Q_OS_WIN) #if defined(Q_OS_WIN)
pref->setAutoRunConsoleEnabled(m_ui->autoRunConsole->isChecked()); pref->setAutoRunConsoleEnabled(m_ui->autoRunConsole->isChecked());
#endif #endif
pref->setActionOnDblClOnTorrentDl(getActionOnDblClOnTorrentDl()); pref->setActionOnDblClOnTorrentDl(getActionOnDblClOnTorrentDl());
@ -1043,7 +1043,7 @@ void OptionsDialog::loadOptions()
m_ui->autoRunBox->setChecked(pref->isAutoRunEnabled()); m_ui->autoRunBox->setChecked(pref->isAutoRunEnabled());
m_ui->lineEditAutoRun->setText(pref->getAutoRunProgram()); m_ui->lineEditAutoRun->setText(pref->getAutoRunProgram());
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)) && defined(Q_OS_WIN) #if defined(Q_OS_WIN)
m_ui->autoRunConsole->setChecked(pref->isAutoRunConsoleEnabled()); m_ui->autoRunConsole->setChecked(pref->isAutoRunConsoleEnabled());
#else #else
m_ui->autoRunConsole->hide(); m_ui->autoRunConsole->hide();

16
src/gui/properties/speedplotview.cpp

@ -304,13 +304,10 @@ void SpeedPlotView::paintEvent(QPaintEvent *)
int yAxisWidth = 0; int yAxisWidth = 0;
for (const QString &label : speedLabels) for (const QString &label : speedLabels)
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)) {
if (fontMetrics.horizontalAdvance(label) > yAxisWidth) if (fontMetrics.horizontalAdvance(label) > yAxisWidth)
yAxisWidth = fontMetrics.horizontalAdvance(label); yAxisWidth = fontMetrics.horizontalAdvance(label);
#else }
if (fontMetrics.width(label) > yAxisWidth)
yAxisWidth = fontMetrics.width(label);
#endif
int i = 0; int i = 0;
for (const QString &label : speedLabels) for (const QString &label : speedLabels)
@ -391,13 +388,8 @@ void SpeedPlotView::paintEvent(QPaintEvent *)
if (!property.enable) if (!property.enable)
continue; continue;
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
if (fontMetrics.horizontalAdvance(property.name) > legendWidth) if (fontMetrics.horizontalAdvance(property.name) > legendWidth)
legendWidth = fontMetrics.horizontalAdvance(property.name); legendWidth = fontMetrics.horizontalAdvance(property.name);
#else
if (fontMetrics.width(property.name) > legendWidth)
legendWidth = fontMetrics.width(property.name);
#endif
legendHeight += 1.5 * fontMetrics.height(); legendHeight += 1.5 * fontMetrics.height();
} }
@ -412,11 +404,7 @@ void SpeedPlotView::paintEvent(QPaintEvent *)
if (!property.enable) if (!property.enable)
continue; continue;
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
int nameSize = fontMetrics.horizontalAdvance(property.name); int nameSize = fontMetrics.horizontalAdvance(property.name);
#else
int nameSize = fontMetrics.width(property.name);
#endif
double indent = 1.5 * (i++) * fontMetrics.height(); double indent = 1.5 * (i++) * fontMetrics.height();
painter.setPen(property.pen); painter.setPen(property.pen);

2
src/gui/rss/automatedrssdownloader.cpp

@ -187,7 +187,7 @@ void AutomatedRssDownloader::loadFeedList()
{ {
QListWidgetItem *item = new QListWidgetItem(feed->name(), m_ui->listFeeds); QListWidgetItem *item = new QListWidgetItem(feed->name(), m_ui->listFeeds);
item->setData(Qt::UserRole, feed->url()); item->setData(Qt::UserRole, feed->url());
item->setFlags(item->flags() | Qt::ItemIsUserCheckable | Qt::ItemIsTristate); item->setFlags(item->flags() | Qt::ItemIsUserCheckable | Qt::ItemIsAutoTristate);
} }
updateFeedList(); updateFeedList();

2
src/gui/torrentcontentmodel.cpp

@ -386,7 +386,7 @@ Qt::ItemFlags TorrentContentModel::flags(const QModelIndex &index) const
Qt::ItemFlags flags {Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable}; Qt::ItemFlags flags {Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable};
if (itemType(index) == TorrentContentModelItem::FolderType) if (itemType(index) == TorrentContentModelItem::FolderType)
flags |= Qt::ItemIsTristate; flags |= Qt::ItemIsAutoTristate;
if (index.column() == TorrentContentModelItem::COL_PRIO) if (index.column() == TorrentContentModelItem::COL_PRIO)
flags |= Qt::ItemIsEditable; flags |= Qt::ItemIsEditable;

4
src/webui/api/synccontroller.cpp

@ -611,9 +611,5 @@ void SyncController::freeDiskSpaceSizeUpdated(qint64 freeSpaceSize)
void SyncController::invokeChecker() const void SyncController::invokeChecker() const
{ {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
QMetaObject::invokeMethod(m_freeDiskSpaceChecker, &FreeDiskSpaceChecker::check, Qt::QueuedConnection); QMetaObject::invokeMethod(m_freeDiskSpaceChecker, &FreeDiskSpaceChecker::check, Qt::QueuedConnection);
#else
QMetaObject::invokeMethod(m_freeDiskSpaceChecker, "check", Qt::QueuedConnection);
#endif
} }

Loading…
Cancel
Save