mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-12-27 08:19:30 +08:00
WebUI: Implement 'Force Start' feature.
This commit is contained in:
parent
2c5edf8652
commit
b5b40abb56
@ -103,6 +103,7 @@ 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_FIRST_LAST_PIECE_PRIO[] = "f_l_piece_prio";
|
||||||
static const char KEY_TORRENT_LABEL[] = "label";
|
static const char KEY_TORRENT_LABEL[] = "label";
|
||||||
static const char KEY_TORRENT_SUPER_SEEDING[] = "super_seeding";
|
static const char KEY_TORRENT_SUPER_SEEDING[] = "super_seeding";
|
||||||
|
static const char KEY_TORRENT_FORCE_START[] = "force_start";
|
||||||
|
|
||||||
// Tracker keys
|
// Tracker keys
|
||||||
static const char KEY_TRACKER_URL[] = "url";
|
static const char KEY_TRACKER_URL[] = "url";
|
||||||
@ -234,6 +235,7 @@ private:
|
|||||||
* - "state": Torrent state
|
* - "state": Torrent state
|
||||||
* - "seq_dl": Torrent sequential download state
|
* - "seq_dl": Torrent sequential download state
|
||||||
* - "f_l_piece_prio": Torrent first last piece priority state
|
* - "f_l_piece_prio": Torrent first last piece priority state
|
||||||
|
* - "force_start": Torrent force start state
|
||||||
*/
|
*/
|
||||||
QByteArray btjson::getTorrents(QString filter, QString label,
|
QByteArray btjson::getTorrents(QString filter, QString label,
|
||||||
QString sortedColumn, bool reverse, int limit, int offset)
|
QString sortedColumn, bool reverse, int limit, int offset)
|
||||||
@ -582,6 +584,7 @@ QVariantMap toMap(const QTorrentHandle& h)
|
|||||||
ret[KEY_TORRENT_FIRST_LAST_PIECE_PRIO] = h.first_last_piece_first();
|
ret[KEY_TORRENT_FIRST_LAST_PIECE_PRIO] = h.first_last_piece_first();
|
||||||
ret[KEY_TORRENT_LABEL] = TorrentPersistentData::instance()->getLabel(h.hash());
|
ret[KEY_TORRENT_LABEL] = TorrentPersistentData::instance()->getLabel(h.hash());
|
||||||
ret[KEY_TORRENT_SUPER_SEEDING] = status.super_seeding;
|
ret[KEY_TORRENT_SUPER_SEEDING] = status.super_seeding;
|
||||||
|
ret[KEY_TORRENT_FORCE_START] = h.is_forced(status);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -103,6 +103,7 @@ QMap<QString, QMap<QString, WebApplication::Action> > WebApplication::initialize
|
|||||||
ADD_ACTION(command, toggleSequentialDownload);
|
ADD_ACTION(command, toggleSequentialDownload);
|
||||||
ADD_ACTION(command, toggleFirstLastPiecePrio);
|
ADD_ACTION(command, toggleFirstLastPiecePrio);
|
||||||
ADD_ACTION(command, setSuperSeeding);
|
ADD_ACTION(command, setSuperSeeding);
|
||||||
|
ADD_ACTION(command, setForceStart);
|
||||||
ADD_ACTION(command, delete);
|
ADD_ACTION(command, delete);
|
||||||
ADD_ACTION(command, deletePerm);
|
ADD_ACTION(command, deletePerm);
|
||||||
ADD_ACTION(command, increasePrio);
|
ADD_ACTION(command, increasePrio);
|
||||||
@ -551,6 +552,19 @@ void WebApplication::action_command_setSuperSeeding()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WebApplication::action_command_setForceStart()
|
||||||
|
{
|
||||||
|
CHECK_URI(0);
|
||||||
|
CHECK_PARAMETERS("hashes" << "value");
|
||||||
|
bool value = request().posts["value"] == "true";
|
||||||
|
QStringList hashes = request().posts["hashes"].split("|");
|
||||||
|
foreach (const QString &hash, hashes) {
|
||||||
|
QTorrentHandle h = QBtSession::instance()->getTorrentHandle(hash);
|
||||||
|
if (h.is_valid())
|
||||||
|
QBtSession::instance()->resumeTorrent(hash, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void WebApplication::action_command_delete()
|
void WebApplication::action_command_delete()
|
||||||
{
|
{
|
||||||
CHECK_URI(0);
|
CHECK_URI(0);
|
||||||
|
@ -77,6 +77,7 @@ private:
|
|||||||
void action_command_toggleSequentialDownload();
|
void action_command_toggleSequentialDownload();
|
||||||
void action_command_toggleFirstLastPiecePrio();
|
void action_command_toggleFirstLastPiecePrio();
|
||||||
void action_command_setSuperSeeding();
|
void action_command_setSuperSeeding();
|
||||||
|
void action_command_setForceStart();
|
||||||
void action_command_delete();
|
void action_command_delete();
|
||||||
void action_command_deletePerm();
|
void action_command_deletePerm();
|
||||||
void action_command_increasePrio();
|
void action_command_increasePrio();
|
||||||
|
@ -96,6 +96,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<ul id="contextmenu">
|
<ul id="contextmenu">
|
||||||
<li><a href="#Start"><img src="theme/media-playback-start" alt="QBT_TR(Resume)QBT_TR"/> QBT_TR(Resume)QBT_TR</a></li>
|
<li><a href="#Start"><img src="theme/media-playback-start" alt="QBT_TR(Resume)QBT_TR"/> QBT_TR(Resume)QBT_TR</a></li>
|
||||||
|
<li><a href="#ForceStart"><img src="theme/checked" alt="QBT_TR(Force Resume)QBT_TR"/> QBT_TR(Force Resume)QBT_TR</a></li>
|
||||||
<li><a href="#Pause"><img src="theme/media-playback-pause" alt="QBT_TR(Pause)QBT_TR"/> QBT_TR(Pause)QBT_TR</a></li>
|
<li><a href="#Pause"><img src="theme/media-playback-pause" alt="QBT_TR(Pause)QBT_TR"/> QBT_TR(Pause)QBT_TR</a></li>
|
||||||
<li class="separator"><a href="#Delete"><img src="theme/list-remove" alt="QBT_TR(Delete)QBT_TR"/> QBT_TR(Delete)QBT_TR</a></li>
|
<li class="separator"><a href="#Delete"><img src="theme/list-remove" alt="QBT_TR(Delete)QBT_TR"/> QBT_TR(Delete)QBT_TR</a></li>
|
||||||
<li id="queueingMenuItems" class="separator">
|
<li id="queueingMenuItems" class="separator">
|
||||||
|
@ -137,6 +137,7 @@ var ContextMenu = new Class({
|
|||||||
all_are_paused = true;
|
all_are_paused = true;
|
||||||
there_are_paused = false;
|
there_are_paused = false;
|
||||||
all_are_super_seeding = true;
|
all_are_super_seeding = true;
|
||||||
|
all_are_force_start = true;
|
||||||
|
|
||||||
var h = myTable.selectedIds();
|
var h = myTable.selectedIds();
|
||||||
h.each(function(item, index){
|
h.each(function(item, index){
|
||||||
@ -152,6 +153,9 @@ var ContextMenu = new Class({
|
|||||||
else
|
else
|
||||||
there_are_f_l_piece_prio = true;
|
there_are_f_l_piece_prio = true;
|
||||||
|
|
||||||
|
if (data['force_start'] != true)
|
||||||
|
all_are_force_start = false;
|
||||||
|
|
||||||
if (data['progress'] != 1.0) // not downloaded
|
if (data['progress'] != 1.0) // not downloaded
|
||||||
all_are_downloaded = false;
|
all_are_downloaded = false;
|
||||||
else if (data['super_seeding'] != true)
|
else if (data['super_seeding'] != true)
|
||||||
@ -174,6 +178,8 @@ var ContextMenu = new Class({
|
|||||||
if (!all_are_f_l_piece_prio && there_are_f_l_piece_prio)
|
if (!all_are_f_l_piece_prio && there_are_f_l_piece_prio)
|
||||||
show_f_l_piece_prio = false;
|
show_f_l_piece_prio = false;
|
||||||
|
|
||||||
|
this.setItemChecked('ForceStart', all_are_force_start);
|
||||||
|
|
||||||
if (all_are_downloaded) {
|
if (all_are_downloaded) {
|
||||||
this.hideItem('SequentialDownload');
|
this.hideItem('SequentialDownload');
|
||||||
this.hideItem('FirstLastPiecePrio');
|
this.hideItem('FirstLastPiecePrio');
|
||||||
|
@ -181,6 +181,21 @@ initializeWindows = function() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
setForceStartFN = function(val) {
|
||||||
|
var h = myTable.selectedIds();
|
||||||
|
if (h.length) {
|
||||||
|
new Request({
|
||||||
|
url: 'command/setForceStart',
|
||||||
|
method: 'post',
|
||||||
|
data: {
|
||||||
|
value: val,
|
||||||
|
hashes: h.join("|")
|
||||||
|
}
|
||||||
|
}).send();
|
||||||
|
updateMainData();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
globalDownloadLimitFN = function() {
|
globalDownloadLimitFN = function() {
|
||||||
new MochaUI.Window({
|
new MochaUI.Window({
|
||||||
id: 'downloadLimitPage',
|
id: 'downloadLimitPage',
|
||||||
|
@ -54,6 +54,9 @@
|
|||||||
},
|
},
|
||||||
SuperSeeding : function (element, ref) {
|
SuperSeeding : function (element, ref) {
|
||||||
setSuperSeedingFN(!ref.getItemChecked('SuperSeeding'));
|
setSuperSeedingFN(!ref.getItemChecked('SuperSeeding'));
|
||||||
|
},
|
||||||
|
ForceStart : function (element, ref) {
|
||||||
|
setForceStartFN(!ref.getItemChecked('ForceStart'));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
offsets : {
|
offsets : {
|
||||||
|
Loading…
Reference in New Issue
Block a user