From 91aad83cada39b262e19d7b231c19345e5ef292d Mon Sep 17 00:00:00 2001 From: Chris Hirst Date: Sun, 1 Feb 2015 21:52:36 +0800 Subject: [PATCH] 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 --- src/gui/transferlistwidget.cpp | 18 ++++++++++++++++++ src/gui/transferlistwidget.h | 1 + 2 files changed, 19 insertions(+) diff --git a/src/gui/transferlistwidget.cpp b/src/gui/transferlistwidget.cpp index 4fd03ee6a..a39b7d5bb 100644 --- a/src/gui/transferlistwidget.cpp +++ b/src/gui/transferlistwidget.cpp @@ -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()); diff --git a/src/gui/transferlistwidget.h b/src/gui/transferlistwidget.h index 5ce5793bc..4988d812c 100644 --- a/src/gui/transferlistwidget.h +++ b/src/gui/transferlistwidget.h @@ -71,6 +71,7 @@ public slots: void topPrioSelectedTorrents(); void bottomPrioSelectedTorrents(); void copySelectedMagnetURIs() const; + void copySelectedCaptions() const; void openSelectedTorrentsFolder() const; void recheckSelectedTorrents(); void setDlLimitSelectedTorrents();