diff --git a/src/webui/api/serialize/serialize_torrent.cpp b/src/webui/api/serialize/serialize_torrent.cpp
index d28b20a55..124d9e1f4 100644
--- a/src/webui/api/serialize/serialize_torrent.cpp
+++ b/src/webui/api/serialize/serialize_torrent.cpp
@@ -120,7 +120,10 @@ QVariantMap serialize(const BitTorrent::TorrentHandle &torrent)
ret[KEY_TORRENT_AMOUNT_UPLOADED_SESSION] = torrent.totalPayloadUpload();
ret[KEY_TORRENT_AMOUNT_LEFT] = torrent.incompletedSize();
ret[KEY_TORRENT_AMOUNT_COMPLETED] = torrent.completedSize();
- ret[KEY_TORRENT_RATIO_LIMIT] = torrent.maxRatio();
+ ret[KEY_TORRENT_MAX_RATIO] = torrent.maxRatio();
+ ret[KEY_TORRENT_MAX_SEEDING_TIME] = torrent.maxSeedingTime();
+ ret[KEY_TORRENT_RATIO_LIMIT] = torrent.ratioLimit();
+ ret[KEY_TORRENT_SEEDING_TIME_LIMIT] = torrent.seedingTimeLimit();
ret[KEY_TORRENT_LAST_SEEN_COMPLETE_TIME] = torrent.lastSeenComplete().toTime_t();
ret[KEY_TORRENT_AUTO_TORRENT_MANAGEMENT] = torrent.isAutoTMMEnabled();
ret[KEY_TORRENT_TIME_ACTIVE] = torrent.activeTime();
diff --git a/src/webui/api/serialize/serialize_torrent.h b/src/webui/api/serialize/serialize_torrent.h
index 8f861637a..832e9e252 100644
--- a/src/webui/api/serialize/serialize_torrent.h
+++ b/src/webui/api/serialize/serialize_torrent.h
@@ -69,7 +69,10 @@ const char KEY_TORRENT_AMOUNT_DOWNLOADED_SESSION[] = "downloaded_session";
const char KEY_TORRENT_AMOUNT_UPLOADED_SESSION[] = "uploaded_session";
const char KEY_TORRENT_AMOUNT_LEFT[] = "amount_left";
const char KEY_TORRENT_AMOUNT_COMPLETED[] = "completed";
+const char KEY_TORRENT_MAX_RATIO[] = "max_ratio";
+const char KEY_TORRENT_MAX_SEEDING_TIME[] = "max_seeding_time";
const char KEY_TORRENT_RATIO_LIMIT[] = "ratio_limit";
+const char KEY_TORRENT_SEEDING_TIME_LIMIT[] = "seeding_time_limit";
const char KEY_TORRENT_LAST_SEEN_COMPLETE_TIME[] = "seen_complete";
const char KEY_TORRENT_LAST_ACTIVITY_TIME[] = "last_activity";
const char KEY_TORRENT_TOTAL_SIZE[] = "total_size";
diff --git a/src/webui/api/synccontroller.cpp b/src/webui/api/synccontroller.cpp
index f88fbd51a..1c2126fd2 100644
--- a/src/webui/api/synccontroller.cpp
+++ b/src/webui/api/synccontroller.cpp
@@ -351,7 +351,10 @@ namespace
// - "amount_left": Amount of data left to download
// - "save_path": Torrent save path
// - "completed": Amount of data completed
+// - "max_ratio": Upload max share ratio
+// - "max_seeding_time": Upload max seeding time
// - "ratio_limit": Upload share ratio limit
+// - "seeding_time_limit": Upload seeding time limit
// - "seen_complete": Indicates the time when the torrent was last seen complete/whole
// - "last_activity": Last time when a chunk was downloaded/uploaded
// - "total_size": Size including unwanted data
diff --git a/src/webui/api/torrentscontroller.cpp b/src/webui/api/torrentscontroller.cpp
index 8b6f25e76..c8b6813d3 100644
--- a/src/webui/api/torrentscontroller.cpp
+++ b/src/webui/api/torrentscontroller.cpp
@@ -623,6 +623,21 @@ void TorrentsController::setDownloadLimitAction()
applyToTorrents(hashes, [limit](BitTorrent::TorrentHandle *torrent) { torrent->setDownloadLimit(limit); });
}
+void TorrentsController::setShareLimitsAction()
+{
+ checkParams({"hashes", "ratioLimit", "seedingTimeLimit"});
+
+ const qreal ratioLimit = params()["ratioLimit"].toDouble();
+ const qlonglong seedingTimeLimit = params()["seedingTimeLimit"].toLongLong();
+ const QStringList hashes = params()["hashes"].split('|');
+
+ applyToTorrents(hashes, [ratioLimit, seedingTimeLimit](BitTorrent::TorrentHandle *torrent)
+ {
+ torrent->setRatioLimit(ratioLimit);
+ torrent->setSeedingTimeLimit(seedingTimeLimit);
+ });
+}
+
void TorrentsController::toggleSequentialDownloadAction()
{
checkParams({"hashes"});
diff --git a/src/webui/api/torrentscontroller.h b/src/webui/api/torrentscontroller.h
index 0b1814ef2..03d870f93 100644
--- a/src/webui/api/torrentscontroller.h
+++ b/src/webui/api/torrentscontroller.h
@@ -61,6 +61,7 @@ private slots:
void downloadLimitAction();
void setUploadLimitAction();
void setDownloadLimitAction();
+ void setShareLimitsAction();
void increasePrioAction();
void decreasePrioAction();
void topPrioAction();
diff --git a/src/webui/webui.qrc b/src/webui/webui.qrc
index b889c9264..686aea1db 100644
--- a/src/webui/webui.qrc
+++ b/src/webui/webui.qrc
@@ -37,6 +37,7 @@
www/private/scripts/prop-trackers.js
www/private/scripts/prop-webseeds.js
www/private/setlocation.html
+ www/private/shareratio.html
www/private/statistics.html
www/private/transferlist.html
www/private/upload.html
diff --git a/src/webui/www/private/index.html b/src/webui/www/private/index.html
index d28ef3daa..d6b4aea08 100644
--- a/src/webui/www/private/index.html
+++ b/src/webui/www/private/index.html
@@ -122,6 +122,7 @@
QBT_TR(Limit download rate...)QBT_TR[CONTEXT=TransferListWidget]
QBT_TR(Limit upload rate...)QBT_TR[CONTEXT=TransferListWidget]
+ QBT_TR(Limit share ratio...)QBT_TR[CONTEXT=TransferListWidget]
QBT_TR(Super seeding mode)QBT_TR[CONTEXT=TransferListWidget]
QBT_TR(Download in sequential order)QBT_TR[CONTEXT=TransferListWidget]
QBT_TR(Download first and last pieces first)QBT_TR[CONTEXT=TransferListWidget]
diff --git a/src/webui/www/private/scripts/dynamicTable.js b/src/webui/www/private/scripts/dynamicTable.js
index ebae00c21..00b6d1c5d 100644
--- a/src/webui/www/private/scripts/dynamicTable.js
+++ b/src/webui/www/private/scripts/dynamicTable.js
@@ -769,7 +769,7 @@ var TorrentsTable = new Class({
this.newColumn('time_active', '', 'QBT_TR(Time Active)QBT_TR[CONTEXT=TorrentModel]', 100, false);
this.newColumn('save_path', '', 'QBT_TR(Save path)QBT_TR[CONTEXT=TorrentModel]', 100, false);
this.newColumn('completed', '', 'QBT_TR(Completed)QBT_TR[CONTEXT=TorrentModel]', 100, false);
- this.newColumn('ratio_limit', '', 'QBT_TR(Ratio Limit)QBT_TR[CONTEXT=TorrentModel]', 100, false);
+ this.newColumn('max_ratio', '', 'QBT_TR(Ratio Limit)QBT_TR[CONTEXT=TorrentModel]', 100, false);
this.newColumn('seen_complete', '', 'QBT_TR(Last Seen Complete)QBT_TR[CONTEXT=TorrentModel]', 100, false);
this.newColumn('last_activity', '', 'QBT_TR(Last Activity)QBT_TR[CONTEXT=TorrentModel]', 100, false);
@@ -1076,8 +1076,8 @@ var TorrentsTable = new Class({
this.columns['save_path'].updateTd = this.columns['name'].updateTd;
this.columns['tracker'].updateTd = this.columns['name'].updateTd;
- // ratio_limit
- this.columns['ratio_limit'].updateTd = this.columns['ratio'].updateTd;
+ // max_ratio
+ this.columns['max_ratio'].updateTd = this.columns['ratio'].updateTd;
// last_activity
this.columns['last_activity'].updateTd = function(td, row) {
diff --git a/src/webui/www/private/scripts/misc.js b/src/webui/www/private/scripts/misc.js
index b1d14b1b9..fb6f4341d 100644
--- a/src/webui/www/private/scripts/misc.js
+++ b/src/webui/www/private/scripts/misc.js
@@ -76,6 +76,10 @@ function friendlyPercentage(value) {
return percentage.toFixed(1) + "%";
}
+function friendlyFloat(value, precision) {
+ return parseFloat(value).toFixed(precision);
+}
+
/*
* From: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString
*/
diff --git a/src/webui/www/private/scripts/mocha-init.js b/src/webui/www/private/scripts/mocha-init.js
index 0ea4f16af..ff316caff 100644
--- a/src/webui/www/private/scripts/mocha-init.js
+++ b/src/webui/www/private/scripts/mocha-init.js
@@ -146,7 +146,6 @@ initializeWindows = function() {
uploadLimitFN = function() {
var hashes = torrentsTable.selectedRowsIds();
if (hashes.length) {
- var hash = hashes[0];
new MochaUI.Window({
id: 'uploadLimitPage',
title: "QBT_TR(Torrent Upload Speed Limiting)QBT_TR[CONTEXT=TransferListWidget]",
@@ -163,6 +162,45 @@ initializeWindows = function() {
}
};
+ shareRatioFN = function() {
+ var hashes = torrentsTable.selectedRowsIds();
+ if (hashes.length) {
+ var shareRatio = null;
+ var torrentsHaveSameShareRatio = true;
+
+ // check if all selected torrents have same share ratio
+ for (var i = 0; i < hashes.length; i++) {
+ var hash = hashes[i];
+ var row = torrentsTable.rows[hash].full_data;
+ var origValues = row.ratio_limit + "|" + row.seeding_time_limit + "|" + row.max_ratio + "|" + row.max_seeding_time;
+
+ // initialize value
+ if (shareRatio === null)
+ shareRatio = origValues;
+
+ if (origValues !== shareRatio) {
+ torrentsHaveSameShareRatio = false;
+ break;
+ }
+ }
+
+ // if all torrents have same share ratio, display that share ratio. else use the default
+ var orig = torrentsHaveSameShareRatio ? shareRatio : "";
+ new MochaUI.Window({
+ id: 'shareRatioPage',
+ title: "QBT_TR(Torrent Upload/Download Ratio Limiting)QBT_TR[CONTEXT=UpDownRatioDlg]",
+ loadMethod: 'iframe',
+ contentURL: 'shareratio.html?hashes=' + hashes.join("|") + '&orig=' + orig,
+ scrollbars: false,
+ maximizable: false,
+ paddingVertical: 0,
+ paddingHorizontal: 0,
+ width: 424,
+ height: 175
+ });
+ }
+ };
+
toggleSequentialDownloadFN = function() {
var hashes = torrentsTable.selectedRowsIds();
if (hashes.length) {
@@ -257,7 +295,6 @@ initializeWindows = function() {
downloadLimitFN = function() {
var hashes = torrentsTable.selectedRowsIds();
if (hashes.length) {
- var hash = hashes[0];
new MochaUI.Window({
id: 'downloadLimitPage',
title: "QBT_TR(Torrent Download Speed Limiting)QBT_TR[CONTEXT=TransferListWidget]",
@@ -388,12 +425,11 @@ initializeWindows = function() {
var hash = hashes[0];
var row = torrentsTable.rows[hash];
if (row) {
- var name = row.full_data.name;
new MochaUI.Window({
id: 'renamePage',
title: "QBT_TR(Rename)QBT_TR[CONTEXT=TransferListWidget]",
loadMethod: 'iframe',
- contentURL: 'rename.html?hash=' + hashes[0] + '&name=' + name,
+ contentURL: 'rename.html?hash=' + hashes[0] + '&name=' + row.full_data.name,
scrollbars: false,
resizable: false,
maximizable: false,
diff --git a/src/webui/www/private/shareratio.html b/src/webui/www/private/shareratio.html
new file mode 100644
index 000000000..1913c65f3
--- /dev/null
+++ b/src/webui/www/private/shareratio.html
@@ -0,0 +1,167 @@
+
+
+
+
+
+ QBT_TR(Torrent Upload/Download Ratio Limiting)QBT_TR[CONTEXT=UpDownRatioDlg]
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/webui/www/private/transferlist.html b/src/webui/www/private/transferlist.html
index 779e61019..5e2fb089c 100644
--- a/src/webui/www/private/transferlist.html
+++ b/src/webui/www/private/transferlist.html
@@ -61,6 +61,9 @@
UploadLimit: function(element, ref) {
uploadLimitFN();
},
+ ShareRatio : function (element, ref) {
+ shareRatioFN();
+ },
SequentialDownload: function(element, ref) {
toggleSequentialDownloadFN();