mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-28 13:28:50 +03:00
Add ability to set super seeding mode for torrents
This commit is contained in:
parent
28f573e9a8
commit
facab1681a
7 changed files with 49 additions and 0 deletions
|
@ -102,6 +102,7 @@ static const char KEY_TORRENT_STATE[] = "state";
|
|||
static const char KEY_TORRENT_SEQUENTIAL_DOWNLOAD[] = "seq_dl";
|
||||
static const char KEY_TORRENT_FIRST_LAST_PIECE_PRIO[] = "f_l_piece_prio";
|
||||
static const char KEY_TORRENT_LABEL[] = "label";
|
||||
static const char KEY_TORRENT_SUPER_SEEDING[] = "super_seeding";
|
||||
|
||||
// Tracker keys
|
||||
static const char KEY_TRACKER_URL[] = "url";
|
||||
|
@ -565,6 +566,7 @@ QVariantMap toMap(const QTorrentHandle& h)
|
|||
if (h.has_metadata())
|
||||
ret[KEY_TORRENT_FIRST_LAST_PIECE_PRIO] = h.first_last_piece_first();
|
||||
ret[KEY_TORRENT_LABEL] = TorrentPersistentData::instance()->getLabel(h.hash());
|
||||
ret[KEY_TORRENT_SUPER_SEEDING] = status.super_seeding;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -102,6 +102,7 @@ QMap<QString, QMap<QString, WebApplication::Action> > WebApplication::initialize
|
|||
ADD_ACTION(command, toggleAlternativeSpeedLimits);
|
||||
ADD_ACTION(command, toggleSequentialDownload);
|
||||
ADD_ACTION(command, toggleFirstLastPiecePrio);
|
||||
ADD_ACTION(command, setSuperSeeding);
|
||||
ADD_ACTION(command, delete);
|
||||
ADD_ACTION(command, deletePerm);
|
||||
ADD_ACTION(command, increasePrio);
|
||||
|
@ -541,6 +542,21 @@ void WebApplication::action_command_toggleFirstLastPiecePrio()
|
|||
}
|
||||
}
|
||||
|
||||
void WebApplication::action_command_setSuperSeeding()
|
||||
{
|
||||
CHECK_URI(0);
|
||||
CHECK_PARAMETERS("hashes" << "value");
|
||||
bool value = request().posts["value"] == "true";
|
||||
QStringList hashes = request().posts["hashes"].split("|");
|
||||
foreach (const QString &hash, hashes) {
|
||||
try {
|
||||
QTorrentHandle h = QBtSession::instance()->getTorrentHandle(hash);
|
||||
h.super_seeding(value);
|
||||
}
|
||||
catch(invalid_handle&) {}
|
||||
}
|
||||
}
|
||||
|
||||
void WebApplication::action_command_delete()
|
||||
{
|
||||
CHECK_URI(0);
|
||||
|
|
|
@ -76,6 +76,7 @@ private:
|
|||
void action_command_toggleAlternativeSpeedLimits();
|
||||
void action_command_toggleSequentialDownload();
|
||||
void action_command_toggleFirstLastPiecePrio();
|
||||
void action_command_setSuperSeeding();
|
||||
void action_command_delete();
|
||||
void action_command_deletePerm();
|
||||
void action_command_increasePrio();
|
||||
|
|
|
@ -111,6 +111,7 @@
|
|||
<li><a href="#UploadLimit"><img src="images/skin/seeding.png" alt="QBT_TR(Limit upload rate...)QBT_TR"/> QBT_TR(Limit upload rate...)QBT_TR</a></li>
|
||||
<li class="separator"><a href="#SequentialDownload"><img src="theme/checked" alt="QBT_TR(Download in sequential order)QBT_TR"/> QBT_TR(Download in sequential order)QBT_TR</a></li>
|
||||
<li><a href="#FirstLastPiecePrio"><img src="theme/checked" alt="QBT_TR(Download first and last piece first)QBT_TR"/> QBT_TR(Download first and last piece first)QBT_TR</a></li>
|
||||
<li class="separator"><a href="#SuperSeeding"><img src="theme/checked" alt="QBT_TR(Super seeding mode)QBT_TR"/> QBT_TR(Super seeding mode)QBT_TR</a></li>
|
||||
<li class="separator"><a href="#ForceRecheck"><img src="theme/document-edit-verify" alt="QBT_TR(Force recheck)QBT_TR"/> QBT_TR(Force recheck)QBT_TR</a></li>
|
||||
</ul>
|
||||
<div id="desktopFooterWrapper">
|
||||
|
|
|
@ -136,6 +136,7 @@ var ContextMenu = new Class({
|
|||
all_are_downloaded = true;
|
||||
all_are_paused = true;
|
||||
there_are_paused = false;
|
||||
all_are_super_seeding = true;
|
||||
|
||||
var h = myTable.selectedIds();
|
||||
h.each(function(item, index){
|
||||
|
@ -153,6 +154,8 @@ var ContextMenu = new Class({
|
|||
|
||||
if (data['progress'] != 1.0) // not downloaded
|
||||
all_are_downloaded = false;
|
||||
else if (data['super_seeding'] != true)
|
||||
all_are_super_seeding = false;
|
||||
|
||||
state = data['state'];
|
||||
if ((state != 'pausedUP') && (state != 'pausedDL'))
|
||||
|
@ -174,6 +177,8 @@ var ContextMenu = new Class({
|
|||
if (all_are_downloaded) {
|
||||
this.hideItem('SequentialDownload');
|
||||
this.hideItem('FirstLastPiecePrio');
|
||||
this.showItem('SuperSeeding');
|
||||
this.setItemChecked('SuperSeeding', all_are_super_seeding);
|
||||
} else {
|
||||
if (!show_seq_dl && show_f_l_piece_prio)
|
||||
this.menu.getElement('a[href$=FirstLastPiecePrio]').parentNode.addClass('separator');
|
||||
|
@ -192,6 +197,8 @@ var ContextMenu = new Class({
|
|||
|
||||
this.setItemChecked('SequentialDownload', all_are_seq_dl);
|
||||
this.setItemChecked('FirstLastPiecePrio', all_are_f_l_piece_prio);
|
||||
|
||||
this.hideItem('SuperSeeding');
|
||||
}
|
||||
|
||||
if (all_are_paused) {
|
||||
|
@ -234,6 +241,10 @@ var ContextMenu = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
getItemChecked: function(item) {
|
||||
return '0' != this.menu.getElement('a[href$=' + item + ']').firstChild.style.opacity;
|
||||
},
|
||||
|
||||
//hide an item
|
||||
hideItem: function(item) {
|
||||
this.menu.getElement('a[href$=' + item + ']').parentNode.addClass('invisible');
|
||||
|
|
|
@ -166,6 +166,21 @@ initializeWindows = function() {
|
|||
}
|
||||
};
|
||||
|
||||
setSuperSeedingFN = function(val) {
|
||||
var h = myTable.selectedIds();
|
||||
if (h.length) {
|
||||
new Request({
|
||||
url: 'command/setSuperSeeding',
|
||||
method: 'post',
|
||||
data: {
|
||||
value: val,
|
||||
hashes: h.join("|")
|
||||
}
|
||||
}).send();
|
||||
updateMainData();
|
||||
}
|
||||
};
|
||||
|
||||
globalDownloadLimitFN = function() {
|
||||
new MochaUI.Window({
|
||||
id: 'downloadLimitPage',
|
||||
|
|
|
@ -51,6 +51,9 @@
|
|||
},
|
||||
FirstLastPiecePrio : function (element, ref) {
|
||||
toggleFirstLastPiecePrioFN();
|
||||
},
|
||||
SuperSeeding : function (element, ref) {
|
||||
setSuperSeedingFN(!ref.getItemChecked('SuperSeeding'));
|
||||
}
|
||||
},
|
||||
offsets : {
|
||||
|
|
Loading…
Reference in a new issue