Add ability to pause/resume entire BitTorrent session

PR #20757.
Closes #18993.
This commit is contained in:
Vladimir Golovnev
2024-05-03 09:02:50 +03:00
committed by GitHub
parent 05416458db
commit 8ef7d3ec9a
16 changed files with 189 additions and 114 deletions

View File

@@ -377,36 +377,14 @@ void TransferListWidget::setSelectedTorrentsLocation()
fileDialog->open();
}
void TransferListWidget::stopAllTorrents()
void TransferListWidget::pauseSession()
{
if (Preferences::instance()->confirmPauseAndResumeAll())
{
// Show confirmation if user would really like to Stop All
const QMessageBox::StandardButton ret = QMessageBox::question(this, tr("Confirm stop all torrents")
, tr("Would you like to stop all torrents?"), (QMessageBox::Yes | QMessageBox::No));
if (ret != QMessageBox::Yes)
return;
}
for (BitTorrent::Torrent *const torrent : asConst(BitTorrent::Session::instance()->torrents()))
torrent->stop();
BitTorrent::Session::instance()->pause();
}
void TransferListWidget::startAllTorrents()
void TransferListWidget::resumeSession()
{
if (Preferences::instance()->confirmPauseAndResumeAll())
{
// Show confirmation if user would really like to Start All
const QMessageBox::StandardButton ret = QMessageBox::question(this, tr("Confirm start all torrents")
, tr("Would you like to start all torrents?"), (QMessageBox::Yes | QMessageBox::No));
if (ret != QMessageBox::Yes)
return;
}
for (BitTorrent::Torrent *const torrent : asConst(BitTorrent::Session::instance()->torrents()))
torrent->start();
BitTorrent::Session::instance()->resume();
}
void TransferListWidget::startSelectedTorrents()
@@ -1142,8 +1120,7 @@ void TransferListWidget::displayListMenu()
needsStop = true;
}
const bool queued = (BitTorrent::Session::instance()->isQueueingSystemEnabled() && torrent->isQueued());
const bool queued = torrent->isQueued();
if (!isStopped && !rechecking && !queued)
oneCanForceReannounce = true;