Browse Source

Allow to set torrent stop condition in WebUI

PR #17876.
adaptive-webui-19844
thalieht 2 years ago committed by GitHub
parent
commit
698284f00e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      src/webui/api/appcontroller.cpp
  2. 12
      src/webui/www/private/download.html
  3. 10
      src/webui/www/private/scripts/download.js
  4. 12
      src/webui/www/private/upload.html
  5. 21
      src/webui/www/private/views/preferences.html

3
src/webui/api/appcontroller.cpp

@ -111,6 +111,7 @@ void AppController::preferencesAction() @@ -111,6 +111,7 @@ void AppController::preferencesAction()
// When adding a torrent
data[u"torrent_content_layout"_qs] = Utils::String::fromEnum(session->torrentContentLayout());
data[u"start_paused_enabled"_qs] = session->isAddTorrentPaused();
data[u"torrent_stop_condition"_qs] = Utils::String::fromEnum(session->torrentStopCondition());
data[u"auto_delete_mode"_qs] = static_cast<int>(TorrentFileGuard::autoDeleteMode());
data[u"preallocate_all"_qs] = session->isPreallocationEnabled();
data[u"incomplete_files_ext"_qs] = session->isAppendExtensionEnabled();
@ -411,6 +412,8 @@ void AppController::setPreferencesAction() @@ -411,6 +412,8 @@ void AppController::setPreferencesAction()
session->setTorrentContentLayout(Utils::String::toEnum(it.value().toString(), BitTorrent::TorrentContentLayout::Original));
if (hasKey(u"start_paused_enabled"_qs))
session->setAddTorrentPaused(it.value().toBool());
if (hasKey(u"torrent_stop_condition"_qs))
session->setTorrentStopCondition(Utils::String::toEnum(it.value().toString(), BitTorrent::Torrent::StopCondition::None));
if (hasKey(u"auto_delete_mode"_qs))
TorrentFileGuard::setAutoDeleteMode(static_cast<TorrentFileGuard::AutoDeleteMode>(it.value().toInt()));

12
src/webui/www/private/download.html

@ -79,6 +79,18 @@ @@ -79,6 +79,18 @@
<input type="checkbox" id="startTorrent" />
</td>
</tr>
<tr>
<td>
<label for="stopCondition">QBT_TR(Stop condition:)QBT_TR[CONTEXT=AddNewTorrentDialog]</label>
</td>
<td>
<select id="stopCondition" name="stopCondition">
<option selected value="None">QBT_TR(None)QBT_TR[CONTEXT=AddNewTorrentDialog]</option>
<option value="MetadataReceived">QBT_TR(Metadata received)QBT_TR[CONTEXT=AddNewTorrentDialog]</option>
<option value="FilesChecked">QBT_TR(Files checked)QBT_TR[CONTEXT=AddNewTorrentDialog]</option>
</select>
</td>
</tr>
<tr>
<td>
<label for="skip_checking">QBT_TR(Skip hash check)QBT_TR[CONTEXT=AddNewTorrentDialog]</label>

10
src/webui/www/private/scripts/download.js

@ -82,6 +82,16 @@ window.qBittorrent.Download = (function() { @@ -82,6 +82,16 @@ window.qBittorrent.Download = (function() {
$('autoTMM').selectedIndex = 0;
}
if (pref.torrent_stop_condition === "MetadataReceived") {
$('stopCondition').selectedIndex = 1;
}
else if (pref.torrent_stop_condition === "FilesChecked") {
$('stopCondition').selectedIndex = 2;
}
else {
$('stopCondition').selectedIndex = 0;
}
if (pref.torrent_content_layout === "Subfolder") {
$('contentLayout').selectedIndex = 1;
}

12
src/webui/www/private/upload.html

@ -67,6 +67,18 @@ @@ -67,6 +67,18 @@
<input type="checkbox" id="startTorrent" />
</td>
</tr>
<tr>
<td>
<label for="stopCondition">QBT_TR(Stop condition:)QBT_TR[CONTEXT=AddNewTorrentDialog]</label>
</td>
<td>
<select id="stopCondition" name="stopCondition">
<option selected value="None">QBT_TR(None)QBT_TR[CONTEXT=AddNewTorrentDialog]</option>
<option value="MetadataReceived">QBT_TR(Metadata received)QBT_TR[CONTEXT=AddNewTorrentDialog]</option>
<option value="FilesChecked">QBT_TR(Files checked)QBT_TR[CONTEXT=AddNewTorrentDialog]</option>
</select>
</td>
</tr>
<tr>
<td>
<label for="skip_checking">QBT_TR(Skip hash check)QBT_TR[CONTEXT=AddNewTorrentDialog]</label>

21
src/webui/www/private/views/preferences.html

@ -13,6 +13,14 @@ @@ -13,6 +13,14 @@
<input type="checkbox" id="dontstartdownloads_checkbox" />
<label for="dontstartdownloads_checkbox">QBT_TR(Do not start the download automatically)QBT_TR[CONTEXT=OptionsDialog]</label>
</div>
<div class="formRow">
<label for="stopConditionSelect">QBT_TR(Torrent stop condition:)QBT_TR[CONTEXT=OptionsDialog]</label>
<select id="stopConditionSelect">
<option value="None">QBT_TR(None)QBT_TR[CONTEXT=OptionsDialog]</option>
<option value="MetadataReceived">QBT_TR(Metadata received)QBT_TR[CONTEXT=OptionsDialog]</option>
<option value="FilesChecked">QBT_TR(Files checked)QBT_TR[CONTEXT=OptionsDialog]</option>
</select>
</div>
<div class="formRow">
<input type="checkbox" id="deletetorrentfileafter_checkbox" />
<label for="deletetorrentfileafter_checkbox">QBT_TR(Delete .torrent files afterwards)QBT_TR[CONTEXT=OptionsDialog]</label>
@ -1740,6 +1748,18 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD @@ -1740,6 +1748,18 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
}
$('contentlayout_select').getChildren('option')[index].setAttribute('selected', '');
$('dontstartdownloads_checkbox').setProperty('checked', pref.start_paused_enabled);
switch (pref.torrent_stop_condition) {
case "None":
index = 0;
break;
case "MetadataReceived":
index = 1;
break;
case "FilesChecked":
index = 2;
break;
}
$('stopConditionSelect').getChildren('option')[index].setAttribute('selected', '');
$('deletetorrentfileafter_checkbox').setProperty('checked', pref.auto_delete_mode);
$('preallocateall_checkbox').setProperty('checked', pref.preallocate_all);
@ -2093,6 +2113,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD @@ -2093,6 +2113,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
// When adding a torrent
settings.set('torrent_content_layout', $('contentlayout_select').getSelected()[0].getProperty('value'));
settings.set('start_paused_enabled', $('dontstartdownloads_checkbox').getProperty('checked'));
settings.set('torrent_stop_condition', $('stopConditionSelect').getSelected()[0].getProperty('value'));
settings.set('auto_delete_mode', $('deletetorrentfileafter_checkbox').getProperty('checked'));
settings.set('preallocate_all', $('preallocateall_checkbox').getProperty('checked'));

Loading…
Cancel
Save