mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-03-10 20:31:47 +00:00
Add feature: copy tracker URL
This commit is contained in:
parent
c82174de6b
commit
d85ff9e088
@ -297,6 +297,28 @@ void TrackerList::askForTrackers() {
|
||||
}
|
||||
}
|
||||
|
||||
// Copy tracker URL to clipboard
|
||||
void TrackerList::copyTrackerUrl() {
|
||||
qDebug()<<"Copy tracker URL to clipboard";
|
||||
QTorrentHandle h = properties->getCurrentTorrent();
|
||||
if (!h.is_valid()) {
|
||||
clear();
|
||||
return;
|
||||
}
|
||||
QList<QTreeWidgetItem *> selected_items = getSelectedTrackerItems();
|
||||
if (selected_items.isEmpty()) return;
|
||||
QString urls_to_copy;
|
||||
foreach (QTreeWidgetItem *item, selected_items) {
|
||||
QString tracker_url = item->data(COL_URL, Qt::DisplayRole).toString();
|
||||
qDebug()<<QString("Copy ")+tracker_url;
|
||||
urls_to_copy += tracker_url/*.prepend(QString(" "))*/;
|
||||
delete item;
|
||||
}
|
||||
QApplication::clipboard()->setText(urls_to_copy);
|
||||
qDebug()<<"Tracker URL copied clipboard!";
|
||||
}
|
||||
|
||||
|
||||
void TrackerList::deleteSelectedTrackers() {
|
||||
QTorrentHandle h = properties->getCurrentTorrent();
|
||||
if (!h.is_valid()) {
|
||||
@ -336,6 +358,7 @@ void TrackerList::showTrackerListMenu(QPoint) {
|
||||
QMenu menu;
|
||||
// Add actions
|
||||
QAction *addAct = menu.addAction(IconProvider::instance()->getIcon("list-add"), tr("Add a new tracker..."));
|
||||
QAction *copyAct = menu.addAction(IconProvider::instance()->getIcon("list-add"), tr("Copy tracker url..."));
|
||||
QAction *delAct = 0;
|
||||
if (!getSelectedTrackerItems().isEmpty()) {
|
||||
delAct = menu.addAction(IconProvider::instance()->getIcon("list-remove"), tr("Remove tracker"));
|
||||
@ -348,6 +371,10 @@ void TrackerList::showTrackerListMenu(QPoint) {
|
||||
askForTrackers();
|
||||
return;
|
||||
}
|
||||
if (act == copyAct) {
|
||||
copyTrackerUrl();
|
||||
return;
|
||||
}
|
||||
if (act == delAct) {
|
||||
deleteSelectedTrackers();
|
||||
return;
|
||||
|
@ -33,6 +33,7 @@
|
||||
|
||||
#include <QTreeWidget>
|
||||
#include <QList>
|
||||
#include <QClipboard>
|
||||
|
||||
#include <libtorrent/version.hpp>
|
||||
#include "qtorrenthandle.h"
|
||||
@ -69,6 +70,7 @@ public slots:
|
||||
void loadStickyItems(const QTorrentHandle &h);
|
||||
void loadTrackers();
|
||||
void askForTrackers();
|
||||
void copyTrackerUrl();
|
||||
void deleteSelectedTrackers();
|
||||
void showTrackerListMenu(QPoint);
|
||||
void loadSettings();
|
||||
|
Loading…
x
Reference in New Issue
Block a user