mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-01-04 14:42:29 -06:00
Add copy comment functionality to the torrent list's context menu
PR #19846. Closes #18890.
This commit is contained in:
@@ -160,6 +160,7 @@ QVariantMap serialize(const BitTorrent::Torrent &torrent)
|
||||
{KEY_TORRENT_LAST_ACTIVITY_TIME, getLastActivityTime()},
|
||||
{KEY_TORRENT_AVAILABILITY, torrent.distributedCopies()},
|
||||
{KEY_TORRENT_REANNOUNCE, torrent.nextAnnounce()},
|
||||
{KEY_TORRENT_COMMENT, torrent.comment()},
|
||||
|
||||
{KEY_TORRENT_TOTAL_SIZE, torrent.totalSize()}
|
||||
};
|
||||
|
||||
@@ -91,5 +91,6 @@ inline const QString KEY_TORRENT_TIME_ACTIVE = u"time_active"_s;
|
||||
inline const QString KEY_TORRENT_SEEDING_TIME = u"seeding_time"_s;
|
||||
inline const QString KEY_TORRENT_AVAILABILITY = u"availability"_s;
|
||||
inline const QString KEY_TORRENT_REANNOUNCE = u"reannounce"_s;
|
||||
inline const QString KEY_TORRENT_COMMENT = u"comment"_s;
|
||||
|
||||
QVariantMap serialize(const BitTorrent::Torrent &torrent);
|
||||
|
||||
@@ -180,6 +180,7 @@
|
||||
<li><a href="#" id="copyInfohash2" class="copyToClipboard"><img src="images/hash.svg" alt="QBT_TR(Info hash v2)QBT_TR[CONTEXT=TransferListWidget]" /> QBT_TR(Info hash v2)QBT_TR[CONTEXT=TransferListWidget]</a></li>
|
||||
<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>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
|
||||
@@ -1528,6 +1528,8 @@ function setupCopyEventHandler() {
|
||||
return copyMagnetLinkFN();
|
||||
case "copyID":
|
||||
return copyIdFN();
|
||||
case "copyComment":
|
||||
return copyCommentFN();
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -89,6 +89,7 @@ let copyNameFN = function() {};
|
||||
let copyInfohashFN = function(policy) {};
|
||||
let copyMagnetLinkFN = function() {};
|
||||
let copyIdFN = function() {};
|
||||
let copyCommentFN = function() {};
|
||||
let setQueuePositionFN = function() {};
|
||||
let exportTorrentFN = function() {};
|
||||
|
||||
@@ -1005,6 +1006,21 @@ const initializeWindows = function() {
|
||||
return torrentsTable.selectedRowsIds().join("\n");
|
||||
};
|
||||
|
||||
copyCommentFN = function() {
|
||||
const selectedRows = torrentsTable.selectedRowsIds();
|
||||
const comments = [];
|
||||
if (selectedRows.length > 0) {
|
||||
const rows = torrentsTable.getFilteredAndSortedRows();
|
||||
for (let i = 0; i < selectedRows.length; ++i) {
|
||||
const hash = selectedRows[i];
|
||||
const comment = rows[hash].full_data.comment;
|
||||
if (comment && (comment !== ""))
|
||||
comments.push(comment);
|
||||
}
|
||||
}
|
||||
return comments.join("\n---------\n");
|
||||
};
|
||||
|
||||
exportTorrentFN = async function() {
|
||||
const hashes = torrentsTable.selectedRowsIds();
|
||||
for (const hash of hashes) {
|
||||
|
||||
Reference in New Issue
Block a user