From d85a41ad75b644e86d3b26400b0d49653b0f5d50 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Wed, 20 Jan 2021 11:30:14 +0800 Subject: [PATCH 1/3] Disable translation of program name --- src/gui/mainwindow.cpp | 2 +- src/gui/properties/propertieswidget.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 48b54dd6f..291f7260b 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -1916,7 +1916,7 @@ void MainWindow::handleUpdateCheckFinished(bool updateAvailable, QString newVers } else if (invokedByUser) { - QMessageBox::information(this, tr("qBittorrent"), + QMessageBox::information(this, QLatin1String("qBittorrent"), tr("No updates available.\nYou are already using the latest version.")); } sender()->deleteLater(); diff --git a/src/gui/properties/propertieswidget.cpp b/src/gui/properties/propertieswidget.cpp index 3c692ab44..cdb68da86 100644 --- a/src/gui/properties/propertieswidget.cpp +++ b/src/gui/properties/propertieswidget.cpp @@ -800,7 +800,7 @@ void PropertiesWidget::editWebSeed() if (!m_ui->listWebSeeds->findItems(newSeed, Qt::MatchFixedString).empty()) { - QMessageBox::warning(this, tr("qBittorrent"), + QMessageBox::warning(this, QLatin1String("qBittorrent"), tr("This URL seed is already in the list."), QMessageBox::Ok); return; From 44e4dd3700122985ac71db97d2256472bfe61b46 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Wed, 20 Jan 2021 12:12:07 +0800 Subject: [PATCH 2/3] Don't let "program update" dialog steal focus And also avoid creating an unnecessary event loop. Closes #14250. --- src/gui/mainwindow.cpp | 64 ++++++++++++++++++++++++++++-------------- src/gui/mainwindow.h | 2 +- 2 files changed, 44 insertions(+), 22 deletions(-) diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 291f7260b..5983ab8a6 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -1897,35 +1897,57 @@ void MainWindow::on_actionDownloadFromURL_triggered() } #if defined(Q_OS_WIN) || defined(Q_OS_MACOS) -void MainWindow::handleUpdateCheckFinished(bool updateAvailable, QString newVersion, bool invokedByUser) +void MainWindow::handleUpdateCheckFinished(const bool updateAvailable, const QString &newVersion, const bool invokedByUser) { - QMessageBox::StandardButton answer = QMessageBox::Yes; + m_ui->actionCheckForUpdates->setEnabled(true); + m_ui->actionCheckForUpdates->setText(tr("&Check for Updates")); + m_ui->actionCheckForUpdates->setToolTip(tr("Check for program updates")); + + QObject *signalSender = sender(); + if (updateAvailable) { - answer = QMessageBox::question(this, tr("qBittorrent Update Available") - , tr("A new version is available.") + "
" - + tr("Do you want to download %1?").arg(newVersion) + "

" - + QString::fromLatin1("%1").arg(tr("Open changelog...")) - , QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); - if (answer == QMessageBox::Yes) + const QString msg {tr("A new version is available.") + "
" + + tr("Do you want to download %1?").arg(newVersion) + "

" + + QString::fromLatin1("%1").arg(tr("Open changelog..."))}; + auto *msgBox = new QMessageBox {QMessageBox::Question, tr("qBittorrent Update Available"), msg + , (QMessageBox::Yes | QMessageBox::No), this}; + msgBox->setAttribute(Qt::WA_DeleteOnClose); + msgBox->setAttribute(Qt::WA_ShowWithoutActivating); + msgBox->setDefaultButton(QMessageBox::Yes); + connect(msgBox, &QMessageBox::buttonClicked, this, [this, msgBox, signalSender](QAbstractButton *button) { - // The user want to update, let's download the update - ProgramUpdater *updater = dynamic_cast(sender()); - updater->updateProgram(); - } + if (msgBox->buttonRole(button) == QMessageBox::YesRole) + { + // The user want to update, let's download the update + auto *updater = dynamic_cast(signalSender); + updater->updateProgram(); + } + else + { + if (Preferences::instance()->isUpdateCheckEnabled()) + m_programUpdateTimer->start(); + } + + signalSender->deleteLater(); + }); + msgBox->open(); } else if (invokedByUser) { - QMessageBox::information(this, QLatin1String("qBittorrent"), - tr("No updates available.\nYou are already using the latest version.")); + auto *msgBox = new QMessageBox {QMessageBox::Information, QLatin1String("qBittorrent") + , tr("No updates available.\nYou are already using the latest version.") + , QMessageBox::Ok, this}; + msgBox->setAttribute(Qt::WA_DeleteOnClose); + connect(msgBox, &QDialog::finished, this, [this, signalSender](const int) + { + if (Preferences::instance()->isUpdateCheckEnabled()) + m_programUpdateTimer->start(); + + signalSender->deleteLater(); + }); + msgBox->open(); } - sender()->deleteLater(); - m_ui->actionCheckForUpdates->setEnabled(true); - m_ui->actionCheckForUpdates->setText(tr("&Check for Updates")); - m_ui->actionCheckForUpdates->setToolTip(tr("Check for program updates")); - // Don't bother the user again in this session if he chose to ignore the update - if (Preferences::instance()->isUpdateCheckEnabled() && (answer == QMessageBox::Yes)) - m_programUpdateTimer->start(); } #endif diff --git a/src/gui/mainwindow.h b/src/gui/mainwindow.h index cea1140fb..6f0ee5998 100644 --- a/src/gui/mainwindow.h +++ b/src/gui/mainwindow.h @@ -135,7 +135,7 @@ private slots: void askRecursiveTorrentDownloadConfirmation(BitTorrent::Torrent *const torrent); void optionsSaved(); #if defined(Q_OS_WIN) || defined(Q_OS_MACOS) - void handleUpdateCheckFinished(bool updateAvailable, QString newVersion, bool invokedByUser); + void handleUpdateCheckFinished(bool updateAvailable, const QString &newVersion, bool invokedByUser); #endif void toggleAlternativeSpeeds(); From ae1b852821122e1c0bce6b53cb450ac7b14702b6 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Wed, 20 Jan 2021 13:04:57 +0800 Subject: [PATCH 3/3] Enlarge "speed limit" icon slightly --- src/gui/optionsdialog.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/optionsdialog.cpp b/src/gui/optionsdialog.cpp index e867b614f..20119e850 100644 --- a/src/gui/optionsdialog.cpp +++ b/src/gui/optionsdialog.cpp @@ -211,8 +211,8 @@ OptionsDialog::OptionsDialog(QWidget *parent) m_ui->IpFilterRefreshBtn->setIcon(UIThemeManager::instance()->getIcon("view-refresh")); - m_ui->labelGlobalRate->setPixmap(Utils::Gui::scaledPixmap(UIThemeManager::instance()->getIcon(QLatin1String("slow_off")), this, 16)); - m_ui->labelAltRate->setPixmap(Utils::Gui::scaledPixmap(UIThemeManager::instance()->getIcon(QLatin1String("slow")), this, 16)); + m_ui->labelGlobalRate->setPixmap(Utils::Gui::scaledPixmap(UIThemeManager::instance()->getIcon(QLatin1String("slow_off")), this, 24)); + m_ui->labelAltRate->setPixmap(Utils::Gui::scaledPixmap(UIThemeManager::instance()->getIcon(QLatin1String("slow")), this, 24)); m_ui->deleteTorrentWarningIcon->setPixmap(QApplication::style()->standardIcon(QStyle::SP_MessageBoxCritical).pixmap(16, 16)); m_ui->deleteTorrentWarningIcon->hide();