Skip to content

Commit

Permalink
Raise minimum supported Qt version to 5.12
Browse files Browse the repository at this point in the history
  • Loading branch information
glassez authored and sledgehammer999 committed Mar 23, 2021
1 parent 8cae8ad commit 4037143
Show file tree
Hide file tree
Showing 20 changed files with 42 additions and 148 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Expand Up @@ -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.9.5)
set(minQtVersion 5.12)
set(minOpenSSLVersion 1.1.1)
set(minLibtorrentVersion 1.2.12)
set(minZlibVersion 1.2.11)
Expand Down
42 changes: 21 additions & 21 deletions configure
Expand Up @@ -1455,7 +1455,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.9.5, overriding pkg-config
QT_QMAKE value of host_bins for Qt5Core >= 5.12, overriding pkg-config
Qt5Svg_CFLAGS
C compiler flags for Qt5Svg, overriding pkg-config
Qt5Svg_LIBS linker flags for Qt5Svg, overriding pkg-config
Expand Down Expand Up @@ -5525,8 +5525,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.9.5\""; } >&5
($PKG_CONFIG --exists --print-errors "Qt5Core >= 5.9.5") 2>&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.12") 2>&5
ac_status=$?
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
Expand All @@ -5535,12 +5535,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.9.5\""; } >&5
($PKG_CONFIG --exists --print-errors "Qt5Core >= 5.9.5") 2>&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.12") 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.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
else
pkg_failed=yes
Expand Down Expand Up @@ -5570,8 +5570,8 @@ fi
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for Qt5 qmake >= 5.9.5" >&5
printf %s "checking for Qt5 qmake >= 5.9.5... " >&6; }
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for Qt5 qmake >= 5.12" >&5
printf %s "checking for Qt5 qmake >= 5.12... " >&6; }
if test "x$QT_QMAKE" != "x"
then :
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $QT_QMAKE" >&5
Expand All @@ -5598,12 +5598,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.5.1\""; } >&5
($PKG_CONFIG --exists --print-errors "Qt5Svg >= 5.5.1") 2>&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.12") 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.5.1" 2>/dev/null`
pkg_cv_Qt5Svg_CFLAGS=`$PKG_CONFIG --cflags "Qt5Svg >= 5.12" 2>/dev/null`
test "x$?" != "x0" && pkg_failed=yes
else
pkg_failed=yes
Expand All @@ -5615,12 +5615,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.5.1\""; } >&5
($PKG_CONFIG --exists --print-errors "Qt5Svg >= 5.5.1") 2>&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.12") 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.5.1" 2>/dev/null`
pkg_cv_Qt5Svg_LIBS=`$PKG_CONFIG --libs "Qt5Svg >= 5.12" 2>/dev/null`
test "x$?" != "x0" && pkg_failed=yes
else
pkg_failed=yes
Expand All @@ -5641,14 +5641,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.5.1" 2>&1`
Qt5Svg_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "Qt5Svg >= 5.12" 2>&1`
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
# Put the nasty error message in config.log where it belongs
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
Expand Down Expand Up @@ -5688,11 +5688,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.9.5" >&5
printf %s "checking for Qt5DBus >= 5.9.5... " >&6; }
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for Qt5DBus >= 5.12" >&5
printf %s "checking for Qt5DBus >= 5.12... " >&6; }
if test -n "$PKG_CONFIG" && \
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"Qt5DBus >= 5.9.5\""; } >&5
($PKG_CONFIG --exists --print-errors "Qt5DBus >= 5.9.5") 2>&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.12") 2>&5
ac_status=$?
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Expand Up @@ -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.5.1])
[PKG_CHECK_MODULES(Qt5Svg, [Qt5Svg >= 5.12])
])
AC_MSG_CHECKING([whether QtDBus should be enabled])
AS_CASE(["x$enable_qt_dbus"],
Expand Down
10 changes: 5 additions & 5 deletions m4/qbittorrent.m4
Expand Up @@ -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.9.5],
[PKG_CHECK_EXISTS([Qt5Core >= 5.12],
[PKG_CHECK_VAR(QT_QMAKE,
[Qt5Core >= 5.9.5],
[Qt5Core >= 5.12],
[host_bins])
])
Expand All @@ -18,7 +18,7 @@ AS_IF([test -f "$QT_QMAKE/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"],
[AC_MSG_RESULT([$QT_QMAKE])],
[AC_MSG_RESULT([not found])]
Expand All @@ -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.9.5])
PKG_CHECK_EXISTS([Qt5DBus >= 5.9.5],
[AC_MSG_CHECKING([for Qt5DBus >= 5.12])
PKG_CHECK_EXISTS([Qt5DBus >= 5.12],
[AC_MSG_RESULT([found])
HAVE_QTDBUS=[true]],
[AC_MSG_RESULT([not found])
Expand Down
12 changes: 2 additions & 10 deletions src/app/CMakeLists.txt
Expand Up @@ -4,22 +4,14 @@
# Based on https://gist.github.com/giraldeau/546ba5512a74dfe9d8ea0862d66db412
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")
if (Qt5_VERSION VERSION_LESS 5.12)
qt5_add_translation(QBT_QM_FILES ${QBT_TS_FILES})
else()
qt5_add_translation(QBT_QM_FILES ${QBT_TS_FILES} OPTIONS -silent)
endif()
qt5_add_translation(QBT_QM_FILES ${QBT_TS_FILES} OPTIONS -silent)
configure_file("${qBittorrent_SOURCE_DIR}/src/lang/lang.qrc" "${qBittorrent_BINARY_DIR}/src/lang/lang.qrc" COPYONLY)

if (WEBUI)
file(GLOB QBT_WEBUI_TS_FILES "${qBittorrent_SOURCE_DIR}/src/webui/www/translations/*.ts")
set_source_files_properties(${QBT_WEBUI_TS_FILES}
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)
endif()
qt5_add_translation(QBT_WEBUI_QM_FILES ${QBT_WEBUI_TS_FILES} OPTIONS -silent)
configure_file("${qBittorrent_SOURCE_DIR}/src/webui/www/translations/webui_translations.qrc"
"${qBittorrent_BINARY_DIR}/src/webui/www/translations/webui_translations.qrc" COPYONLY)
endif()
Expand Down
4 changes: 0 additions & 4 deletions src/app/application.cpp
Expand Up @@ -403,7 +403,6 @@ void Application::runExternalProgram(const BitTorrent::Torrent *torrent) const
for (int i = 1; i < argCount; ++i)
argList += QString::fromWCharArray(args[i]);

#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
QProcess proc;
proc.setProgram(QString::fromWCharArray(args[0]));
proc.setArguments(argList);
Expand All @@ -429,9 +428,6 @@ void Application::runExternalProgram(const BitTorrent::Torrent *torrent) const
args->startupInfo->hStdError = nullptr;
});
proc.startDetached();
#else
QProcess::startDetached(QString::fromWCharArray(args[0]), argList);
#endif // QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
#else // Q_OS_WIN
// Cannot give users shell environment by default, as doing so could
// enable command injection via torrent name and other arguments
Expand Down
6 changes: 1 addition & 5 deletions src/app/main.cpp
Expand Up @@ -235,7 +235,7 @@ int main(int argc, char *argv[])
// 3. https://bugreports.qt.io/browse/QTBUG-46015

qputenv("QT_BEARER_POLL_TIMEOUT", QByteArray::number(-1));
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)) && !defined(DISABLE_GUI)
#if !defined(DISABLE_GUI)
// this is the default in Qt6
app->setAttribute(Qt::AA_DisableWindowContextHelpButton);
#endif
Expand Down Expand Up @@ -381,11 +381,7 @@ void showSplashScreen()
const QString version = QBT_VERSION;
painter.setPen(QPen(Qt::white));
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);
#else
painter.drawText(224 - painter.fontMetrics().width(version), 270, version);
#endif
QSplashScreen *splash = new QSplashScreen(splashImg);
splash->show();
QTimer::singleShot(1500, splash, &QObject::deleteLater);
Expand Down
5 changes: 0 additions & 5 deletions src/base/asyncfilestorage.cpp
Expand Up @@ -55,13 +55,8 @@ AsyncFileStorage::~AsyncFileStorage()

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); }
, Qt::QueuedConnection);
#else
QMetaObject::invokeMethod(this, "store_impl", Qt::QueuedConnection
, Q_ARG(QString, fileName), Q_ARG(QByteArray, data));
#endif
}

QDir AsyncFileStorage::storageDir() const
Expand Down
45 changes: 5 additions & 40 deletions src/base/bittorrent/session.cpp
Expand Up @@ -1111,11 +1111,7 @@ void Session::initializeNativeSession()

m_nativeSession->set_alert_notify([this]()
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
QMetaObject::invokeMethod(this, &Session::readAlerts, Qt::QueuedConnection);
#else
QMetaObject::invokeMethod(this, "readAlerts", Qt::QueuedConnection);
#endif
});

// Enabling plugins
Expand Down Expand Up @@ -1854,18 +1850,13 @@ bool Session::deleteTorrent(const TorrentID &id, const DeleteOption deleteOption
}

// Remove it from torrent resume directory
const QString resumedataFile = QString::fromLatin1("%1.fastresume").arg(torrent->id().toString());
const QString metadataFile = QString::fromLatin1("%1.torrent").arg(torrent->id().toString());
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
const QString resumedataFile = QString::fromLatin1("%1.fastresume").arg(torrent->id());
const QString metadataFile = QString::fromLatin1("%1.torrent").arg(torrent->id());
QMetaObject::invokeMethod(m_resumeDataSavingManager, [this, resumedataFile, metadataFile]()
{
m_resumeDataSavingManager->remove(resumedataFile);
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;
return true;
Expand Down Expand Up @@ -2228,16 +2219,10 @@ void Session::findIncompleteFiles(const TorrentInfo &torrentInfo, const QString
const QStringList originalFileNames = torrentInfo.filePaths();
const QString completeSavePath = savePath;
const QString incompleteSavePath = (isTempPathEnabled() ? torrentTempPath(torrentInfo) : QString {});
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
QMetaObject::invokeMethod(m_fileSearcher, [=]()
{
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
Expand Down Expand Up @@ -2387,24 +2372,15 @@ void Session::saveTorrentsQueue() const
data += (torrentID.toLatin1() + '\n');

const QString filename = QLatin1String {"queue"};
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
QMetaObject::invokeMethod(m_resumeDataSavingManager
, [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
{
const QString filename = QLatin1String {"queue"};
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
QMetaObject::invokeMethod(m_resumeDataSavingManager
, [this, filename]() { m_resumeDataSavingManager->remove(filename); });
#else
QMetaObject::invokeMethod(m_resumeDataSavingManager, "remove", Q_ARG(QString, filename));
#endif
}

void Session::setDefaultSavePath(QString path)
Expand Down Expand Up @@ -3952,14 +3928,9 @@ void Session::handleTorrentResumeDataReady(TorrentImpl *const torrent, const std
// Separated thread is used for the blocking IO which results in slow processing of many torrents.
// Copying lt::entry objects around isn't cheap.

const QString filename = QString::fromLatin1("%1.fastresume").arg(torrent->id().toString());
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
const QString filename = QString::fromLatin1("%1.fastresume").arg(torrent->id());
QMetaObject::invokeMethod(m_resumeDataSavingManager
, [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)
Expand Down Expand Up @@ -4118,15 +4089,9 @@ void Session::configureDeferred()
{
if (m_deferredConfigureScheduled)
return;
m_deferredConfigureScheduled = true;

#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
QMetaObject::invokeMethod(this
, qOverload<>(&Session::configure)
, Qt::QueuedConnection);
#else
QMetaObject::invokeMethod(this, "configure", Qt::QueuedConnection);
#endif
m_deferredConfigureScheduled = true;
QMetaObject::invokeMethod(this, qOverload<>(&Session::configure), Qt::QueuedConnection);
}

// Enable IP Filtering
Expand Down
5 changes: 0 additions & 5 deletions src/base/bittorrent/session.h
Expand Up @@ -790,8 +790,3 @@ namespace BitTorrent
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 changes: 0 additions & 4 deletions src/base/bittorrent/torrentinfo.cpp
Expand Up @@ -492,11 +492,7 @@ void TorrentInfo::addRootFolder()
const QString extension = Utils::Fs::fileExtension(originalName);
const QString rootFolder = extension.isEmpty()
? originalName
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
: originalName.chopped(extension.size() + 1);
#else
: originalName.left(originalName.size() - (extension.size() + 1));
#endif
const std::string rootPrefix = Utils::Fs::toNativePath(rootFolder + QLatin1Char {'/'}).toStdString();
lt::file_storage files = m_nativeInfo->files();
files.set_name(rootFolder.toStdString());
Expand Down
2 changes: 1 addition & 1 deletion src/base/preferences.cpp
Expand Up @@ -863,7 +863,7 @@ void Preferences::setAutoRunProgram(const QString &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
{
return value("AutoRun/ConsoleEnabled", false).toBool();
Expand Down
2 changes: 1 addition & 1 deletion src/base/preferences.h
Expand Up @@ -248,7 +248,7 @@ class Preferences : public QObject
void setAutoRunEnabled(bool enabled);
QString getAutoRunProgram() const;
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;
void setAutoRunConsoleEnabled(bool enabled);
#endif
Expand Down

0 comments on commit 4037143

Please sign in to comment.