mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-16 02:03:07 -07:00
- New peers can manually be added to a torrent
This commit is contained in:
parent
bb4dc84824
commit
94f3323270
10 changed files with 265 additions and 2 deletions
|
@ -34,10 +34,12 @@
|
|||
#include "preferences.h"
|
||||
#include "propertieswidget.h"
|
||||
#include "geoip.h"
|
||||
#include "peeraddition.h"
|
||||
#include <QStandardItemModel>
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <QSet>
|
||||
#include <QSettings>
|
||||
#include <QMenu>
|
||||
#include <vector>
|
||||
|
||||
PeerListWidget::PeerListWidget(PropertiesWidget *parent): properties(parent), display_flags(false) {
|
||||
|
@ -59,6 +61,9 @@ PeerListWidget::PeerListWidget(PropertiesWidget *parent): properties(parent), di
|
|||
proxyModel->setDynamicSortFilter(true);
|
||||
proxyModel->setSourceModel(listModel);
|
||||
setModel(proxyModel);
|
||||
// Context menu
|
||||
setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showPeerListMenu(QPoint)));
|
||||
// List delegate
|
||||
listDelegate = new PeerListDelegate(this);
|
||||
setItemDelegate(listDelegate);
|
||||
|
@ -104,6 +109,27 @@ void PeerListWidget::updatePeerCountryResolutionState() {
|
|||
}
|
||||
}
|
||||
|
||||
void PeerListWidget::showPeerListMenu(QPoint) {
|
||||
QMenu menu;
|
||||
QTorrentHandle h = properties->getCurrentTorrent();
|
||||
if(!h.is_valid()) return;
|
||||
QAction *addPeerAct = 0;
|
||||
if(!h.is_queued() && !h.is_checking()) {
|
||||
addPeerAct = menu.addAction(QIcon(":/Icons/oxygen/add_peer.png"), "Add a new peer");
|
||||
}
|
||||
QAction *act = menu.exec(QCursor::pos());
|
||||
if(act == addPeerAct) {
|
||||
boost::asio::ip::tcp::endpoint ep = PeerAdditionDlg::askForPeerEndpoint();
|
||||
if(ep != boost::asio::ip::tcp::endpoint()) {
|
||||
h.connect_peer(ep);
|
||||
QMessageBox::information(0, tr("Peer addition"), tr("The peer was added to this torrent."));
|
||||
} else {
|
||||
qDebug("No peer was added");
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void PeerListWidget::clear() {
|
||||
qDebug("clearing peer list");
|
||||
peerItems.clear();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue