Browse Source

Add WebUI Auto TMM options

adaptive-webui-19844
Thomas Piccirello 6 years ago
parent
commit
d05cf47169
  1. 2
      src/gui/optionsdialog.ui
  2. 12
      src/webui/api/appcontroller.cpp
  3. 2
      src/webui/api/torrentscontroller.cpp
  4. 11
      src/webui/www/private/download.html
  5. 54
      src/webui/www/private/preferences_content.html
  6. 31
      src/webui/www/private/scripts/download.js
  7. 11
      src/webui/www/private/upload.html

2
src/gui/optionsdialog.ui

@ -941,7 +941,7 @@ @@ -941,7 +941,7 @@
<item row="3" column="0">
<widget class="QLabel" name="labelCategoryChanged">
<property name="text">
<string>When Category changed:</string>
<string>When Category Save Path changed:</string>
</property>
</widget>
</item>

12
src/webui/api/appcontroller.cpp

@ -87,6 +87,10 @@ void AppController::preferencesAction() @@ -87,6 +87,10 @@ void AppController::preferencesAction()
data["preallocate_all"] = session->isPreallocationEnabled();
data["incomplete_files_ext"] = session->isAppendExtensionEnabled();
// Saving Management
data["auto_tmm_enabled"] = !session->isAutoTMMDisabledByDefault();
data["torrent_changed_tmm_enabled"] = !session->isDisableAutoTMMWhenCategoryChanged();
data["save_path_changed_tmm_enabled"] = !session->isDisableAutoTMMWhenDefaultSavePathChanged();
data["category_changed_tmm_enabled"] = !session->isDisableAutoTMMWhenCategorySavePathChanged();
data["save_path"] = Utils::Fs::toNativePath(session->defaultSavePath());
data["temp_path_enabled"] = session->isTempPathEnabled();
data["temp_path"] = Utils::Fs::toNativePath(session->tempPath());
@ -242,6 +246,14 @@ void AppController::setPreferencesAction() @@ -242,6 +246,14 @@ void AppController::setPreferencesAction()
session->setAppendExtensionEnabled(it.value().toBool());
// Saving Management
if ((it = m.find(QLatin1String("auto_tmm_enabled"))) != m.constEnd())
session->setAutoTMMDisabledByDefault(!it.value().toBool());
if ((it = m.find(QLatin1String("torrent_changed_tmm_enabled"))) != m.constEnd())
session->setDisableAutoTMMWhenCategoryChanged(!it.value().toBool());
if ((it = m.find(QLatin1String("save_path_changed_tmm_enabled"))) != m.constEnd())
session->setDisableAutoTMMWhenDefaultSavePathChanged(!it.value().toBool());
if ((it = m.find(QLatin1String("category_changed_tmm_enabled"))) != m.constEnd())
session->setDisableAutoTMMWhenCategorySavePathChanged(!it.value().toBool());
if (m.contains("save_path"))
session->setDefaultSavePath(m["save_path"].toString());
if (m.contains("temp_path_enabled"))

2
src/webui/api/torrentscontroller.cpp

@ -469,6 +469,7 @@ void TorrentsController::addAction() @@ -469,6 +469,7 @@ void TorrentsController::addAction()
const QString torrentName = params()["rename"].trimmed();
const int upLimit = params()["upLimit"].toInt();
const int dlLimit = params()["dlLimit"].toInt();
const TriStateBool autoTMM = parseTriStateBool(params()["autoTMM"]);
QList<QNetworkCookie> cookies;
if (!cookie.isEmpty()) {
@ -496,6 +497,7 @@ void TorrentsController::addAction() @@ -496,6 +497,7 @@ void TorrentsController::addAction()
params.name = torrentName;
params.uploadLimit = (upLimit > 0) ? upLimit : -1;
params.downloadLimit = (dlLimit > 0) ? dlLimit : -1;
params.useAutoTMM = autoTMM;
bool partialSuccess = false;
for (QString url : asConst(urls.split('\n'))) {

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

@ -20,6 +20,17 @@ @@ -20,6 +20,17 @@
<p>QBT_TR(Only one link per line)QBT_TR[CONTEXT=HttpServer]</p>
<fieldset class="settings" style="border: 0; text-align: left; margin-top: 6px;">
<table style="margin: auto;">
<tr>
<td>
<label for="autoTMM">QBT_TR(Torrent Management Mode:)QBT_TR[CONTEXT=AddNewTorrentDialog]</label>
</td>
<td>
<select id="autoTMM" name="autoTMM" onchange="changeTMM(this)">
<option selected value="false">Manual</option>
<option value="true">Automatic</option>
</select>
</td>
</tr>
<tr>
<td>
<label for="savepath">QBT_TR(Save files to location:)QBT_TR[CONTEXT=HttpServer]</label>

54
src/webui/www/private/preferences_content.html

@ -12,6 +12,52 @@ @@ -12,6 +12,52 @@
<fieldset class="settings">
<legend>QBT_TR(Saving Management)QBT_TR[CONTEXT=HttpServer]</legend>
<table>
<tr>
<td>
<label>QBT_TR(Default Torrent Management Mode:)QBT_TR[CONTEXT=OptionsDialog]</label>
</td>
<td>
<select id="default_tmm_combobox">
<option value="false" selected>QBT_TR(Manual)QBT_TR[CONTEXT=OptionsDialog]</option>
<option value="true">QBT_TR(Automatic)QBT_TR[CONTEXT=OptionsDialog]</option>
</select>
</td>
</tr>
<tr>
<td>
<label>QBT_TR(When Torrent Category changed:)QBT_TR[CONTEXT=OptionsDialog]</label>
</td>
<td>
<select id="torrent_changed_tmm_combobox">
<option value="true">QBT_TR(Relocate torrent)QBT_TR[CONTEXT=OptionsDialog]</option>
<option value="false" selected>QBT_TR(Switch torrent to Manual Mode)QBT_TR[CONTEXT=OptionsDialog]</option>
</select>
</td>
</tr>
<tr>
<td>
<label>QBT_TR(When Default Save Path changed:)QBT_TR[CONTEXT=OptionsDialog]</label>
</td>
<td>
<select id="save_path_changed_tmm_combobox">
<option value="true">QBT_TR(Relocate affected torrents)QBT_TR[CONTEXT=OptionsDialog]</option>
<option value="false" selected>QBT_TR(Switch affected torrents to Manual Mode)QBT_TR[CONTEXT=OptionsDialog]</option>
</select>
</td>
</tr>
<tr>
<td>
<label>QBT_TR(When Category Save Path changed:)QBT_TR[CONTEXT=OptionsDialog]</label>
</td>
<td>
<select id="category_changed_tmm_combobox">
<option value="true">QBT_TR(Relocate affected torrents)QBT_TR[CONTEXT=OptionsDialog]</option>
<option value="false" selected>QBT_TR(Switch affected torrents to Manual Mode)QBT_TR[CONTEXT=OptionsDialog]</option>
</select>
</td>
</tr>
</table>
<table>
<tr>
<td>
@ -984,6 +1030,10 @@ @@ -984,6 +1030,10 @@
$('appendext_checkbox').setProperty('checked', pref.incomplete_files_ext);
// Saving Managmenet
$('default_tmm_combobox').setProperty('value', pref.auto_tmm_enabled);
$('torrent_changed_tmm_combobox').setProperty('value', pref.torrent_changed_tmm_enabled);
$('save_path_changed_tmm_combobox').setProperty('value', pref.save_path_changed_tmm_enabled);
$('category_changed_tmm_combobox').setProperty('value', pref.category_changed_tmm_enabled);
$('savepath_text').setProperty('value', pref.save_path);
$('temppath_checkbox').setProperty('checked', pref.temp_path_enabled);
$('temppath_text').setProperty('value', pref.temp_path);
@ -1228,6 +1278,10 @@ @@ -1228,6 +1278,10 @@
settings.set('incomplete_files_ext', $('appendext_checkbox').getProperty('checked'));
// Saving Management
settings.set('auto_tmm_enabled', $('default_tmm_combobox').getProperty('value'));
settings.set('torrent_changed_tmm_enabled', $('torrent_changed_tmm_combobox').getProperty('value'));
settings.set('save_path_changed_tmm_enabled', $('save_path_changed_tmm_combobox').getProperty('value'));
settings.set('category_changed_tmm_enabled', $('category_changed_tmm_combobox').getProperty('value'));
settings.set('save_path', $('savepath_text').getProperty('value'));
settings.set('temp_path_enabled', $('temppath_checkbox').getProperty('checked'));
settings.set('temp_path', $('temppath_text').getProperty('value'));

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

@ -21,22 +21,39 @@ @@ -21,22 +21,39 @@
* THE SOFTWARE.
*/
getSavePath = function() {
new Request({
url: 'api/v2/app/defaultSavePath',
getPreferences = function() {
new Request.JSON({
url: 'api/v2/app/preferences',
method: 'get',
noCache: true,
onFailure: function() {
alert("Could not contact qBittorrent");
},
onSuccess: function(data) {
if (data) {
$('savepath').setProperty('value', data);
onSuccess: function(pref) {
if (pref) {
$('savepath').setProperty('value', pref.save_path);
if (pref.auto_tmm_enabled == 1) {
$('autoTMM').selectedIndex = 1;
$('savepath').disabled = true;
}
else {
$('autoTMM').selectedIndex = 0;
}
}
}
}).send();
};
changeTMM = function(item) {
if (item.selectedIndex == 1) {
$('savepath').disabled = true;
}
else {
$('savepath').disabled = false;
}
};
$(window).addEventListener("load", function() {
getSavePath();
getPreferences();
});

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

@ -18,6 +18,17 @@ @@ -18,6 +18,17 @@
</div>
<fieldset class="settings" style="border: 0; text-align: left; margin-top: 12px;">
<table style="margin: auto;">
<tr>
<td>
<label for="autoTMM">QBT_TR(Torrent Management Mode:)QBT_TR[CONTEXT=AddNewTorrentDialog]</label>
</td>
<td>
<select id="autoTMM" name="autoTMM" onchange="changeTMM(this)">
<option selected value="false">Manual</option>
<option value="true">Automatic</option>
</select>
</td>
</tr>
<tr>
<td>
<label for="savepath">QBT_TR(Save files to location:)QBT_TR[CONTEXT=HttpServer]</label>

Loading…
Cancel
Save