Allow to disable confirmation of Pause/Resume All

PR #19067.
Closes #18155.
This commit is contained in:
Vladimir Golovnev 2023-06-04 08:57:14 +03:00 committed by GitHub
parent 83e6afcb71
commit cf415dd7fe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 44 additions and 14 deletions

View file

@ -1224,6 +1224,16 @@ void Preferences::setConfirmRemoveAllTags(const bool enabled)
setValue(u"Preferences/Advanced/confirmRemoveAllTags"_qs, enabled);
}
bool Preferences::confirmPauseAndResumeAll() const
{
return value(u"GUI/ConfirmActions/PauseAndResumeAllTorrents"_qs, true);
}
void Preferences::setConfirmPauseAndResumeAll(const bool enabled)
{
setValue(u"GUI/ConfirmActions/PauseAndResumeAllTorrents"_qs, enabled);
}
#ifndef Q_OS_MACOS
TrayIcon::Style Preferences::trayIconStyle() const
{

View file

@ -315,6 +315,8 @@ public:
void setConfirmTorrentRecheck(bool enabled);
bool confirmRemoveAllTags() const;
void setConfirmRemoveAllTags(bool enabled);
bool confirmPauseAndResumeAll() const;
void setConfirmPauseAndResumeAll(bool enabled);
#ifndef Q_OS_MACOS
bool systemTrayEnabled() const;
void setSystemTrayEnabled(bool enabled);

View file

@ -253,6 +253,7 @@ void OptionsDialog::loadBehaviorTabOptions()
m_ui->checkShowSplash->setChecked(!pref->isSplashScreenDisabled());
m_ui->checkProgramExitConfirm->setChecked(pref->confirmOnExit());
m_ui->checkProgramAutoExitConfirm->setChecked(!pref->dontConfirmAutoExit());
m_ui->checkConfirmPauseAndResumeAll->setChecked(pref->confirmPauseAndResumeAll());
m_ui->windowStateComboBox->addItem(tr("Normal"), QVariant::fromValue(WindowState::Normal));
m_ui->windowStateComboBox->addItem(tr("Minimized"), QVariant::fromValue(WindowState::Minimized));
@ -354,6 +355,7 @@ void OptionsDialog::loadBehaviorTabOptions()
connect(m_ui->checkShowSplash, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
connect(m_ui->checkProgramExitConfirm, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
connect(m_ui->checkProgramAutoExitConfirm, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
connect(m_ui->checkConfirmPauseAndResumeAll, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
connect(m_ui->checkShowSystray, &QGroupBox::toggled, this, &ThisType::enableApplyButton);
connect(m_ui->checkMinimizeToSysTray, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
connect(m_ui->checkCloseToSystray, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
@ -425,6 +427,7 @@ void OptionsDialog::saveBehaviorTabOptions() const
pref->setSplashScreenDisabled(isSplashScreenDisabled());
pref->setConfirmOnExit(m_ui->checkProgramExitConfirm->isChecked());
pref->setDontConfirmAutoExit(!m_ui->checkProgramAutoExitConfirm->isChecked());
pref->setConfirmPauseAndResumeAll(m_ui->checkConfirmPauseAndResumeAll->isChecked());
#ifdef Q_OS_WIN
pref->setWinStartup(WinStartup());

View file

@ -239,6 +239,19 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkConfirmPauseAndResumeAll">
<property name="toolTip">
<string>Shows a confirmation dialog upon pausing/resuming all the torrents</string>
</property>
<property name="text">
<string>Confirm "Pause/Resume all" actions</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkAltRowColors">
<property name="text">

View file

@ -362,14 +362,15 @@ void TransferListWidget::setSelectedTorrentsLocation()
void TransferListWidget::pauseAllTorrents()
{
// Show confirmation if user would really like to Pause All
const QMessageBox::StandardButton ret =
QMessageBox::question(this, tr("Confirm pause")
, tr("Would you like to pause all torrents?")
, (QMessageBox::Yes | QMessageBox::No));
if (Preferences::instance()->confirmPauseAndResumeAll())
{
// Show confirmation if user would really like to Pause All
const QMessageBox::StandardButton ret = QMessageBox::question(this, tr("Confirm pause")
, tr("Would you like to pause all torrents?"), (QMessageBox::Yes | QMessageBox::No));
if (ret != QMessageBox::Yes)
return;
if (ret != QMessageBox::Yes)
return;
}
for (BitTorrent::Torrent *const torrent : asConst(BitTorrent::Session::instance()->torrents()))
torrent->pause();
@ -377,14 +378,15 @@ void TransferListWidget::pauseAllTorrents()
void TransferListWidget::resumeAllTorrents()
{
// Show confirmation if user would really like to Resume All
const QMessageBox::StandardButton ret =
QMessageBox::question(this, tr("Confirm resume")
, tr("Would you like to resume all torrents?")
, (QMessageBox::Yes | QMessageBox::No));
if (Preferences::instance()->confirmPauseAndResumeAll())
{
// Show confirmation if user would really like to Resume All
const QMessageBox::StandardButton ret = QMessageBox::question(this, tr("Confirm resume")
, tr("Would you like to resume all torrents?"), (QMessageBox::Yes | QMessageBox::No));
if (ret != QMessageBox::Yes)
return;
if (ret != QMessageBox::Yes)
return;
}
for (BitTorrent::Torrent *const torrent : asConst(BitTorrent::Session::instance()->torrents()))
torrent->resume();