Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable update checks on versions before Windows 10 #19295

Merged
merged 1 commit into from
Jul 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/gui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
#include <algorithm>
#include <chrono>

#if defined(Q_OS_WIN)
#include <Windows.h>
#include <versionhelpers.h> // must follow after Windows.h
#endif

#include <QActionGroup>
#include <QClipboard>
#include <QCloseEvent>
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();

Expand Down
Loading