mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-22 12:34:19 +00:00
- Global Upload/Download rates can be set by clicking on the status bar values
This commit is contained in:
parent
f6bfacda2c
commit
13493e1afe
@ -305,7 +305,7 @@ void HttpConnection::respondPreferencesJson() {
|
||||
|
||||
void HttpConnection::respondGlobalTransferInfoJson() {
|
||||
QVariantMap info;
|
||||
session_status sessionStatus = parent->getBTSession()->getSessionStatus();
|
||||
session_status sessionStatus = BTSession->getSessionStatus();
|
||||
info["DlInfos"] = tr("D: %1/s - T: %2", "Download speed: x KiB/s - Transferred: x MiB").arg(misc::friendlyUnit(sessionStatus.payload_download_rate)).arg(misc::friendlyUnit(sessionStatus.total_payload_download));
|
||||
info["UpInfos"] = tr("U: %1/s - T: %2", "Upload speed: x KiB/s - Transferred: x MiB").arg(misc::friendlyUnit(sessionStatus.payload_upload_rate)).arg(misc::friendlyUnit(sessionStatus.total_payload_upload));
|
||||
QString string = json::toJson(info);
|
||||
@ -454,6 +454,18 @@ void HttpConnection::respondCommand(QString command)
|
||||
h.set_download_limit(limit);
|
||||
}
|
||||
}
|
||||
if(command == "setGlobalUpLimit") {
|
||||
qlonglong limit = parser.post("limit").toLongLong();
|
||||
if(limit == 0) limit = -1;
|
||||
BTSession->getSession()->set_upload_rate_limit(limit);
|
||||
Preferences::setGlobalUploadLimit(limit/1024.);
|
||||
}
|
||||
if(command == "setGlobalDlLimit") {
|
||||
qlonglong limit = parser.post("limit").toLongLong();
|
||||
if(limit == 0) limit = -1;
|
||||
BTSession->getSession()->set_download_rate_limit(limit);
|
||||
Preferences::setGlobalDownloadLimit(limit/1024.);
|
||||
}
|
||||
if(command == "pause") {
|
||||
emit pauseTorrent(parser.post("hash"));
|
||||
return;
|
||||
|
@ -60,7 +60,6 @@ class HttpServer : public QTcpServer {
|
||||
EventManager *eventManager() const;
|
||||
QString generateNonce() const;
|
||||
QHash<QString, int> client_failed_attempts;
|
||||
Bittorrent *getBTSession() const { return BTSession; }
|
||||
|
||||
private slots:
|
||||
void newHttpConnection();
|
||||
|
@ -24,13 +24,23 @@
|
||||
var hash = new URI().getData('hash');
|
||||
setDlLimit = function() {
|
||||
var limit = $("dllimitUpdatevalue").get('html').toInt() * 1024;
|
||||
new Request({url: '/command/setTorrentDlLimit',
|
||||
method: 'post',
|
||||
data: {'hash': hash, 'limit': limit},
|
||||
onComplete: function() {
|
||||
window.parent.closeWindows();
|
||||
}
|
||||
}).send();
|
||||
if(hash == "global") {
|
||||
new Request({url: '/command/setGlobalDlLimit',
|
||||
method: 'post',
|
||||
data: {'limit': limit},
|
||||
onComplete: function() {
|
||||
window.parent.closeWindows();
|
||||
}
|
||||
}).send();
|
||||
} else {
|
||||
new Request({url: '/command/setTorrentDlLimit',
|
||||
method: 'post',
|
||||
data: {'hash': hash, 'limit': limit},
|
||||
onComplete: function() {
|
||||
window.parent.closeWindows();
|
||||
}
|
||||
}).send();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<input type="button" value="_(Apply)" onclick="setDlLimit()"/>
|
||||
|
@ -100,7 +100,7 @@
|
||||
<div id="desktopFooterWrapper">
|
||||
<div id="desktopFooter">
|
||||
<table style="position: absolute; right: 5px;">
|
||||
<tr><td id="DlInfos"></td><td style="width: 2px;margin:0;"><img src="images/skin/toolbox-divider.gif" style="height: 18px; padding-left: 10px; padding-right: 10px; margin-bottom: -2px;"/></td><td id="UpInfos"></td></tr>
|
||||
<tr><td id="DlInfos" style="cursor:pointer;"></td><td style="width: 2px;margin:0;"><img src="images/skin/toolbox-divider.gif" style="height: 18px; padding-left: 10px; padding-right: 10px; margin-bottom: -2px;"/></td><td id="UpInfos" style="cursor:pointer;"></td></tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -135,6 +135,9 @@ window.addEvent('load', function(){
|
||||
}).send();
|
||||
}
|
||||
};
|
||||
$('DlInfos').addEvent('click', globalDownloadLimitFN);
|
||||
$('UpInfos').addEvent('click', globalUploadLimitFN);
|
||||
|
||||
var ajaxfn = function(){
|
||||
var queueing_enabled = false;
|
||||
var url = 'json/events';
|
||||
|
@ -76,6 +76,22 @@ initializeWindows = function(){
|
||||
});
|
||||
});
|
||||
|
||||
globalUploadLimitFN = function() {
|
||||
new MochaUI.Window({
|
||||
id: 'uploadLimitPage',
|
||||
title: "_(Global Upload Speed Limiting)",
|
||||
loadMethod: 'iframe',
|
||||
contentURL:'uploadlimit.html?hash=global',
|
||||
scrollbars: false,
|
||||
resizable: false,
|
||||
maximizable: false,
|
||||
paddingVertical: 0,
|
||||
paddingHorizontal: 0,
|
||||
width: 424,
|
||||
height: 80
|
||||
});
|
||||
}
|
||||
|
||||
uploadLimitFN = function() {
|
||||
var h = myTable.selectedIds();
|
||||
if(h.length){
|
||||
@ -96,6 +112,22 @@ initializeWindows = function(){
|
||||
}
|
||||
};
|
||||
|
||||
globalDownloadLimitFN = function() {
|
||||
new MochaUI.Window({
|
||||
id: 'downloadLimitPage',
|
||||
title: "_(Global Download Speed Limiting)",
|
||||
loadMethod: 'iframe',
|
||||
contentURL:'downloadlimit.html?hash=global',
|
||||
scrollbars: false,
|
||||
resizable: false,
|
||||
maximizable: false,
|
||||
paddingVertical: 0,
|
||||
paddingHorizontal: 0,
|
||||
width: 424,
|
||||
height: 80
|
||||
});
|
||||
}
|
||||
|
||||
downloadLimitFN = function() {
|
||||
var h = myTable.selectedIds();
|
||||
if(h.length){
|
||||
|
@ -32,40 +32,68 @@ MochaUI.extend({
|
||||
maximum = tmp / 1024.
|
||||
}
|
||||
}
|
||||
}
|
||||
}).send();
|
||||
// Get torrent upload limit
|
||||
// And create slider
|
||||
var req = new Request({
|
||||
url: '/command/getTorrentUpLimit',
|
||||
method: 'post',
|
||||
data: {hash: hash},
|
||||
onSuccess: function(data) {
|
||||
if(data){
|
||||
var up_limit = data.toInt();
|
||||
// Get torrent upload limit
|
||||
// And create slider
|
||||
if(hash == 'global') {
|
||||
var up_limit = maximum;
|
||||
if(up_limit < 0) up_limit = 0;
|
||||
maximum = 1000;
|
||||
var mochaSlide = new Slider($('uplimitSliderarea'), $('uplimitSliderknob'), {
|
||||
steps: maximum,
|
||||
offset: 0,
|
||||
initialStep: (up_limit/1024.).round(),
|
||||
onChange: function(pos){
|
||||
if(pos > 0) {
|
||||
$('uplimitUpdatevalue').set('html', pos);
|
||||
$('upLimitUnit').set('html', "_(KiB/s)");
|
||||
} else {
|
||||
$('uplimitUpdatevalue').set('html', '∞');
|
||||
$('upLimitUnit').set('html', "");
|
||||
}
|
||||
}.bind(this)
|
||||
});
|
||||
steps: maximum,
|
||||
offset: 0,
|
||||
initialStep: up_limit.round(),
|
||||
onChange: function(pos){
|
||||
if(pos > 0) {
|
||||
$('uplimitUpdatevalue').set('html', pos);
|
||||
$('upLimitUnit').set('html', "_(KiB/s)");
|
||||
} else {
|
||||
$('uplimitUpdatevalue').set('html', '∞');
|
||||
$('upLimitUnit').set('html', "");
|
||||
}
|
||||
}.bind(this)
|
||||
});
|
||||
// Set default value
|
||||
if(up_limit == 0) {
|
||||
$('uplimitUpdatevalue').set('html', '∞');
|
||||
$('upLimitUnit').set('html', "");
|
||||
} else {
|
||||
$('uplimitUpdatevalue').set('html', (up_limit/1024.).round());
|
||||
$('uplimitUpdatevalue').set('html', up_limit.round());
|
||||
$('upLimitUnit').set('html', "_(KiB/s)");
|
||||
}
|
||||
} else {
|
||||
var req = new Request({
|
||||
url: '/command/getTorrentUpLimit',
|
||||
method: 'post',
|
||||
data: {hash: hash},
|
||||
onSuccess: function(data) {
|
||||
if(data){
|
||||
var up_limit = data.toInt();
|
||||
if(up_limit < 0) up_limit = 0;
|
||||
var mochaSlide = new Slider($('uplimitSliderarea'), $('uplimitSliderknob'), {
|
||||
steps: maximum,
|
||||
offset: 0,
|
||||
initialStep: (up_limit/1024.).round(),
|
||||
onChange: function(pos){
|
||||
if(pos > 0) {
|
||||
$('uplimitUpdatevalue').set('html', pos);
|
||||
$('upLimitUnit').set('html', "_(KiB/s)");
|
||||
} else {
|
||||
$('uplimitUpdatevalue').set('html', '∞');
|
||||
$('upLimitUnit').set('html', "");
|
||||
}
|
||||
}.bind(this)
|
||||
});
|
||||
// Set default value
|
||||
if(up_limit == 0) {
|
||||
$('uplimitUpdatevalue').set('html', '∞');
|
||||
$('upLimitUnit').set('html', "");
|
||||
} else {
|
||||
$('uplimitUpdatevalue').set('html', (up_limit/1024.).round());
|
||||
$('upLimitUnit').set('html', "_(KiB/s)");
|
||||
}
|
||||
}
|
||||
}
|
||||
}).send();
|
||||
}
|
||||
}
|
||||
}).send();
|
||||
@ -89,22 +117,16 @@ MochaUI.extend({
|
||||
maximum = tmp / 1024.
|
||||
}
|
||||
}
|
||||
}
|
||||
}).send();
|
||||
// Get torrent download limit
|
||||
// And create slider
|
||||
var req = new Request({
|
||||
url: '/command/getTorrentDlLimit',
|
||||
method: 'post',
|
||||
data: {hash: hash},
|
||||
onSuccess: function(data) {
|
||||
if(data){
|
||||
var dl_limit = data.toInt();
|
||||
// Get torrent download limit
|
||||
// And create slider
|
||||
if(hash == "global") {
|
||||
var dl_limit = maximum;
|
||||
if(dl_limit < 0) dl_limit = 0;
|
||||
maximum = 1000;
|
||||
var mochaSlide = new Slider($('dllimitSliderarea'), $('dllimitSliderknob'), {
|
||||
steps: maximum,
|
||||
offset: 0,
|
||||
initialStep: (dl_limit/1024.).round(),
|
||||
initialStep: dl_limit.round(),
|
||||
onChange: function(pos){
|
||||
if(pos > 0) {
|
||||
$('dllimitUpdatevalue').set('html', pos);
|
||||
@ -120,9 +142,43 @@ MochaUI.extend({
|
||||
$('dllimitUpdatevalue').set('html', '∞');
|
||||
$('dlLimitUnit').set('html', "");
|
||||
} else {
|
||||
$('dllimitUpdatevalue').set('html', (dl_limit/1024.).round());
|
||||
$('dllimitUpdatevalue').set('html', dl_limit.round());
|
||||
$('dlLimitUnit').set('html', "_(KiB/s)");
|
||||
}
|
||||
} else {
|
||||
var req = new Request({
|
||||
url: '/command/getTorrentDlLimit',
|
||||
method: 'post',
|
||||
data: {hash: hash},
|
||||
onSuccess: function(data) {
|
||||
if(data){
|
||||
var dl_limit = data.toInt();
|
||||
if(dl_limit < 0) dl_limit = 0;
|
||||
var mochaSlide = new Slider($('dllimitSliderarea'), $('dllimitSliderknob'), {
|
||||
steps: maximum,
|
||||
offset: 0,
|
||||
initialStep: (dl_limit/1024.).round(),
|
||||
onChange: function(pos){
|
||||
if(pos > 0) {
|
||||
$('dllimitUpdatevalue').set('html', pos);
|
||||
$('dlLimitUnit').set('html', "_(KiB/s)");
|
||||
} else {
|
||||
$('dllimitUpdatevalue').set('html', '∞');
|
||||
$('dlLimitUnit').set('html', "");
|
||||
}
|
||||
}.bind(this)
|
||||
});
|
||||
// Set default value
|
||||
if(dl_limit == 0) {
|
||||
$('dllimitUpdatevalue').set('html', '∞');
|
||||
$('dlLimitUnit').set('html', "");
|
||||
} else {
|
||||
$('dllimitUpdatevalue').set('html', (dl_limit/1024.).round());
|
||||
$('dlLimitUnit').set('html', "_(KiB/s)");
|
||||
}
|
||||
}
|
||||
}
|
||||
}).send();
|
||||
}
|
||||
}
|
||||
}).send();
|
||||
|
@ -24,13 +24,23 @@
|
||||
var hash = new URI().getData('hash');
|
||||
setUpLimit = function() {
|
||||
var limit = $("uplimitUpdatevalue").get('html').toInt() * 1024;
|
||||
new Request({url: '/command/setTorrentUpLimit',
|
||||
method: 'post',
|
||||
data: {'hash': hash, 'limit': limit},
|
||||
onComplete: function() {
|
||||
window.parent.closeWindows();
|
||||
}
|
||||
}).send();
|
||||
if(hash == "global") {
|
||||
new Request({url: '/command/setGlobalUpLimit',
|
||||
method: 'post',
|
||||
data: {'limit': limit},
|
||||
onComplete: function() {
|
||||
window.parent.closeWindows();
|
||||
}
|
||||
}).send();
|
||||
}else {
|
||||
new Request({url: '/command/setTorrentUpLimit',
|
||||
method: 'post',
|
||||
data: {'hash': hash, 'limit': limit},
|
||||
onComplete: function() {
|
||||
window.parent.closeWindows();
|
||||
}
|
||||
}).send();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<input type="button" value="_(Apply)" onclick="setUpLimit()"/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user