mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-01-01 13:18:06 -06:00
Allow to add root folder to torrent content
This commit is contained in:
committed by
sledgehammer999
parent
cd0b6d9a43
commit
c08ec1ac5e
@@ -56,6 +56,7 @@
|
||||
#include "base/utils/misc.h"
|
||||
#include "base/utils/net.h"
|
||||
#include "base/utils/password.h"
|
||||
#include "base/utils/string.h"
|
||||
#include "../webapplication.h"
|
||||
|
||||
void AppController::webapiVersionAction()
|
||||
@@ -100,7 +101,7 @@ void AppController::preferencesAction()
|
||||
|
||||
// Downloads
|
||||
// When adding a torrent
|
||||
data["create_subfolder_enabled"] = session->isKeepTorrentTopLevelFolder();
|
||||
data["torrent_content_layout"] = Utils::String::fromEnum(session->torrentContentLayout());
|
||||
data["start_paused_enabled"] = session->isAddTorrentPaused();
|
||||
data["auto_delete_mode"] = static_cast<int>(TorrentFileGuard::autoDeleteMode());
|
||||
data["preallocate_all"] = session->isPreallocationEnabled();
|
||||
@@ -355,8 +356,8 @@ void AppController::setPreferencesAction()
|
||||
|
||||
// Downloads
|
||||
// When adding a torrent
|
||||
if (hasKey("create_subfolder_enabled"))
|
||||
session->setKeepTorrentTopLevelFolder(it.value().toBool());
|
||||
if (hasKey("torrent_content_layout"))
|
||||
session->setTorrentContentLayout(Utils::String::toEnum(it.value().toString(), BitTorrent::TorrentContentLayout::Original));
|
||||
if (hasKey("start_paused_enabled"))
|
||||
session->setAddTorrentPaused(it.value().toBool());
|
||||
if (hasKey("auto_delete_mode"))
|
||||
|
||||
@@ -606,7 +606,6 @@ void TorrentsController::addAction()
|
||||
const bool seqDownload = parseBool(params()["sequentialDownload"], false);
|
||||
const bool firstLastPiece = parseBool(params()["firstLastPiecePrio"], false);
|
||||
const TriStateBool addPaused = parseTriStateBool(params()["paused"]);
|
||||
const TriStateBool rootFolder = parseTriStateBool(params()["root_folder"]);
|
||||
const QString savepath = params()["savepath"].trimmed();
|
||||
const QString category = params()["category"];
|
||||
const QSet<QString> tags = List::toSet(params()["tags"].split(',', QString::SkipEmptyParts));
|
||||
@@ -616,6 +615,11 @@ void TorrentsController::addAction()
|
||||
const int dlLimit = params()["dlLimit"].toInt();
|
||||
const TriStateBool autoTMM = parseTriStateBool(params()["autoTMM"]);
|
||||
|
||||
const QString contentLayoutParam = params()["contentLayout"];
|
||||
const boost::optional<BitTorrent::TorrentContentLayout> contentLayout = (!contentLayoutParam.isEmpty()
|
||||
? Utils::String::toEnum(contentLayoutParam, BitTorrent::TorrentContentLayout::Original)
|
||||
: boost::optional<BitTorrent::TorrentContentLayout> {});
|
||||
|
||||
QList<QNetworkCookie> cookies;
|
||||
if (!cookie.isEmpty())
|
||||
{
|
||||
@@ -639,7 +643,7 @@ void TorrentsController::addAction()
|
||||
params.sequential = seqDownload;
|
||||
params.firstLastPiecePriority = firstLastPiece;
|
||||
params.addPaused = addPaused;
|
||||
params.createSubfolder = rootFolder;
|
||||
params.contentLayout = contentLayout;
|
||||
params.savePath = savepath;
|
||||
params.category = category;
|
||||
params.tags = tags;
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
#include "base/utils/net.h"
|
||||
#include "base/utils/version.h"
|
||||
|
||||
constexpr Utils::Version<int, 3, 2> API_VERSION {2, 6, 2};
|
||||
constexpr Utils::Version<int, 3, 2> API_VERSION {2, 7, 0};
|
||||
|
||||
class APIController;
|
||||
class WebApplication;
|
||||
|
||||
@@ -89,11 +89,14 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="rootFolder">QBT_TR(Keep top-level folder)QBT_TR[CONTEXT=AddNewTorrentDialog]</label>
|
||||
<label for="contentLayout">QBT_TR(Content layout:)QBT_TR[CONTEXT=AddNewTorrentDialog]</label>
|
||||
</td>
|
||||
<td>
|
||||
<input type="hidden" id="rootFolderHidden" name="root_folder" />
|
||||
<input type="checkbox" id="rootFolder" />
|
||||
<select id="contentLayout" name="contentLayout">
|
||||
<option selected value="Original">QBT_TR(Original)QBT_TR[CONTEXT=AddNewTorrentDialog]</option>
|
||||
<option value="Subfolder">QBT_TR(Create subfolder)QBT_TR[CONTEXT=AddNewTorrentDialog]</option>
|
||||
<option value="NoSubfolder">QBT_TR(Don't create subfolder)QBT_TR[CONTEXT=AddNewTorrentDialog]</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
@@ -82,6 +82,16 @@ window.qBittorrent.Download = (function() {
|
||||
else {
|
||||
$('autoTMM').selectedIndex = 0;
|
||||
}
|
||||
|
||||
if (pref.torrent_content_layout === "Subfolder") {
|
||||
$('contentLayout').selectedIndex = 1;
|
||||
}
|
||||
else if (pref.torrent_content_layout === "NoSubfolder") {
|
||||
$('contentLayout').selectedIndex = 2;
|
||||
}
|
||||
else {
|
||||
$('contentLayout').selectedIndex = 0;
|
||||
}
|
||||
}
|
||||
}).send();
|
||||
};
|
||||
|
||||
@@ -77,11 +77,14 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="rootFolder">QBT_TR(Keep top-level folder)QBT_TR[CONTEXT=AddNewTorrentDialog]</label>
|
||||
<label for="contentLayout">QBT_TR(Content layout:)QBT_TR[CONTEXT=AddNewTorrentDialog]</label>
|
||||
</td>
|
||||
<td>
|
||||
<input type="hidden" id="rootFolderHidden" name="root_folder" />
|
||||
<input type="checkbox" id="rootFolder" />
|
||||
<select id="contentLayout" name="contentLayout">
|
||||
<option selected value="Original">QBT_TR(Original)QBT_TR[CONTEXT=AddNewTorrentDialog]</option>
|
||||
<option value="Subfolder">QBT_TR(Create subfolder)QBT_TR[CONTEXT=AddNewTorrentDialog]</option>
|
||||
<option value="NoSubfolder">QBT_TR(Don't create subfolder)QBT_TR[CONTEXT=AddNewTorrentDialog]</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
@@ -248,13 +248,14 @@ Supports the formats: S01E01, 1x1, 2017.12.31 and 31.12.2017 (Date formats also
|
||||
<table class="fullWidth">
|
||||
<tr>
|
||||
<td>
|
||||
<label class="noWrap">QBT_TR(Create Subfolder:)QBT_TR[CONTEXT=AutomatedRssDownloader]</label>
|
||||
<label class="noWrap">QBT_TR(Torrent content layout:)QBT_TR[CONTEXT=AutomatedRssDownloader]</label>
|
||||
</td>
|
||||
<td class="fullWidth">
|
||||
<select disabled id="creatSubfolderCombobox" class="fullWidth">
|
||||
<option value="default">QBT_TR(Use global settings)QBT_TR[CONTEXT=AutomatedRssDownloader]</option>
|
||||
<option value="always">QBT_TR(Always)QBT_TR[CONTEXT=AutomatedRssDownloader]</option>
|
||||
<option value="never">QBT_TR(Never)QBT_TR[CONTEXT=AutomatedRssDownloader]</option>
|
||||
<select disabled id="contentLayoutCombobox" class="fullWidth">
|
||||
<option value="Default">QBT_TR(Use global settings)QBT_TR[CONTEXT=AutomatedRssDownloader]</option>
|
||||
<option value="Original">QBT_TR(Original)QBT_TR[CONTEXT=AutomatedRssDownloader]</option>
|
||||
<option value="Subfolder">QBT_TR(Create subfolder)QBT_TR[CONTEXT=AutomatedRssDownloader]</option>
|
||||
<option value="NoSubfolder">QBT_TR(Don't create subfolder)QBT_TR[CONTEXT=AutomatedRssDownloader]</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -586,15 +587,18 @@ Supports the formats: S01E01, 1x1, 2017.12.31 and 31.12.2017 (Date formats also
|
||||
break;
|
||||
}
|
||||
|
||||
switch ($('creatSubfolderCombobox').value) {
|
||||
case 'default':
|
||||
rulesList[rule].createSubfolder = null;
|
||||
switch ($('contentLayoutCombobox').value) {
|
||||
case 'Default':
|
||||
rulesList[rule].torrentContentLayout = null;
|
||||
break;
|
||||
case 'always':
|
||||
rulesList[rule].createSubfolder = true;
|
||||
case 'Original':
|
||||
rulesList[rule].torrentContentLayout = 'Original';
|
||||
break;
|
||||
case 'never':
|
||||
rulesList[rule].createSubfolder = false;
|
||||
case 'Subfolder':
|
||||
rulesList[rule].torrentContentLayout = 'Subfolder';
|
||||
break;
|
||||
case 'NoSubfolder':
|
||||
rulesList[rule].torrentContentLayout = 'NoSubfolder';
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -660,7 +664,7 @@ Supports the formats: S01E01, 1x1, 2017.12.31 and 31.12.2017 (Date formats also
|
||||
$('saveToText').disabled = true;
|
||||
$('ignoreDaysValue').disabled = true;
|
||||
$('addPausedCombobox').disabled = true;
|
||||
$('creatSubfolderCombobox').disabled = true;
|
||||
$('contentLayoutCombobox').disabled = true;
|
||||
|
||||
// reset all boxes
|
||||
$('useRegEx').checked = false;
|
||||
@@ -674,7 +678,7 @@ Supports the formats: S01E01, 1x1, 2017.12.31 and 31.12.2017 (Date formats also
|
||||
$('ignoreDaysValue').value = 0;
|
||||
$('lastMatchText').innerHTML = 'QBT_TR(Last Match: Unknown)QBT_TR[CONTEXT=AutomatedRssDownloader]';
|
||||
$('addPausedCombobox').value = 'default';
|
||||
$('creatSubfolderCombobox').value = 'default';
|
||||
$('contentLayoutCombobox').value = 'Default';
|
||||
rssDownloaderFeedSelectionTable.clear();
|
||||
rssDownloaderArticlesTable.clear();
|
||||
|
||||
@@ -696,7 +700,7 @@ Supports the formats: S01E01, 1x1, 2017.12.31 and 31.12.2017 (Date formats also
|
||||
$('saveToText').disabled = rulesList[ruleName].savePath ? false : true;
|
||||
$('ignoreDaysValue').disabled = false;
|
||||
$('addPausedCombobox').disabled = false;
|
||||
$('creatSubfolderCombobox').disabled = false;
|
||||
$('contentLayoutCombobox').disabled = false;
|
||||
|
||||
// load rule settings
|
||||
$('useRegEx').checked = rulesList[ruleName].useRegex;
|
||||
@@ -725,10 +729,10 @@ Supports the formats: S01E01, 1x1, 2017.12.31 and 31.12.2017 (Date formats also
|
||||
else
|
||||
$('addPausedCombobox').value = rulesList[ruleName].addPaused ? 'always' : 'never';
|
||||
|
||||
if (rulesList[ruleName].createSubfolder === null)
|
||||
$('creatSubfolderCombobox').value = 'default';
|
||||
if (rulesList[ruleName].torrentContentLayout === null)
|
||||
$('contentLayoutCombobox').value = 'Default';
|
||||
else
|
||||
$('creatSubfolderCombobox').value = rulesList[ruleName].createSubfolder ? 'always' : 'never';
|
||||
$('contentLayoutCombobox').value = rulesList[ruleName].torrentContentLayout;
|
||||
|
||||
setElementTitles();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user