mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-10 15:32:48 -07:00
Provide v1 and v2 infohashes in UI (#15097)
This commit is contained in:
parent
f6eb29d800
commit
37f227ae74
24 changed files with 285 additions and 106 deletions
|
@ -487,7 +487,33 @@ void TransferListWidget::copySelectedNames() const
|
|||
qApp->clipboard()->setText(torrentNames.join('\n'));
|
||||
}
|
||||
|
||||
void TransferListWidget::copySelectedHashes() const
|
||||
void TransferListWidget::copySelectedInfohashes(const CopyInfohashPolicy policy) const
|
||||
{
|
||||
const auto selectedTorrents = getSelectedTorrents();
|
||||
QStringList infoHashes;
|
||||
infoHashes.reserve(selectedTorrents.size());
|
||||
switch (policy)
|
||||
{
|
||||
case CopyInfohashPolicy::Version1:
|
||||
for (const BitTorrent::Torrent *torrent : selectedTorrents)
|
||||
{
|
||||
if (const auto infoHash = torrent->infoHash().v1(); infoHash.isValid())
|
||||
infoHashes << infoHash.toString();
|
||||
}
|
||||
break;
|
||||
case CopyInfohashPolicy::Version2:
|
||||
for (const BitTorrent::Torrent *torrent : selectedTorrents)
|
||||
{
|
||||
if (const auto infoHash = torrent->infoHash().v2(); infoHash.isValid())
|
||||
infoHashes << infoHash.toString();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
qApp->clipboard()->setText(infoHashes.join('\n'));
|
||||
}
|
||||
|
||||
void TransferListWidget::copySelectedIDs() const
|
||||
{
|
||||
QStringList torrentIDs;
|
||||
for (BitTorrent::Torrent *const torrent : asConst(getSelectedTorrents()))
|
||||
|
@ -827,10 +853,14 @@ void TransferListWidget::displayListMenu(const QPoint &)
|
|||
connect(actionForceReannounce, &QAction::triggered, this, &TransferListWidget::reannounceSelectedTorrents);
|
||||
auto *actionCopyMagnetLink = new QAction(UIThemeManager::instance()->getIcon("kt-magnet"), tr("Magnet link"), listMenu);
|
||||
connect(actionCopyMagnetLink, &QAction::triggered, this, &TransferListWidget::copySelectedMagnetURIs);
|
||||
auto *actionCopyID = new QAction(UIThemeManager::instance()->getIcon("edit-copy"), tr("Torrent ID"), listMenu);
|
||||
connect(actionCopyID, &QAction::triggered, this, &TransferListWidget::copySelectedIDs);
|
||||
auto *actionCopyName = new QAction(UIThemeManager::instance()->getIcon("edit-copy"), tr("Name"), listMenu);
|
||||
connect(actionCopyName, &QAction::triggered, this, &TransferListWidget::copySelectedNames);
|
||||
auto *actionCopyHash = new QAction(UIThemeManager::instance()->getIcon("edit-copy"), tr("Hash"), listMenu);
|
||||
connect(actionCopyHash, &QAction::triggered, this, &TransferListWidget::copySelectedHashes);
|
||||
auto *actionCopyHash1 = new QAction(UIThemeManager::instance()->getIcon("edit-copy"), tr("Info hash v1"), listMenu);
|
||||
connect(actionCopyHash1, &QAction::triggered, this, [this]() { copySelectedInfohashes(CopyInfohashPolicy::Version1); });
|
||||
auto *actionCopyHash2 = new QAction(UIThemeManager::instance()->getIcon("edit-copy"), tr("Info hash v2"), listMenu);
|
||||
connect(actionCopyHash2, &QAction::triggered, this, [this]() { copySelectedInfohashes(CopyInfohashPolicy::Version2); });
|
||||
auto *actionSuperSeedingMode = new TriStateAction(tr("Super seeding mode"), listMenu);
|
||||
connect(actionSuperSeedingMode, &QAction::triggered, this, &TransferListWidget::setSelectedTorrentsSuperSeeding);
|
||||
auto *actionRename = new QAction(UIThemeManager::instance()->getIcon("edit-rename"), tr("Rename..."), listMenu);
|
||||
|
@ -860,6 +890,7 @@ void TransferListWidget::displayListMenu(const QPoint &)
|
|||
bool first = true;
|
||||
TagSet tagsInAny;
|
||||
TagSet tagsInAll;
|
||||
bool hasInfohashV1 = false, hasInfohashV2 = false;
|
||||
|
||||
for (const QModelIndex &index : selectedIndexes)
|
||||
{
|
||||
|
@ -939,12 +970,18 @@ void TransferListWidget::displayListMenu(const QPoint &)
|
|||
if (torrent->hasMetadata())
|
||||
needsPreview = true;
|
||||
|
||||
if (!hasInfohashV1 && torrent->infoHash().v1().isValid())
|
||||
hasInfohashV1 = true;
|
||||
if (!hasInfohashV2 && torrent->infoHash().v2().isValid())
|
||||
hasInfohashV2 = true;
|
||||
|
||||
first = false;
|
||||
|
||||
if (oneHasMetadata && oneNotSeed && !allSameSequentialDownloadMode
|
||||
&& !allSamePrioFirstlast && !allSameSuperSeeding && !allSameCategory
|
||||
&& needsStart && needsForce && needsPause && needsPreview && !allSameAutoTMM)
|
||||
{
|
||||
&& needsStart && needsForce && needsPause && needsPreview && !allSameAutoTMM
|
||||
&& hasInfohashV1 && hasInfohashV2)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1084,8 +1121,12 @@ void TransferListWidget::displayListMenu(const QPoint &)
|
|||
QMenu *copySubMenu = listMenu->addMenu(
|
||||
UIThemeManager::instance()->getIcon("edit-copy"), tr("Copy"));
|
||||
copySubMenu->addAction(actionCopyName);
|
||||
copySubMenu->addAction(actionCopyHash);
|
||||
copySubMenu->addAction(actionCopyHash1);
|
||||
actionCopyHash1->setEnabled(hasInfohashV1);
|
||||
copySubMenu->addAction(actionCopyHash2);
|
||||
actionCopyHash2->setEnabled(hasInfohashV2);
|
||||
copySubMenu->addAction(actionCopyMagnetLink);
|
||||
copySubMenu->addAction(actionCopyID);
|
||||
|
||||
listMenu->popup(QCursor::pos());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue