Add "Remove torrent and its files" option to share ratio limiting

This commit is contained in:
thalieht
2019-09-18 19:26:01 +03:00
parent 19c70fd659
commit 07eb261991
7 changed files with 97 additions and 39 deletions

View File

@@ -747,7 +747,14 @@ void OptionsDialog::saveOptions()
session->setAdditionalTrackers(m_ui->textTrackers->toPlainText());
session->setGlobalMaxRatio(getMaxRatio());
session->setGlobalMaxSeedingMinutes(getMaxSeedingMinutes());
session->setMaxRatioAction(static_cast<MaxRatioAction>(m_ui->comboRatioLimitAct->currentIndex()));
const QVector<MaxRatioAction> actIndex = {
Pause,
Remove,
DeleteFiles,
EnableSuperSeeding
};
session->setMaxRatioAction(actIndex.value(m_ui->comboRatioLimitAct->currentIndex()));
// End Bittorrent preferences
// Misc preferences
@@ -1130,7 +1137,14 @@ void OptionsDialog::loadOptions()
m_ui->spinMaxSeedingMinutes->setEnabled(false);
}
m_ui->comboRatioLimitAct->setEnabled((session->globalMaxSeedingMinutes() >= 0) || (session->globalMaxRatio() >= 0.));
m_ui->comboRatioLimitAct->setCurrentIndex(session->maxRatioAction());
const QHash<MaxRatioAction, int> actIndex = {
{Pause, 0},
{Remove, 1},
{DeleteFiles, 2},
{EnableSuperSeeding, 3}
};
m_ui->comboRatioLimitAct->setCurrentIndex(actIndex.value(session->maxRatioAction()));
// End Bittorrent preferences
// Web UI preferences

View File

@@ -2485,17 +2485,22 @@
</property>
<item>
<property name="text">
<string>Pause them</string>
<string>Pause torrent</string>
</property>
</item>
<item>
<property name="text">
<string>Remove them</string>
<string>Remove torrent</string>
</property>
</item>
<item>
<property name="text">
<string>Enable super seeding for them</string>
<string>Remove torrent and its files</string>
</property>
</item>
<item>
<property name="text">
<string>Enable super seeding for torrent</string>
</property>
</item>
</widget>

View File

@@ -371,8 +371,9 @@ void TransferListWidget::deleteSelectedTorrents(bool deleteLocalFiles)
if (Preferences::instance()->confirmTorrentDeletion()
&& !DeletionConfirmationDialog::askForDeletionConfirmation(this, deleteLocalFiles, torrents.size(), torrents[0]->name()))
return;
for (BitTorrent::TorrentHandle *const torrent : torrents)
BitTorrent::Session::instance()->deleteTorrent(torrent->hash(), deleteLocalFiles);
const DeleteOption deleteOption = deleteLocalFiles ? TorrentAndFiles : Torrent;
for (const BitTorrent::TorrentHandle *torrent : torrents)
BitTorrent::Session::instance()->deleteTorrent(torrent->hash(), deleteOption);
}
void TransferListWidget::deleteVisibleTorrents()
@@ -388,8 +389,9 @@ void TransferListWidget::deleteVisibleTorrents()
&& !DeletionConfirmationDialog::askForDeletionConfirmation(this, deleteLocalFiles, torrents.size(), torrents[0]->name()))
return;
for (BitTorrent::TorrentHandle *const torrent : asConst(torrents))
BitTorrent::Session::instance()->deleteTorrent(torrent->hash(), deleteLocalFiles);
const DeleteOption deleteOption = deleteLocalFiles ? TorrentAndFiles : Torrent;
for (const BitTorrent::TorrentHandle *torrent : asConst(torrents))
BitTorrent::Session::instance()->deleteTorrent(torrent->hash(), deleteOption);
}
void TransferListWidget::increaseQueuePosSelectedTorrents()