Add an option to set BitTorrent session shutdown timeout

PR #20797.
This commit is contained in:
Vladimir Golovnev 2024-05-07 13:15:39 +03:00 committed by GitHub
parent 79eb7b8e38
commit 2b728b3bc0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 52 additions and 3 deletions

View file

@ -106,6 +106,7 @@ namespace
#endif // Q_OS_MACOS || Q_OS_WIN
PYTHON_EXECUTABLE_PATH,
START_SESSION_PAUSED,
SESSION_SHUTDOWN_TIMEOUT,
// libtorrent section
LIBTORRENT_HEADER,
@ -334,6 +335,8 @@ void AdvancedSettings::saveAdvancedSettings() const
pref->setPythonExecutablePath(Path(m_pythonExecutablePath.text().trimmed()));
// Start session paused
session->setStartPaused(m_checkBoxStartSessionPaused.isChecked());
// Session shutdown timeout
session->setShutdownTimeout(m_spinBoxSessionShutdownTimeout.value());
// Choking algorithm
session->setChokingAlgorithm(m_comboBoxChokingAlgorithm.currentData().value<BitTorrent::ChokingAlgorithm>());
// Seed choking algorithm
@ -848,7 +851,16 @@ void AdvancedSettings::loadAdvancedSettings()
addRow(PYTHON_EXECUTABLE_PATH, tr("Python executable path (may require restart)"), &m_pythonExecutablePath);
// Start session paused
m_checkBoxStartSessionPaused.setChecked(session->isStartPaused());
addRow(START_SESSION_PAUSED, tr("Start session in paused state"), &m_checkBoxStartSessionPaused);
addRow(START_SESSION_PAUSED, tr("Start BitTorrent session in paused state"), &m_checkBoxStartSessionPaused);
// Session shutdown timeout
m_spinBoxSessionShutdownTimeout.setMinimum(-1);
m_spinBoxSessionShutdownTimeout.setMaximum(std::numeric_limits<int>::max());
m_spinBoxSessionShutdownTimeout.setValue(session->shutdownTimeout());
m_spinBoxSessionShutdownTimeout.setSuffix(tr(" sec", " seconds"));
m_spinBoxSessionShutdownTimeout.setSpecialValueText(tr("-1 (unlimited)"));
m_spinBoxSessionShutdownTimeout.setToolTip(u"Sets the timeout for the session to be shut down gracefully, at which point it will be forcibly terminated.<br>Note that this does not apply to the saving resume data time."_s);
addRow(SESSION_SHUTDOWN_TIMEOUT, tr("BitTorrent session shutdown timeout [-1: unlimited]"), &m_spinBoxSessionShutdownTimeout);
// Choking algorithm
m_comboBoxChokingAlgorithm.addItem(tr("Fixed slots"), QVariant::fromValue(BitTorrent::ChokingAlgorithm::FixedSlots));
m_comboBoxChokingAlgorithm.addItem(tr("Upload rate based"), QVariant::fromValue(BitTorrent::ChokingAlgorithm::RateBased));
@ -946,6 +958,7 @@ void AdvancedSettings::addRow(const int row, const QString &text, T *widget)
{
auto *label = new QLabel(text);
label->setOpenExternalLinks(true);
label->setToolTip(widget->toolTip());
setCellWidget(row, PROPERTY, label);
setCellWidget(row, VALUE, widget);