Allow to copy content paths of selected torrents

Closes #23227.
PR #23239.

---------

Co-authored-by: Chocobo1 <Chocobo1@users.noreply.github.com>
This commit is contained in:
Mark Yu
2025-09-14 04:42:59 -04:00
committed by GitHub
parent 919520b4c3
commit 8e14541236
5 changed files with 36 additions and 0 deletions

View File

@@ -219,6 +219,7 @@
<li><a href="#" id="copyMagnetLink" class="copyToClipboard"><img src="images/torrent-magnet.svg" alt="QBT_TR(Magnet link)QBT_TR[CONTEXT=TransferListWidget]"> QBT_TR(Magnet link)QBT_TR[CONTEXT=TransferListWidget]</a></li>
<li><a href="#" id="copyID" class="copyToClipboard"><img src="images/help-about.svg" alt="QBT_TR(Torrent ID)QBT_TR[CONTEXT=TransferListWidget]"> QBT_TR(Torrent ID)QBT_TR[CONTEXT=TransferListWidget]</a></li>
<li><a href="#" id="copyComment" class="copyToClipboard"><img src="images/edit-copy.svg" alt="QBT_TR(Comment)QBT_TR[CONTEXT=TransferListWidget]"> QBT_TR(Comment)QBT_TR[CONTEXT=TransferListWidget]</a></li>
<li><a href="#" id="copyContentPath" class="copyToClipboard"><img src="images/directory.svg" alt="QBT_TR(Content Path)QBT_TR[CONTEXT=TransferListWidget]"> QBT_TR(Content Path)QBT_TR[CONTEXT=TransferListWidget]</a></li>
</ul>
</li>
<li>

View File

@@ -1886,6 +1886,9 @@ window.addEventListener("DOMContentLoaded", (event) => {
case "copyComment":
setupClickEvent(copyCommentFN);
break;
case "copyContentPath":
setupClickEvent(copyContentPathFN);
break;
}
}

View File

@@ -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) {