diff --git a/src/webui/webapplication.cpp b/src/webui/webapplication.cpp index bcd0b8098..f9ff7927c 100644 --- a/src/webui/webapplication.cpp +++ b/src/webui/webapplication.cpp @@ -34,6 +34,7 @@ #include #include "base/iconprovider.h" +#include "base/logger.h" #include "base/utils/misc.h" #include "base/utils/fs.h" #include "base/utils/string.h" @@ -117,6 +118,7 @@ QMap > WebApplication::initialize ADD_ACTION(command, decreasePrio); ADD_ACTION(command, topPrio); ADD_ACTION(command, bottomPrio); + ADD_ACTION(command, setLocation); ADD_ACTION(command, recheck); ADD_ACTION(command, setCategory); ADD_ACTION(command, addCategory); @@ -774,6 +776,30 @@ void WebApplication::action_command_bottomPrio() BitTorrent::Session::instance()->bottomTorrentsPriority(hashes); } +void WebApplication::action_command_setLocation() +{ + CHECK_URI(0); + CHECK_PARAMETERS("hashes" << "location"); + + QStringList hashes = request().posts["hashes"].split("|"); + QString newLocation = request().posts["location"].trimmed(); + + // check location exists + if (newLocation.isEmpty() || !QDir(newLocation).exists()) + return; + + foreach (const QString &hash, hashes) { + BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash); + if (torrent) { + // get old location + const QString oldLocation = torrent->savePath(); + Logger::instance()->addMessage(tr("WebUI Set location: moving \"%1\", from \"%2\" to \"%3\"").arg(torrent->name()).arg(torrent->savePath()).arg(newLocation)); + + torrent->move(Utils::Fs::expandPathAbs(newLocation)); + } + } +} + void WebApplication::action_command_recheck() { CHECK_URI(0); diff --git a/src/webui/webapplication.h b/src/webui/webapplication.h index 126cfa204..5e58e18e3 100644 --- a/src/webui/webapplication.h +++ b/src/webui/webapplication.h @@ -90,6 +90,7 @@ private: void action_command_decreasePrio(); void action_command_topPrio(); void action_command_bottomPrio(); + void action_command_setLocation(); void action_command_recheck(); void action_command_setCategory(); void action_command_addCategory(); diff --git a/src/webui/webui.qrc b/src/webui/webui.qrc index 833ea74ed..0e1cbac2b 100644 --- a/src/webui/webui.qrc +++ b/src/webui/webui.qrc @@ -41,5 +41,6 @@ www/public/upload.html www/public/uploadlimit.html www/public/newcategory.html + www/public/setlocation.html diff --git a/src/webui/www/private/index.html b/src/webui/www/private/index.html index 33104bb18..4d85de23f 100644 --- a/src/webui/www/private/index.html +++ b/src/webui/www/private/index.html @@ -108,6 +108,9 @@
  • QBT_TR(Force Resume)QBT_TR[CONTEXT=TransferListWidget] QBT_TR(Force Resume)QBT_TR[CONTEXT=TransferListWidget]
  • QBT_TR(Delete)QBT_TR[CONTEXT=TransferListWidget] QBT_TR(Delete)QBT_TR[CONTEXT=TransferListWidget]
  • + QBT_TR(Set location...)QBT_TR[CONTEXT=TransferListWidget] QBT_TR(Set location...)QBT_TR[CONTEXT=TransferListWidget] +
  • +
  • QBT_TR(Category)QBT_TR[CONTEXT=TransferListWidget] QBT_TR(Category)QBT_TR[CONTEXT=TransferListWidget]
    • diff --git a/src/webui/www/public/newcategory.html b/src/webui/www/public/newcategory.html index 19bc5987e..8e8eee583 100644 --- a/src/webui/www/public/newcategory.html +++ b/src/webui/www/public/newcategory.html @@ -65,7 +65,7 @@

      QBT_TR(Category)QBT_TR[CONTEXT=TransferListWidget]:

      -
      +
      diff --git a/src/webui/www/public/scripts/mocha-init.js b/src/webui/www/public/scripts/mocha-init.js index 3ca2e4f15..bd956e8e8 100644 --- a/src/webui/www/public/scripts/mocha-init.js +++ b/src/webui/www/public/scripts/mocha-init.js @@ -119,14 +119,14 @@ initializeWindows = function() { }; uploadLimitFN = function() { - var h = torrentsTable.selectedRowsIds(); - if (h.length) { - var hash = h[0]; + 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]", loadMethod: 'iframe', - contentURL: 'uploadlimit.html?hashes=' + h.join("|"), + contentURL: 'uploadlimit.html?hashes=' + hashes.join("|"), scrollbars: false, resizable: false, maximizable: false, @@ -139,13 +139,13 @@ initializeWindows = function() { }; toggleSequentialDownloadFN = function() { - var h = torrentsTable.selectedRowsIds(); - if (h.length) { + var hashes = torrentsTable.selectedRowsIds(); + if (hashes.length) { new Request({ url: 'command/toggleSequentialDownload', method: 'post', data: { - hashes: h.join("|") + hashes: hashes.join("|") } }).send(); updateMainData(); @@ -153,13 +153,13 @@ initializeWindows = function() { }; toggleFirstLastPiecePrioFN = function() { - var h = torrentsTable.selectedRowsIds(); - if (h.length) { + var hashes = torrentsTable.selectedRowsIds(); + if (hashes.length) { new Request({ url: 'command/toggleFirstLastPiecePrio', method: 'post', data: { - hashes: h.join("|") + hashes: hashes.join("|") } }).send(); updateMainData(); @@ -167,14 +167,14 @@ initializeWindows = function() { }; setSuperSeedingFN = function(val) { - var h = torrentsTable.selectedRowsIds(); - if (h.length) { + var hashes = torrentsTable.selectedRowsIds(); + if (hashes.length) { new Request({ url: 'command/setSuperSeeding', method: 'post', data: { value: val, - hashes: h.join("|") + hashes: hashes.join("|") } }).send(); updateMainData(); @@ -182,14 +182,14 @@ initializeWindows = function() { }; setForceStartFN = function() { - var h = torrentsTable.selectedRowsIds(); - if (h.length) { + var hashes = torrentsTable.selectedRowsIds(); + if (hashes.length) { new Request({ url: 'command/setForceStart', method: 'post', data: { value: 'true', - hashes: h.join("|") + hashes: hashes.join("|") } }).send(); updateMainData(); @@ -228,14 +228,14 @@ initializeWindows = function() { }; downloadLimitFN = function() { - var h = torrentsTable.selectedRowsIds(); - if (h.length) { - var hash = h[0]; + 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]", loadMethod: 'iframe', - contentURL: 'downloadlimit.html?hashes=' + h.join("|"), + contentURL: 'downloadlimit.html?hashes=' + hashes.join("|"), scrollbars: false, resizable: false, maximizable: false, @@ -248,13 +248,13 @@ initializeWindows = function() { }; deleteFN = function() { - var h = torrentsTable.selectedRowsIds(); - if (h.length) { + var hashes = torrentsTable.selectedRowsIds(); + if (hashes.length) { new MochaUI.Window({ id: 'confirmDeletionPage', title: "QBT_TR(Deletion confirmation)QBT_TR[CONTEXT=confirmDeletionDlg]", loadMethod: 'iframe', - contentURL: 'confirmdeletion.html?hashes=' + h.join("|"), + contentURL: 'confirmdeletion.html?hashes=' + hashes.join("|"), scrollbars: false, resizable: false, maximizable: false, @@ -272,9 +272,9 @@ initializeWindows = function() { }); pauseFN = function() { - var h = torrentsTable.selectedRowsIds(); - if (h.length) { - h.each(function(hash, index) { + var hashes = torrentsTable.selectedRowsIds(); + if (hashes.length) { + hashes.each(function(hash, index) { new Request({ url: 'command/pause', method: 'post', @@ -288,9 +288,9 @@ initializeWindows = function() { }; startFN = function() { - var h = torrentsTable.selectedRowsIds(); - if (h.length) { - h.each(function(hash, index) { + var hashes = torrentsTable.selectedRowsIds(); + if (hashes.length) { + hashes.each(function(hash, index) { new Request({ url: 'command/resume', method: 'post', @@ -304,9 +304,9 @@ initializeWindows = function() { }; recheckFN = function() { - var h = torrentsTable.selectedRowsIds(); - if (h.length) { - h.each(function(hash, index) { + var hashes = torrentsTable.selectedRowsIds(); + if (hashes.length) { + hashes.each(function(hash, index) { new Request({ url: 'command/recheck', method: 'post', @@ -319,14 +319,33 @@ initializeWindows = function() { } }; + setLocationFN = function() { + var hashes = torrentsTable.selectedRowsIds(); + if (hashes.length) { + new MochaUI.Window({ + id: 'setLocationPage', + title: "QBT_TR(Set location)QBT_TR[CONTEXT=TransferListWidget]", + loadMethod: 'iframe', + contentURL: 'setlocation.html?hashes=' + hashes.join('|'), + scrollbars: false, + resizable: false, + maximizable: false, + paddingVertical: 0, + paddingHorizontal: 0, + width: 250, + height: 100 + }); + } + }; + torrentNewCategoryFN = function () { - var h = torrentsTable.selectedRowsIds(); - if (h.length) { + var hashes = torrentsTable.selectedRowsIds(); + if (hashes.length) { new MochaUI.Window({ id: 'newCategoryPage', title: "QBT_TR(New Category)QBT_TR[CONTEXT=TransferListWidget]", loadMethod: 'iframe', - contentURL: 'newcategory.html?hashes=' + h.join('|'), + contentURL: 'newcategory.html?hashes=' + hashes.join('|'), scrollbars: false, resizable: false, maximizable: false, @@ -340,15 +359,15 @@ initializeWindows = function() { torrentSetCategoryFN = function (categoryHash) { var categoryName = ''; - if (categoryHash !== 0) + if (categoryHash != 0) categoryName = category_list[categoryHash].name; - var h = torrentsTable.selectedRowsIds(); - if (h.length) { + var hashes = torrentsTable.selectedRowsIds(); + if (hashes.length) { new Request({ url: 'command/setCategory', method: 'post', data: { - hashes: h.join("|"), + hashes: hashes.join("|"), category: categoryName } }).send(); @@ -401,9 +420,9 @@ initializeWindows = function() { }; startTorrentsByCategoryFN = function (categoryHash) { - var h = torrentsTable.getFilteredTorrentsHashes('all', categoryHash); - if (h.length) { - h.each(function (hash, index) { + var hashes = torrentsTable.getFilteredTorrentsHashes('all', categoryHash); + if (hashes.length) { + hashes.each(function (hash, index) { new Request({ url: 'command/resume', method: 'post', @@ -417,9 +436,9 @@ initializeWindows = function() { }; pauseTorrentsByCategoryFN = function (categoryHash) { - var h = torrentsTable.getFilteredTorrentsHashes('all', categoryHash); - if (h.length) { - h.each(function (hash, index) { + var hashes = torrentsTable.getFilteredTorrentsHashes('all', categoryHash); + if (hashes.length) { + hashes.each(function (hash, index) { new Request({ url: 'command/pause', method: 'post', @@ -433,13 +452,13 @@ initializeWindows = function() { }; deleteTorrentsByCategoryFN = function (categoryHash) { - var h = torrentsTable.getFilteredTorrentsHashes('all', categoryHash); - if (h.length) { + var hashes = torrentsTable.getFilteredTorrentsHashes('all', categoryHash); + if (hashes.length) { new MochaUI.Window({ id: 'confirmDeletionPage', title: "QBT_TR(Deletion confirmation)QBT_TR[CONTEXT=confirmDeletionDlg]", loadMethod: 'iframe', - contentURL: 'confirmdeletion.html?hashes=' + h.join("|"), + contentURL: 'confirmdeletion.html?hashes=' + hashes.join("|"), scrollbars: false, resizable: false, maximizable: false, @@ -494,9 +513,9 @@ initializeWindows = function() { ['pause', 'resume', 'recheck'].each(function(item) { addClickEvent(item, function(e) { new Event(e).stop(); - var h = torrentsTable.selectedRowsIds(); - if (h.length) { - h.each(function(hash, index) { + var hashes = torrentsTable.selectedRowsIds(); + if (hashes.length) { + hashes.each(function(hash, index) { new Request({ url: 'command/' + item, method: 'post', @@ -518,13 +537,13 @@ initializeWindows = function() { }); setPriorityFN = function(cmd) { - var h = torrentsTable.selectedRowsIds(); - if (h.length) { + var hashes = torrentsTable.selectedRowsIds(); + if (hashes.length) { new Request({ url: 'command/' + cmd, method: 'post', data: { - hashes: h.join("|") + hashes: hashes.join("|") } }).send(); updateMainData(); diff --git a/src/webui/www/public/setlocation.html b/src/webui/www/public/setlocation.html new file mode 100644 index 000000000..ddc08a231 --- /dev/null +++ b/src/webui/www/public/setlocation.html @@ -0,0 +1,55 @@ + + + + + QBT_TR(Set location)QBT_TR[CONTEXT=TransferListWidget] + + + + + + +
      +

      QBT_TR(Location)QBT_TR[CONTEXT=TransferListWidget]:

      + +
      + +
      +
      + + diff --git a/src/webui/www/public/transferlist.html b/src/webui/www/public/transferlist.html index e088e66d6..d28150441 100644 --- a/src/webui/www/public/transferlist.html +++ b/src/webui/www/public/transferlist.html @@ -22,9 +22,6 @@ targets : '.torrentsTableContextMenuTarget', menu : 'torrentsTableMenu', actions : { - Delete : function (element, ref) { - deleteFN(); - }, Start : function (element, ref) { startFN(); }, @@ -34,6 +31,15 @@ ForceStart : function (element, ref) { setForceStartFN(); }, + + Delete : function (element, ref) { + deleteFN(); + }, + + SetLocation : function (element, ref) { + setLocationFN(); + }, + prioTop : function (element, ref) { setPriorityFN('topPrio'); }, @@ -46,21 +52,25 @@ prioBottom : function (element, ref) { setPriorityFN('bottomPrio'); }, - ForceRecheck : function (element, ref) { - recheckFN(); + + DownloadLimit : function (element, ref) { + downloadLimitFN(); }, UploadLimit : function (element, ref) { uploadLimitFN(); }, - DownloadLimit : function (element, ref) { - downloadLimitFN(); - }, + SequentialDownload : function (element, ref) { toggleSequentialDownloadFN(); }, FirstLastPiecePrio : function (element, ref) { toggleFirstLastPiecePrioFN(); }, + + ForceRecheck : function (element, ref) { + recheckFN(); + }, + SuperSeeding : function (element, ref) { setSuperSeedingFN(!ref.getItemChecked('SuperSeeding')); }