diff --git a/src/gui/transferlistwidget.cpp b/src/gui/transferlistwidget.cpp index b2ed64ee7..745deaad2 100644 --- a/src/gui/transferlistwidget.cpp +++ b/src/gui/transferlistwidget.cpp @@ -525,6 +525,19 @@ void TransferListWidget::copySelectedNames() const qApp->clipboard()->setText(torrentNames.join(u'\n')); } +void TransferListWidget::copyContentPaths() const +{ + QStringList contentPaths; + for (BitTorrent::Torrent *const torrent : asConst(getSelectedTorrents())) + { + const Path contentPath = torrent->contentPath(); + if (!contentPath.isEmpty()) + contentPaths << contentPath.toString(); + } + + qApp->clipboard()->setText(contentPaths.join(u'\n')); +} + void TransferListWidget::copySelectedInfohashes(const CopyInfohashPolicy policy) const { const auto selectedTorrents = getSelectedTorrents(); @@ -1000,6 +1013,8 @@ void TransferListWidget::displayListMenu() connect(actionCopyHash1, &QAction::triggered, this, [this]() { copySelectedInfohashes(CopyInfohashPolicy::Version1); }); auto *actionCopyHash2 = new QAction(UIThemeManager::instance()->getIcon(u"hash"_s, u"edit-copy"_s), tr("Info h&ash v2"), listMenu); connect(actionCopyHash2, &QAction::triggered, this, [this]() { copySelectedInfohashes(CopyInfohashPolicy::Version2); }); + auto *actionCopyContentPath = new QAction(UIThemeManager::instance()->getIcon(u"directory"_s, u"edit-copy"_s), tr("Content &Path"), listMenu); + connect(actionCopyContentPath, &QAction::triggered, this, &TransferListWidget::copyContentPaths); auto *actionSuperSeedingMode = new TriStateAction(tr("Super seeding mode"), listMenu); connect(actionSuperSeedingMode, &QAction::triggered, this, &TransferListWidget::setSelectedTorrentsSuperSeeding); auto *actionRename = new QAction(UIThemeManager::instance()->getIcon(u"edit-rename"_s), tr("Re&name..."), listMenu); @@ -1282,6 +1297,7 @@ void TransferListWidget::displayListMenu() copySubMenu->addAction(actionCopyMagnetLink); copySubMenu->addAction(actionCopyID); copySubMenu->addAction(actionCopyComment); + copySubMenu->addAction(actionCopyContentPath); actionExportTorrent->setToolTip(tr("Exported torrent is not necessarily the same as the imported")); listMenu->addAction(actionExportTorrent); diff --git a/src/gui/transferlistwidget.h b/src/gui/transferlistwidget.h index 097dd809a..f1bbf4141 100644 --- a/src/gui/transferlistwidget.h +++ b/src/gui/transferlistwidget.h @@ -85,6 +85,7 @@ public slots: void bottomQueuePosSelectedTorrents(); void copySelectedMagnetURIs() const; void copySelectedNames() const; + void copyContentPaths() const; void copySelectedInfohashes(CopyInfohashPolicy policy) const; void copySelectedIDs() const; void copySelectedComments() const; diff --git a/src/webui/www/private/index.html b/src/webui/www/private/index.html index b5877abc4..3a97b49ef 100644 --- a/src/webui/www/private/index.html +++ b/src/webui/www/private/index.html @@ -219,6 +219,7 @@
  • QBT_TR(Magnet link)QBT_TR[CONTEXT=TransferListWidget] QBT_TR(Magnet link)QBT_TR[CONTEXT=TransferListWidget]
  • QBT_TR(Torrent ID)QBT_TR[CONTEXT=TransferListWidget] QBT_TR(Torrent ID)QBT_TR[CONTEXT=TransferListWidget]
  • QBT_TR(Comment)QBT_TR[CONTEXT=TransferListWidget] QBT_TR(Comment)QBT_TR[CONTEXT=TransferListWidget]
  • +
  • QBT_TR(Content Path)QBT_TR[CONTEXT=TransferListWidget] QBT_TR(Content Path)QBT_TR[CONTEXT=TransferListWidget]
  • diff --git a/src/webui/www/private/scripts/client.js b/src/webui/www/private/scripts/client.js index 6e3144111..3aecd3409 100644 --- a/src/webui/www/private/scripts/client.js +++ b/src/webui/www/private/scripts/client.js @@ -1886,6 +1886,9 @@ window.addEventListener("DOMContentLoaded", (event) => { case "copyComment": setupClickEvent(copyCommentFN); break; + case "copyContentPath": + setupClickEvent(copyContentPathFN); + break; } } diff --git a/src/webui/www/private/scripts/mocha-init.js b/src/webui/www/private/scripts/mocha-init.js index e3d1300c3..3665a6ebc 100644 --- a/src/webui/www/private/scripts/mocha-init.js +++ b/src/webui/www/private/scripts/mocha-init.js @@ -153,6 +153,7 @@ let copyInfohashFN = (policy) => {}; let copyMagnetLinkFN = () => {}; let copyIdFN = () => {}; let copyCommentFN = () => {}; +let copyContentPathFN = () => {}; let setQueuePositionFN = () => {}; let exportTorrentFN = () => {}; @@ -1219,6 +1220,20 @@ const initializeWindows = () => { return comments.join("\n---------\n"); }; + copyContentPathFN = () => { + const selectedRows = torrentsTable.selectedRowsIds(); + const contentPaths = []; + if (selectedRows.length > 0) { + const rows = torrentsTable.getFilteredAndSortedRows(); + for (const hash of selectedRows) { + const contentPath = rows[hash].full_data.content_path; + if ((contentPath !== null) && (contentPath.length > 0)) + contentPaths.push(contentPath); + } + } + return contentPaths.join("\n"); + }; + exportTorrentFN = async () => { const hashes = torrentsTable.selectedRowsIds(); for (const hash of hashes) {