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

@@ -885,10 +885,11 @@ void TorrentsController::deleteAction()
checkParams({"hashes", "deleteFiles"});
const QStringList hashes {params()["hashes"].split('|')};
const bool deleteFiles {parseBool(params()["deleteFiles"], false)};
applyToTorrents(hashes, [deleteFiles](BitTorrent::TorrentHandle *const torrent)
const DeleteOption deleteOption = parseBool(params()["deleteFiles"], false)
? TorrentAndFiles : Torrent;
applyToTorrents(hashes, [deleteOption](const BitTorrent::TorrentHandle *torrent)
{
BitTorrent::Session::instance()->deleteTorrent(torrent->hash(), deleteFiles);
BitTorrent::Session::instance()->deleteTorrent(torrent->hash(), deleteOption);
});
}

View File

@@ -577,9 +577,10 @@
</td>
<td>
<select id="max_ratio_act">
<option value="0">QBT_TR(Pause them)QBT_TR[CONTEXT=OptionsDialog]</option>
<option value="1">QBT_TR(Remove them)QBT_TR[CONTEXT=OptionsDialog]</option>
<option value="2">QBT_TR(Enable super seeding for them)QBT_TR[CONTEXT=OptionsDialog]</option>
<option value="0">QBT_TR(Pause torrent)QBT_TR[CONTEXT=OptionsDialog]</option>
<option value="1">QBT_TR(Remove torrent)QBT_TR[CONTEXT=OptionsDialog]</option>
<option value="3">QBT_TR(Remove torrent and its files)QBT_TR[CONTEXT=OptionsDialog]</option>
<option value="2">QBT_TR(Enable super seeding for torrent)QBT_TR[CONTEXT=OptionsDialog]</option>
</select>
</td>
</tr>
@@ -1660,8 +1661,23 @@
$('max_seeding_time_value').setProperty('value', pref.max_seeding_time.toInt());
else
$('max_seeding_time_value').setProperty('value', 1440);
const max_ratio_act = pref.max_ratio_act.toInt();
$('max_ratio_act').getChildren('option')[max_ratio_act].setAttribute('selected', '');
let maxRatioAct = 0;
switch (pref.max_ratio_act.toInt()) {
case 0: // Pause
default:
maxRatioAct = 0;
break;
case 1: // Remove
maxRatioAct = 1;
break;
case 2: // Enable super seeding
maxRatioAct = 3;
break;
case 3: // Remove torrent and files
maxRatioAct = 2;
break;
}
$('max_ratio_act').getChildren('option')[maxRatioAct].setAttribute('selected', '');
updateMaxRatioTimeEnabled();
// Add trackers