mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-01-07 16:12:30 -06:00
Add option to stop seeding when torrent has been inactive
PR #19294. Closes #533. Closes #8073. Closes #15939.
This commit is contained in:
@@ -1048,7 +1048,20 @@ void OptionsDialog::loadBittorrentTabOptions()
|
||||
m_ui->checkMaxSeedingMinutes->setChecked(false);
|
||||
m_ui->spinMaxSeedingMinutes->setEnabled(false);
|
||||
}
|
||||
m_ui->comboRatioLimitAct->setEnabled((session->globalMaxSeedingMinutes() >= 0) || (session->globalMaxRatio() >= 0.));
|
||||
if (session->globalMaxInactiveSeedingMinutes() >= 0)
|
||||
{
|
||||
// Enable
|
||||
m_ui->checkMaxInactiveSeedingMinutes->setChecked(true);
|
||||
m_ui->spinMaxInactiveSeedingMinutes->setEnabled(true);
|
||||
m_ui->spinMaxInactiveSeedingMinutes->setValue(session->globalMaxInactiveSeedingMinutes());
|
||||
}
|
||||
else
|
||||
{
|
||||
// Disable
|
||||
m_ui->checkMaxInactiveSeedingMinutes->setChecked(false);
|
||||
m_ui->spinMaxInactiveSeedingMinutes->setEnabled(false);
|
||||
}
|
||||
m_ui->comboRatioLimitAct->setEnabled((session->globalMaxSeedingMinutes() >= 0) || (session->globalMaxRatio() >= 0.) || (session->globalMaxInactiveSeedingMinutes() >= 0));
|
||||
|
||||
const QHash<MaxRatioAction, int> actIndex =
|
||||
{
|
||||
@@ -1088,6 +1101,10 @@ void OptionsDialog::loadBittorrentTabOptions()
|
||||
connect(m_ui->checkMaxSeedingMinutes, &QAbstractButton::toggled, this, &ThisType::toggleComboRatioLimitAct);
|
||||
connect(m_ui->checkMaxSeedingMinutes, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||||
connect(m_ui->spinMaxSeedingMinutes, qSpinBoxValueChanged, this, &ThisType::enableApplyButton);
|
||||
connect(m_ui->checkMaxInactiveSeedingMinutes, &QAbstractButton::toggled, m_ui->spinMaxInactiveSeedingMinutes, &QWidget::setEnabled);
|
||||
connect(m_ui->checkMaxInactiveSeedingMinutes, &QAbstractButton::toggled, this, &ThisType::toggleComboRatioLimitAct);
|
||||
connect(m_ui->checkMaxInactiveSeedingMinutes, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||||
connect(m_ui->spinMaxInactiveSeedingMinutes, qSpinBoxValueChanged, this, &ThisType::enableApplyButton);
|
||||
|
||||
connect(m_ui->checkEnableAddTrackers, &QGroupBox::toggled, this, &ThisType::enableApplyButton);
|
||||
connect(m_ui->textTrackers, &QPlainTextEdit::textChanged, this, &ThisType::enableApplyButton);
|
||||
@@ -1116,6 +1133,7 @@ void OptionsDialog::saveBittorrentTabOptions() const
|
||||
|
||||
session->setGlobalMaxRatio(getMaxRatio());
|
||||
session->setGlobalMaxSeedingMinutes(getMaxSeedingMinutes());
|
||||
session->setGlobalMaxInactiveSeedingMinutes(getMaxInactiveSeedingMinutes());
|
||||
const QVector<MaxRatioAction> actIndex =
|
||||
{
|
||||
Pause,
|
||||
@@ -1443,6 +1461,14 @@ int OptionsDialog::getMaxSeedingMinutes() const
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Return Inactive Seeding Minutes
|
||||
int OptionsDialog::getMaxInactiveSeedingMinutes() const
|
||||
{
|
||||
return m_ui->checkMaxInactiveSeedingMinutes->isChecked()
|
||||
? m_ui->spinMaxInactiveSeedingMinutes->value()
|
||||
: -1;
|
||||
}
|
||||
|
||||
// Return max connections number
|
||||
int OptionsDialog::getMaxConnections() const
|
||||
{
|
||||
@@ -1547,7 +1573,7 @@ void OptionsDialog::enableApplyButton()
|
||||
void OptionsDialog::toggleComboRatioLimitAct()
|
||||
{
|
||||
// Verify if the share action button must be enabled
|
||||
m_ui->comboRatioLimitAct->setEnabled(m_ui->checkMaxRatio->isChecked() || m_ui->checkMaxSeedingMinutes->isChecked());
|
||||
m_ui->comboRatioLimitAct->setEnabled(m_ui->checkMaxRatio->isChecked() || m_ui->checkMaxSeedingMinutes->isChecked() || m_ui->checkMaxInactiveSeedingMinutes->isChecked());
|
||||
}
|
||||
|
||||
void OptionsDialog::adjustProxyOptions()
|
||||
|
||||
@@ -166,6 +166,7 @@ private:
|
||||
int getEncryptionSetting() const;
|
||||
qreal getMaxRatio() const;
|
||||
int getMaxSeedingMinutes() const;
|
||||
int getMaxInactiveSeedingMinutes() const;
|
||||
// Proxy options
|
||||
bool isProxyEnabled() const;
|
||||
QString getProxyIp() const;
|
||||
|
||||
@@ -2899,8 +2899,51 @@ Disable encryption: Only connect to peers without protocol encryption</string>
|
||||
<property name="title">
|
||||
<string>Seeding Limits</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_91">
|
||||
<item row="2" column="1">
|
||||
<layout class="QGridLayout" name="gridLayout_15">
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="checkMaxRatio">
|
||||
<property name="text">
|
||||
<string>When ratio reaches</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QDoubleSpinBox" name="spinMaxRatio">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>9998.000000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.050000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="checkMaxSeedingMinutes">
|
||||
<property name="text">
|
||||
<string>When total seeding time reaches</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QSpinBox" name="spinMaxSeedingMinutes">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
@@ -2917,9 +2960,25 @@ Disable encryption: Only connect to peers without protocol encryption</string>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QCheckBox" name="checkMaxSeedingMinutes">
|
||||
<widget class="QCheckBox" name="checkMaxInactiveSeedingMinutes">
|
||||
<property name="text">
|
||||
<string>When seeding time reaches</string>
|
||||
<string>When inactive seeding time reaches</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QSpinBox" name="spinMaxInactiveSeedingMinutes">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string extracomment="minutes"> min</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>9999999</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>1440</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -2960,42 +3019,6 @@ Disable encryption: Only connect to peers without protocol encryption</string>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="checkMaxRatio">
|
||||
<property name="text">
|
||||
<string>When ratio reaches</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QDoubleSpinBox" name="spinMaxRatio">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>9998.000000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.050000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@@ -266,6 +266,7 @@ void TorrentCreatorDialog::handleCreationSuccess(const Path &path, const Path &b
|
||||
{
|
||||
params.ratioLimit = BitTorrent::Torrent::NO_RATIO_LIMIT;
|
||||
params.seedingTimeLimit = BitTorrent::Torrent::NO_SEEDING_TIME_LIMIT;
|
||||
params.inactiveSeedingTimeLimit = BitTorrent::Torrent::NO_INACTIVE_SEEDING_TIME_LIMIT;
|
||||
}
|
||||
params.useAutoTMM = false; // otherwise if it is on by default, it will overwrite `savePath` to the default save path
|
||||
|
||||
|
||||
@@ -82,6 +82,7 @@ TorrentOptionsDialog::TorrentOptionsDialog(QWidget *parent, const QVector<BitTor
|
||||
bool allSameDownLimit = true;
|
||||
bool allSameRatio = true;
|
||||
bool allSameSeedingTime = true;
|
||||
bool allSameInactiveSeedingTime = true;
|
||||
bool allTorrentsArePrivate = true;
|
||||
bool allSameDHT = true;
|
||||
bool allSamePEX = true;
|
||||
@@ -102,6 +103,7 @@ TorrentOptionsDialog::TorrentOptionsDialog(QWidget *parent, const QVector<BitTor
|
||||
|
||||
const qreal firstTorrentRatio = torrents[0]->ratioLimit();
|
||||
const int firstTorrentSeedingTime = torrents[0]->seedingTimeLimit();
|
||||
const int firstTorrentInactiveSeedingTime = torrents[0]->inactiveSeedingTimeLimit();
|
||||
|
||||
const bool isFirstTorrentDHTDisabled = torrents[0]->isDHTDisabled();
|
||||
const bool isFirstTorrentPEXDisabled = torrents[0]->isPEXDisabled();
|
||||
@@ -154,6 +156,11 @@ TorrentOptionsDialog::TorrentOptionsDialog(QWidget *parent, const QVector<BitTor
|
||||
if (torrent->seedingTimeLimit() != firstTorrentSeedingTime)
|
||||
allSameSeedingTime = false;
|
||||
}
|
||||
if (allSameInactiveSeedingTime)
|
||||
{
|
||||
if (torrent->inactiveSeedingTimeLimit() != firstTorrentInactiveSeedingTime)
|
||||
allSameInactiveSeedingTime = false;
|
||||
}
|
||||
if (allTorrentsArePrivate)
|
||||
{
|
||||
if (!torrent->isPrivate())
|
||||
@@ -280,7 +287,7 @@ TorrentOptionsDialog::TorrentOptionsDialog(QWidget *parent, const QVector<BitTor
|
||||
&& (firstTorrentRatio == BitTorrent::Torrent::USE_GLOBAL_RATIO)
|
||||
&& (firstTorrentSeedingTime == BitTorrent::Torrent::USE_GLOBAL_SEEDING_TIME);
|
||||
|
||||
if (!allSameRatio || !allSameSeedingTime)
|
||||
if (!allSameRatio || !allSameSeedingTime || !allSameInactiveSeedingTime)
|
||||
{
|
||||
m_ui->radioUseGlobalShareLimits->setChecked(false);
|
||||
m_ui->radioNoLimit->setChecked(false);
|
||||
@@ -291,7 +298,8 @@ TorrentOptionsDialog::TorrentOptionsDialog(QWidget *parent, const QVector<BitTor
|
||||
m_ui->radioUseGlobalShareLimits->setChecked(true);
|
||||
}
|
||||
else if ((firstTorrentRatio == BitTorrent::Torrent::NO_RATIO_LIMIT)
|
||||
&& (firstTorrentSeedingTime == BitTorrent::Torrent::NO_SEEDING_TIME_LIMIT))
|
||||
&& (firstTorrentSeedingTime == BitTorrent::Torrent::NO_SEEDING_TIME_LIMIT)
|
||||
&& (firstTorrentInactiveSeedingTime == BitTorrent::Torrent::NO_INACTIVE_SEEDING_TIME_LIMIT))
|
||||
{
|
||||
m_ui->radioNoLimit->setChecked(true);
|
||||
}
|
||||
@@ -302,14 +310,19 @@ TorrentOptionsDialog::TorrentOptionsDialog(QWidget *parent, const QVector<BitTor
|
||||
m_ui->checkMaxRatio->setChecked(true);
|
||||
if (firstTorrentSeedingTime >= 0)
|
||||
m_ui->checkMaxTime->setChecked(true);
|
||||
if (firstTorrentInactiveSeedingTime >= 0)
|
||||
m_ui->checkMaxInactiveTime->setChecked(true);
|
||||
}
|
||||
|
||||
const qreal maxRatio = (allSameRatio && (firstTorrentRatio >= 0))
|
||||
? firstTorrentRatio : session->globalMaxRatio();
|
||||
const int maxSeedingTime = (allSameSeedingTime && (firstTorrentSeedingTime >= 0))
|
||||
? firstTorrentSeedingTime : session->globalMaxSeedingMinutes();
|
||||
const int maxInactiveSeedingTime = (allSameInactiveSeedingTime && (firstTorrentInactiveSeedingTime >= 0))
|
||||
? firstTorrentInactiveSeedingTime : session->globalMaxInactiveSeedingMinutes();
|
||||
m_ui->spinRatioLimit->setValue(maxRatio);
|
||||
m_ui->spinTimeLimit->setValue(maxSeedingTime);
|
||||
m_ui->spinInactiveTimeLimit->setValue(maxInactiveSeedingTime);
|
||||
|
||||
if (!allTorrentsArePrivate)
|
||||
{
|
||||
@@ -360,6 +373,7 @@ TorrentOptionsDialog::TorrentOptionsDialog(QWidget *parent, const QVector<BitTor
|
||||
m_ui->comboCategory->currentText(),
|
||||
getRatio(),
|
||||
getSeedingTime(),
|
||||
getInactiveSeedingTime(),
|
||||
m_ui->spinUploadLimit->value(),
|
||||
m_ui->spinDownloadLimit->value(),
|
||||
m_ui->checkAutoTMM->checkState(),
|
||||
@@ -390,6 +404,7 @@ TorrentOptionsDialog::TorrentOptionsDialog(QWidget *parent, const QVector<BitTor
|
||||
|
||||
connect(m_ui->checkMaxRatio, &QCheckBox::toggled, m_ui->spinRatioLimit, &QWidget::setEnabled);
|
||||
connect(m_ui->checkMaxTime, &QCheckBox::toggled, m_ui->spinTimeLimit, &QWidget::setEnabled);
|
||||
connect(m_ui->checkMaxInactiveTime, &QCheckBox::toggled, m_ui->spinInactiveTimeLimit, &QSpinBox::setEnabled);
|
||||
|
||||
connect(m_ui->buttonGroup, &QButtonGroup::idClicked, this, &TorrentOptionsDialog::handleRatioTypeChanged);
|
||||
|
||||
@@ -405,7 +420,8 @@ TorrentOptionsDialog::~TorrentOptionsDialog()
|
||||
|
||||
void TorrentOptionsDialog::accept()
|
||||
{
|
||||
if (m_ui->radioTorrentLimit->isChecked() && !m_ui->checkMaxRatio->isChecked() && !m_ui->checkMaxTime->isChecked())
|
||||
if (m_ui->radioTorrentLimit->isChecked() && !m_ui->checkMaxRatio->isChecked()
|
||||
&& !m_ui->checkMaxTime->isChecked() && !m_ui->checkMaxInactiveTime->isChecked())
|
||||
{
|
||||
QMessageBox::critical(this, tr("No share limit method selected"), tr("Please select a limit method first"));
|
||||
return;
|
||||
@@ -462,6 +478,10 @@ void TorrentOptionsDialog::accept()
|
||||
if (m_initialValues.seedingTime != seedingTimeLimit)
|
||||
torrent->setSeedingTimeLimit(seedingTimeLimit);
|
||||
|
||||
const int inactiveSeedingTimeLimit = getInactiveSeedingTime();
|
||||
if (m_initialValues.inactiveSeedingTime != inactiveSeedingTimeLimit)
|
||||
torrent->setInactiveSeedingTimeLimit(inactiveSeedingTimeLimit);
|
||||
|
||||
if (!torrent->isPrivate())
|
||||
{
|
||||
if (m_initialValues.disableDHT != m_ui->checkDisableDHT->checkState())
|
||||
@@ -509,6 +529,20 @@ int TorrentOptionsDialog::getSeedingTime() const
|
||||
return m_ui->spinTimeLimit->value();
|
||||
}
|
||||
|
||||
int TorrentOptionsDialog::getInactiveSeedingTime() const
|
||||
{
|
||||
if (m_ui->buttonGroup->checkedId() == -1) // No radio button is selected
|
||||
return MIXED_SHARE_LIMITS;
|
||||
|
||||
if (m_ui->radioUseGlobalShareLimits->isChecked())
|
||||
return BitTorrent::Torrent::USE_GLOBAL_INACTIVE_SEEDING_TIME;
|
||||
|
||||
if (m_ui->radioNoLimit->isChecked() || !m_ui->checkMaxInactiveTime->isChecked())
|
||||
return BitTorrent::Torrent::NO_INACTIVE_SEEDING_TIME_LIMIT;
|
||||
|
||||
return m_ui->spinInactiveTimeLimit->value();
|
||||
}
|
||||
|
||||
void TorrentOptionsDialog::handleCategoryChanged(const int index)
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
@@ -588,7 +622,8 @@ void TorrentOptionsDialog::handleUseDownloadPathChanged()
|
||||
|
||||
void TorrentOptionsDialog::handleRatioTypeChanged()
|
||||
{
|
||||
if ((m_initialValues.ratio == MIXED_SHARE_LIMITS) || (m_initialValues.seedingTime == MIXED_SHARE_LIMITS))
|
||||
if ((m_initialValues.ratio == MIXED_SHARE_LIMITS) || (m_initialValues.seedingTime == MIXED_SHARE_LIMITS)
|
||||
|| (m_initialValues.inactiveSeedingTime == MIXED_SHARE_LIMITS))
|
||||
{
|
||||
QAbstractButton *currentRadio = m_ui->buttonGroup->checkedButton();
|
||||
if (currentRadio && (currentRadio == m_previousRadio))
|
||||
@@ -603,9 +638,11 @@ void TorrentOptionsDialog::handleRatioTypeChanged()
|
||||
|
||||
m_ui->checkMaxRatio->setEnabled(m_ui->radioTorrentLimit->isChecked());
|
||||
m_ui->checkMaxTime->setEnabled(m_ui->radioTorrentLimit->isChecked());
|
||||
m_ui->checkMaxInactiveTime->setEnabled(m_ui->radioTorrentLimit->isChecked());
|
||||
|
||||
m_ui->spinRatioLimit->setEnabled(m_ui->radioTorrentLimit->isChecked() && m_ui->checkMaxRatio->isChecked());
|
||||
m_ui->spinTimeLimit->setEnabled(m_ui->radioTorrentLimit->isChecked() && m_ui->checkMaxTime->isChecked());
|
||||
m_ui->spinInactiveTimeLimit->setEnabled(m_ui->radioTorrentLimit->isChecked() && m_ui->checkMaxInactiveTime->isChecked());
|
||||
}
|
||||
|
||||
void TorrentOptionsDialog::handleUpSpeedLimitChanged()
|
||||
|
||||
@@ -73,6 +73,7 @@ private slots:
|
||||
private:
|
||||
qreal getRatio() const;
|
||||
int getSeedingTime() const;
|
||||
int getInactiveSeedingTime() const;
|
||||
|
||||
QVector<BitTorrent::TorrentID> m_torrentIDs;
|
||||
Ui::TorrentOptionsDialog *m_ui = nullptr;
|
||||
@@ -88,6 +89,7 @@ private:
|
||||
QString category;
|
||||
qreal ratio;
|
||||
int seedingTime;
|
||||
int inactiveSeedingTime;
|
||||
int upSpeedLimit;
|
||||
int downSpeedLimit;
|
||||
Qt::CheckState autoTMM;
|
||||
|
||||
@@ -188,10 +188,10 @@
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QCheckBox" name="checkMaxTime">
|
||||
<item row="0" column="1">
|
||||
<widget class="QCheckBox" name="checkMaxRatio">
|
||||
<property name="text">
|
||||
<string>minutes</string>
|
||||
<string>ratio</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -208,6 +208,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QCheckBox" name="checkMaxTime">
|
||||
<property name="text">
|
||||
<string>total minutes</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QSpinBox" name="spinTimeLimit">
|
||||
<property name="maximum">
|
||||
@@ -231,10 +238,20 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QCheckBox" name="checkMaxRatio">
|
||||
<item row="2" column="1">
|
||||
<widget class="QCheckBox" name="checkMaxInactiveTime">
|
||||
<property name="text">
|
||||
<string>ratio</string>
|
||||
<string>inactive minutes</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QSpinBox" name="spinInactiveTimeLimit">
|
||||
<property name="maximum">
|
||||
<number>525600</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>1440</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
Reference in New Issue
Block a user