|
|
@ -90,7 +90,6 @@ |
|
|
|
#include "statsdialog.h" |
|
|
|
#include "statsdialog.h" |
|
|
|
#include "statusbar.h" |
|
|
|
#include "statusbar.h" |
|
|
|
#include "torrentcreatordialog.h" |
|
|
|
#include "torrentcreatordialog.h" |
|
|
|
|
|
|
|
|
|
|
|
#include "transferlistfilterswidget.h" |
|
|
|
#include "transferlistfilterswidget.h" |
|
|
|
#include "transferlistmodel.h" |
|
|
|
#include "transferlistmodel.h" |
|
|
|
#include "transferlistwidget.h" |
|
|
|
#include "transferlistwidget.h" |
|
|
@ -105,6 +104,8 @@ |
|
|
|
#include "programupdater.h" |
|
|
|
#include "programupdater.h" |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using namespace std::chrono_literals; |
|
|
|
|
|
|
|
|
|
|
|
namespace |
|
|
|
namespace |
|
|
|
{ |
|
|
|
{ |
|
|
|
#define SETTINGS_KEY(name) "GUI/" name |
|
|
|
#define SETTINGS_KEY(name) "GUI/" name |
|
|
@ -148,9 +149,6 @@ MainWindow::MainWindow(QWidget *parent) |
|
|
|
, m_posInitialized(false) |
|
|
|
, m_posInitialized(false) |
|
|
|
, m_forceExit(false) |
|
|
|
, m_forceExit(false) |
|
|
|
, m_unlockDlgShowing(false) |
|
|
|
, m_unlockDlgShowing(false) |
|
|
|
#if defined(Q_OS_WIN) || defined(Q_OS_MACOS) |
|
|
|
|
|
|
|
, m_wasUpdateCheckEnabled(false) |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
, m_hasPython(false) |
|
|
|
, m_hasPython(false) |
|
|
|
{ |
|
|
|
{ |
|
|
|
m_ui->setupUi(this); |
|
|
|
m_ui->setupUi(this); |
|
|
@ -317,11 +315,11 @@ MainWindow::MainWindow(QWidget *parent) |
|
|
|
connect(m_ui->actionUseAlternativeSpeedLimits, &QAction::triggered, this, &MainWindow::toggleAlternativeSpeeds); |
|
|
|
connect(m_ui->actionUseAlternativeSpeedLimits, &QAction::triggered, this, &MainWindow::toggleAlternativeSpeeds); |
|
|
|
|
|
|
|
|
|
|
|
#if defined(Q_OS_WIN) || defined(Q_OS_MACOS) |
|
|
|
#if defined(Q_OS_WIN) || defined(Q_OS_MACOS) |
|
|
|
m_programUpdateTimer = new QTimer(this); |
|
|
|
connect(m_ui->actionCheckForUpdates, &QAction::triggered, this, [this]() { checkProgramUpdate(true); }); |
|
|
|
m_programUpdateTimer->setInterval(60 * 60 * 1000); |
|
|
|
|
|
|
|
m_programUpdateTimer->setSingleShot(true); |
|
|
|
// trigger an early check on startup
|
|
|
|
connect(m_programUpdateTimer, &QTimer::timeout, this, &MainWindow::checkProgramUpdate); |
|
|
|
if (pref->isUpdateCheckEnabled()) |
|
|
|
connect(m_ui->actionCheckForUpdates, &QAction::triggered, this, &MainWindow::checkProgramUpdate); |
|
|
|
checkProgramUpdate(false); |
|
|
|
#else |
|
|
|
#else |
|
|
|
m_ui->actionCheckForUpdates->setVisible(false); |
|
|
|
m_ui->actionCheckForUpdates->setVisible(false); |
|
|
|
#endif |
|
|
|
#endif |
|
|
@ -804,6 +802,7 @@ void MainWindow::cleanup() |
|
|
|
m_preventTimer->stop(); |
|
|
|
m_preventTimer->stop(); |
|
|
|
|
|
|
|
|
|
|
|
#if (defined(Q_OS_WIN) || defined(Q_OS_MACOS)) |
|
|
|
#if (defined(Q_OS_WIN) || defined(Q_OS_MACOS)) |
|
|
|
|
|
|
|
if (m_programUpdateTimer) |
|
|
|
m_programUpdateTimer->stop(); |
|
|
|
m_programUpdateTimer->stop(); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
@ -1583,15 +1582,21 @@ void MainWindow::loadPreferences(const bool configureSession) |
|
|
|
m_propertiesWidget->reloadPreferences(); |
|
|
|
m_propertiesWidget->reloadPreferences(); |
|
|
|
|
|
|
|
|
|
|
|
#if defined(Q_OS_WIN) || defined(Q_OS_MACOS) |
|
|
|
#if defined(Q_OS_WIN) || defined(Q_OS_MACOS) |
|
|
|
if (pref->isUpdateCheckEnabled() && !m_wasUpdateCheckEnabled) |
|
|
|
if (pref->isUpdateCheckEnabled()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (!m_programUpdateTimer) |
|
|
|
{ |
|
|
|
{ |
|
|
|
m_wasUpdateCheckEnabled = true; |
|
|
|
m_programUpdateTimer = new QTimer(this); |
|
|
|
checkProgramUpdate(); |
|
|
|
m_programUpdateTimer->setInterval(24h); |
|
|
|
|
|
|
|
m_programUpdateTimer->setSingleShot(true); |
|
|
|
|
|
|
|
connect(m_programUpdateTimer, &QTimer::timeout, this, [this]() { checkProgramUpdate(false); }); |
|
|
|
|
|
|
|
m_programUpdateTimer->start(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else if (!pref->isUpdateCheckEnabled() && m_wasUpdateCheckEnabled) |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
m_wasUpdateCheckEnabled = false; |
|
|
|
delete m_programUpdateTimer; |
|
|
|
m_programUpdateTimer->stop(); |
|
|
|
m_programUpdateTimer = nullptr; |
|
|
|
} |
|
|
|
} |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
@ -1897,15 +1902,21 @@ void MainWindow::on_actionDownloadFromURL_triggered() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#if defined(Q_OS_WIN) || defined(Q_OS_MACOS) |
|
|
|
#if defined(Q_OS_WIN) || defined(Q_OS_MACOS) |
|
|
|
void MainWindow::handleUpdateCheckFinished(const bool updateAvailable, const QString &newVersion, const bool invokedByUser) |
|
|
|
void MainWindow::handleUpdateCheckFinished(ProgramUpdater *updater, const bool invokedByUser) |
|
|
|
{ |
|
|
|
{ |
|
|
|
m_ui->actionCheckForUpdates->setEnabled(true); |
|
|
|
m_ui->actionCheckForUpdates->setEnabled(true); |
|
|
|
m_ui->actionCheckForUpdates->setText(tr("&Check for Updates")); |
|
|
|
m_ui->actionCheckForUpdates->setText(tr("&Check for Updates")); |
|
|
|
m_ui->actionCheckForUpdates->setToolTip(tr("Check for program updates")); |
|
|
|
m_ui->actionCheckForUpdates->setToolTip(tr("Check for program updates")); |
|
|
|
|
|
|
|
|
|
|
|
QObject *signalSender = sender(); |
|
|
|
const auto cleanup = [this, updater]() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (m_programUpdateTimer) |
|
|
|
|
|
|
|
m_programUpdateTimer->start(); |
|
|
|
|
|
|
|
updater->deleteLater(); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
if (updateAvailable) |
|
|
|
const QString newVersion = updater->getNewVersion(); |
|
|
|
|
|
|
|
if (!newVersion.isEmpty()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
const QString msg {tr("A new version is available.") + "<br/>" |
|
|
|
const QString msg {tr("A new version is available.") + "<br/>" |
|
|
|
+ tr("Do you want to download %1?").arg(newVersion) + "<br/><br/>" |
|
|
|
+ tr("Do you want to download %1?").arg(newVersion) + "<br/><br/>" |
|
|
@ -1915,39 +1926,32 @@ void MainWindow::handleUpdateCheckFinished(const bool updateAvailable, const QSt |
|
|
|
msgBox->setAttribute(Qt::WA_DeleteOnClose); |
|
|
|
msgBox->setAttribute(Qt::WA_DeleteOnClose); |
|
|
|
msgBox->setAttribute(Qt::WA_ShowWithoutActivating); |
|
|
|
msgBox->setAttribute(Qt::WA_ShowWithoutActivating); |
|
|
|
msgBox->setDefaultButton(QMessageBox::Yes); |
|
|
|
msgBox->setDefaultButton(QMessageBox::Yes); |
|
|
|
connect(msgBox, &QMessageBox::buttonClicked, this, [this, msgBox, signalSender](QAbstractButton *button) |
|
|
|
connect(msgBox, &QMessageBox::buttonClicked, this, [this, msgBox, updater](QAbstractButton *button) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (msgBox->buttonRole(button) == QMessageBox::YesRole) |
|
|
|
if (msgBox->buttonRole(button) == QMessageBox::YesRole) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// The user want to update, let's download the update
|
|
|
|
|
|
|
|
auto *updater = dynamic_cast<ProgramUpdater *>(signalSender); |
|
|
|
|
|
|
|
updater->updateProgram(); |
|
|
|
updater->updateProgram(); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (Preferences::instance()->isUpdateCheckEnabled()) |
|
|
|
|
|
|
|
m_programUpdateTimer->start(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
signalSender->deleteLater(); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
connect(msgBox, &QDialog::finished, this, cleanup); |
|
|
|
msgBox->open(); |
|
|
|
msgBox->open(); |
|
|
|
} |
|
|
|
} |
|
|
|
else if (invokedByUser) |
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (invokedByUser) |
|
|
|
{ |
|
|
|
{ |
|
|
|
auto *msgBox = new QMessageBox {QMessageBox::Information, QLatin1String("qBittorrent") |
|
|
|
auto *msgBox = new QMessageBox {QMessageBox::Information, QLatin1String("qBittorrent") |
|
|
|
, tr("No updates available.\nYou are already using the latest version.") |
|
|
|
, tr("No updates available.\nYou are already using the latest version.") |
|
|
|
, QMessageBox::Ok, this}; |
|
|
|
, QMessageBox::Ok, this}; |
|
|
|
msgBox->setAttribute(Qt::WA_DeleteOnClose); |
|
|
|
msgBox->setAttribute(Qt::WA_DeleteOnClose); |
|
|
|
connect(msgBox, &QDialog::finished, this, [this, signalSender](const int) |
|
|
|
connect(msgBox, &QDialog::finished, this, cleanup); |
|
|
|
{ |
|
|
|
|
|
|
|
if (Preferences::instance()->isUpdateCheckEnabled()) |
|
|
|
|
|
|
|
m_programUpdateTimer->start(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
signalSender->deleteLater(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
msgBox->open(); |
|
|
|
msgBox->open(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
cleanup(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
@ -2106,18 +2110,23 @@ QIcon MainWindow::getSystrayIcon() const |
|
|
|
#endif // Q_OS_MACOS
|
|
|
|
#endif // Q_OS_MACOS
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(Q_OS_WIN) || defined(Q_OS_MACOS) |
|
|
|
#if defined(Q_OS_WIN) || defined(Q_OS_MACOS) |
|
|
|
void MainWindow::checkProgramUpdate() |
|
|
|
void MainWindow::checkProgramUpdate(const bool invokedByUser) |
|
|
|
{ |
|
|
|
{ |
|
|
|
m_programUpdateTimer->stop(); // If the user had clicked the menu item
|
|
|
|
if (m_programUpdateTimer) |
|
|
|
|
|
|
|
m_programUpdateTimer->stop(); |
|
|
|
|
|
|
|
|
|
|
|
m_ui->actionCheckForUpdates->setEnabled(false); |
|
|
|
m_ui->actionCheckForUpdates->setEnabled(false); |
|
|
|
m_ui->actionCheckForUpdates->setText(tr("Checking for Updates...")); |
|
|
|
m_ui->actionCheckForUpdates->setText(tr("Checking for Updates...")); |
|
|
|
m_ui->actionCheckForUpdates->setToolTip(tr("Already checking for program updates in the background")); |
|
|
|
m_ui->actionCheckForUpdates->setToolTip(tr("Already checking for program updates in the background")); |
|
|
|
bool invokedByUser = m_ui->actionCheckForUpdates == qobject_cast<QAction *>(sender()); |
|
|
|
|
|
|
|
ProgramUpdater *updater = new ProgramUpdater(this, invokedByUser); |
|
|
|
auto *updater = new ProgramUpdater(this); |
|
|
|
connect(updater, &ProgramUpdater::updateCheckFinished, this, &MainWindow::handleUpdateCheckFinished); |
|
|
|
connect(updater, &ProgramUpdater::updateCheckFinished |
|
|
|
|
|
|
|
, this, [this, invokedByUser, updater]() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
handleUpdateCheckFinished(updater, invokedByUser); |
|
|
|
|
|
|
|
}); |
|
|
|
updater->checkForUpdates(); |
|
|
|
updater->checkForUpdates(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
#ifdef Q_OS_WIN |
|
|
|
#ifdef Q_OS_WIN |
|
|
|