Add "Copy name" option in right-click menu of torrent list

Implementation of feature request #2452
https://github.com/qbittorrent/qBittorrent/issues/2452

Adds a new option in the right-click menu of the torrent list to copy
the name(s) of selected torrent(s) to the clipboard. This is similar to
the existing option to copy the magnet links to the clipboard.

This patch was originally authored by Chris Hirst (ciaobaby). I changed
the item name from "Copy caption" to "Copy name" (the torrent list
column header says "Name"), and I added the missing line in the header
file.

Note: Translations are not updated for the English menu item "Copy
name".

Signed-off-by: ADTC <send2adtc@gmail.com>
This commit is contained in:
Chris Hirst 2015-02-01 21:52:36 +08:00 committed by ADTC
parent 2859856034
commit 91aad83cad
2 changed files with 19 additions and 0 deletions

View file

@ -424,6 +424,19 @@ void TransferListWidget::copySelectedMagnetURIs() const
qApp->clipboard()->setText(magnet_uris.join("\n"));
}
// create list of captions from tasklist.
void TransferListWidget::copySelectedCaptions() const
{
QStringList captions;
const QStringList hashes = getSelectedTorrentsHashes();
foreach (const QString &hash, hashes) {
const QTorrentHandle h = BTSession->getTorrentHandle(hash);
if (h.is_valid())
captions << h.name();
}
qApp->clipboard()->setText(captions.join("\n"));
}
void TransferListWidget::hidePriorityColumn(bool hide)
{
qDebug("hidePriorityColumn(%d)", hide);
@ -741,6 +754,10 @@ void TransferListWidget::displayListMenu(const QPoint&)
connect(&actionForce_recheck, SIGNAL(triggered()), this, SLOT(recheckSelectedTorrents()));
QAction actionCopy_magnet_link(QIcon(":/icons/magnet.png"), tr("Copy magnet link"), 0);
connect(&actionCopy_magnet_link, SIGNAL(triggered()), this, SLOT(copySelectedMagnetURIs()));
QAction actionCopy_caption_list(tr("Copy name"), 0);
connect(&actionCopy_caption_list, SIGNAL(triggered()), this, SLOT(copySelectedCaptions()));
QAction actionSuper_seeding_mode(tr("Super seeding mode"), 0);
actionSuper_seeding_mode.setCheckable(true);
connect(&actionSuper_seeding_mode, SIGNAL(triggered()), this, SLOT(toggleSelectedTorrentsSuperSeeding()));
@ -874,6 +891,7 @@ void TransferListWidget::displayListMenu(const QPoint&)
}
listMenu.addSeparator();
listMenu.addAction(&actionCopy_magnet_link);
listMenu.addAction(&actionCopy_caption_list);
// Call menu
QAction *act = 0;
act = listMenu.exec(QCursor::pos());

View file

@ -71,6 +71,7 @@ public slots:
void topPrioSelectedTorrents();
void bottomPrioSelectedTorrents();
void copySelectedMagnetURIs() const;
void copySelectedCaptions() const;
void openSelectedTorrentsFolder() const;
void recheckSelectedTorrents();
void setDlLimitSelectedTorrents();