From 6d6219bdf86e2f2e75d8f3f76b1a8f22e8cbaa12 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Tue, 30 Mar 2021 09:15:55 +0300 Subject: [PATCH] qt: Add "Copy address" item to the context menu in the Peers table --- src/qt/peertablemodel.cpp | 19 ++++++++++++++++++- src/qt/rpcconsole.cpp | 4 ++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/qt/peertablemodel.cpp b/src/qt/peertablemodel.cpp index 6c4e3260119..354e4c05376 100644 --- a/src/qt/peertablemodel.cpp +++ b/src/qt/peertablemodel.cpp @@ -146,7 +146,24 @@ QVariant PeerTableModel::data(const QModelIndex &index, int role) const } // no default case, so the compiler can warn about missing cases assert(false); } else if (role == StatsRole) { - return QVariant::fromValue(rec); + switch (index.column()) { + case NetNodeId: + return QVariant::fromValue(rec); + case Address: + return QString::fromStdString(rec->nodeStats.addrName); + case ConnectionType: + [[fallthrough]]; + case Network: + [[fallthrough]]; + case Ping: + [[fallthrough]]; + case Sent: + [[fallthrough]]; + case Received: + [[fallthrough]]; + case Subversion: + return {}; + } // no default case, so the compiler can warn about missing cases } return QVariant(); diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp index 006f60e7a1c..8f37ba6b319 100644 --- a/src/qt/rpcconsole.cpp +++ b/src/qt/rpcconsole.cpp @@ -619,6 +619,10 @@ void RPCConsole::setClientModel(ClientModel *model, int bestblock_height, int64_ // create peer table context menu peersTableContextMenu = new QMenu(this); + peersTableContextMenu->addAction(tr("Copy address"), [this] { + GUIUtil::copyEntryData(ui->peerWidget, PeerTableModel::Address, PeerTableModel::StatsRole); + }); + peersTableContextMenu->addSeparator(); peersTableContextMenu->addAction(tr("Disconnect"), this, &RPCConsole::disconnectSelectedNode); peersTableContextMenu->addAction(ts.ban_for + " " + tr("1 hour"), [this] { banSelectedNode(60 * 60); }); peersTableContextMenu->addAction(ts.ban_for + " " + tr("1 day"), [this] { banSelectedNode(60 * 60 * 24); });