From 93204a63ad244aec14ed0676dc82a3884c1e3aad Mon Sep 17 00:00:00 2001 From: sledgehammer999 Date: Mon, 10 Jul 2023 01:09:28 +0300 Subject: [PATCH] Disable update checks on versions before Windows 10 On versions before Windows 10 the user is running the Qt5 build. The next qBittorrent release will change to Qt6 as the default build. It is counterintuitive to tell the user about available updates when they are running an incompatible Windows version. --- src/gui/mainwindow.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 5fd86649c..849cac439 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -31,6 +31,11 @@ #include #include +#if defined(Q_OS_WIN) +#include +#include // must follow after Windows.h +#endif + #include #include #include @@ -273,9 +278,15 @@ MainWindow::MainWindow(IGUIApplication *app, const State initialState) #if defined(Q_OS_WIN) || defined(Q_OS_MACOS) connect(m_ui->actionCheckForUpdates, &QAction::triggered, this, [this]() { checkProgramUpdate(true); }); +#ifdef Q_OS_WIN + if (::IsWindows10OrGreater() && pref->isUpdateCheckEnabled()) + checkProgramUpdate(false); +#else + // trigger an early check on startup if (pref->isUpdateCheckEnabled()) checkProgramUpdate(false); +#endif #else m_ui->actionCheckForUpdates->setVisible(false); #endif @@ -1483,7 +1494,11 @@ void MainWindow::loadPreferences() #if defined(Q_OS_WIN) || defined(Q_OS_MACOS) if (pref->isUpdateCheckEnabled()) { +#ifdef Q_OS_WIN + if (::IsWindows10OrGreater() && !m_programUpdateTimer) +#else if (!m_programUpdateTimer) +#endif { m_programUpdateTimer = new QTimer(this); m_programUpdateTimer->setInterval(24h); @@ -1919,6 +1934,21 @@ void MainWindow::updatePowerManagementState() #if defined(Q_OS_WIN) || defined(Q_OS_MACOS) void MainWindow::checkProgramUpdate(const bool invokedByUser) { +#ifdef Q_OS_WIN + if (!::IsWindows10OrGreater()) + { + if (invokedByUser) { + auto *msgBox = new QMessageBox {QMessageBox::Information, u"qBittorrent"_qs + , tr("This is the last supported version for your Windows version.") + , QMessageBox::Ok, this}; + msgBox->setAttribute(Qt::WA_DeleteOnClose); + msgBox->show(); + } + + return; + } +#endif + if (m_programUpdateTimer) m_programUpdateTimer->stop();