mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-11 15:27:54 +00:00
Merge pull request #14256 from Chocobo1/tr
Don't let "program update" dialog steal focus
This commit is contained in:
commit
42637a642b
@ -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;
|
||||
if (updateAvailable)
|
||||
{
|
||||
answer = QMessageBox::question(this, tr("qBittorrent Update Available")
|
||||
, tr("A new version is available.") + "<br/>"
|
||||
+ tr("Do you want to download %1?").arg(newVersion) + "<br/><br/>"
|
||||
+ QString::fromLatin1("<a href=\"https://www.qbittorrent.org/news.php\">%1</a>").arg(tr("Open changelog..."))
|
||||
, QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
|
||||
if (answer == QMessageBox::Yes)
|
||||
{
|
||||
// The user want to update, let's download the update
|
||||
ProgramUpdater *updater = dynamic_cast<ProgramUpdater * >(sender());
|
||||
updater->updateProgram();
|
||||
}
|
||||
}
|
||||
else if (invokedByUser)
|
||||
{
|
||||
QMessageBox::information(this, tr("qBittorrent"),
|
||||
tr("No updates available.\nYou are already using the latest version."));
|
||||
}
|
||||
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();
|
||||
|
||||
QObject *signalSender = sender();
|
||||
|
||||
if (updateAvailable)
|
||||
{
|
||||
const QString msg {tr("A new version is available.") + "<br/>"
|
||||
+ tr("Do you want to download %1?").arg(newVersion) + "<br/><br/>"
|
||||
+ QString::fromLatin1("<a href=\"https://www.qbittorrent.org/news.php\">%1</a>").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)
|
||||
{
|
||||
if (msgBox->buttonRole(button) == QMessageBox::YesRole)
|
||||
{
|
||||
// The user want to update, let's download the update
|
||||
auto *updater = dynamic_cast<ProgramUpdater *>(signalSender);
|
||||
updater->updateProgram();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Preferences::instance()->isUpdateCheckEnabled())
|
||||
m_programUpdateTimer->start();
|
||||
}
|
||||
|
||||
signalSender->deleteLater();
|
||||
});
|
||||
msgBox->open();
|
||||
}
|
||||
else if (invokedByUser)
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user