mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-17 14:08:03 -06:00
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:
@@ -525,6 +525,19 @@ void TransferListWidget::copySelectedNames() const
|
|||||||
qApp->clipboard()->setText(torrentNames.join(u'\n'));
|
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
|
void TransferListWidget::copySelectedInfohashes(const CopyInfohashPolicy policy) const
|
||||||
{
|
{
|
||||||
const auto selectedTorrents = getSelectedTorrents();
|
const auto selectedTorrents = getSelectedTorrents();
|
||||||
@@ -1000,6 +1013,8 @@ void TransferListWidget::displayListMenu()
|
|||||||
connect(actionCopyHash1, &QAction::triggered, this, [this]() { copySelectedInfohashes(CopyInfohashPolicy::Version1); });
|
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);
|
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); });
|
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);
|
auto *actionSuperSeedingMode = new TriStateAction(tr("Super seeding mode"), listMenu);
|
||||||
connect(actionSuperSeedingMode, &QAction::triggered, this, &TransferListWidget::setSelectedTorrentsSuperSeeding);
|
connect(actionSuperSeedingMode, &QAction::triggered, this, &TransferListWidget::setSelectedTorrentsSuperSeeding);
|
||||||
auto *actionRename = new QAction(UIThemeManager::instance()->getIcon(u"edit-rename"_s), tr("Re&name..."), listMenu);
|
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(actionCopyMagnetLink);
|
||||||
copySubMenu->addAction(actionCopyID);
|
copySubMenu->addAction(actionCopyID);
|
||||||
copySubMenu->addAction(actionCopyComment);
|
copySubMenu->addAction(actionCopyComment);
|
||||||
|
copySubMenu->addAction(actionCopyContentPath);
|
||||||
|
|
||||||
actionExportTorrent->setToolTip(tr("Exported torrent is not necessarily the same as the imported"));
|
actionExportTorrent->setToolTip(tr("Exported torrent is not necessarily the same as the imported"));
|
||||||
listMenu->addAction(actionExportTorrent);
|
listMenu->addAction(actionExportTorrent);
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ public slots:
|
|||||||
void bottomQueuePosSelectedTorrents();
|
void bottomQueuePosSelectedTorrents();
|
||||||
void copySelectedMagnetURIs() const;
|
void copySelectedMagnetURIs() const;
|
||||||
void copySelectedNames() const;
|
void copySelectedNames() const;
|
||||||
|
void copyContentPaths() const;
|
||||||
void copySelectedInfohashes(CopyInfohashPolicy policy) const;
|
void copySelectedInfohashes(CopyInfohashPolicy policy) const;
|
||||||
void copySelectedIDs() const;
|
void copySelectedIDs() const;
|
||||||
void copySelectedComments() const;
|
void copySelectedComments() const;
|
||||||
|
|||||||
@@ -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="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="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="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>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
|
|||||||
@@ -1886,6 +1886,9 @@ window.addEventListener("DOMContentLoaded", (event) => {
|
|||||||
case "copyComment":
|
case "copyComment":
|
||||||
setupClickEvent(copyCommentFN);
|
setupClickEvent(copyCommentFN);
|
||||||
break;
|
break;
|
||||||
|
case "copyContentPath":
|
||||||
|
setupClickEvent(copyContentPathFN);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -153,6 +153,7 @@ let copyInfohashFN = (policy) => {};
|
|||||||
let copyMagnetLinkFN = () => {};
|
let copyMagnetLinkFN = () => {};
|
||||||
let copyIdFN = () => {};
|
let copyIdFN = () => {};
|
||||||
let copyCommentFN = () => {};
|
let copyCommentFN = () => {};
|
||||||
|
let copyContentPathFN = () => {};
|
||||||
let setQueuePositionFN = () => {};
|
let setQueuePositionFN = () => {};
|
||||||
let exportTorrentFN = () => {};
|
let exportTorrentFN = () => {};
|
||||||
|
|
||||||
@@ -1219,6 +1220,20 @@ const initializeWindows = () => {
|
|||||||
return comments.join("\n---------\n");
|
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 () => {
|
exportTorrentFN = async () => {
|
||||||
const hashes = torrentsTable.selectedRowsIds();
|
const hashes = torrentsTable.selectedRowsIds();
|
||||||
for (const hash of hashes) {
|
for (const hash of hashes) {
|
||||||
|
|||||||
Reference in New Issue
Block a user