aboutsummaryrefslogtreecommitdiff
path: root/src/qt/rpcconsole.cpp
diff options
context:
space:
mode:
authorRoss Nicoll <[email protected]>2021-06-08 19:11:30 +0100
committerGitHub <[email protected]>2021-06-08 19:11:30 +0100
commit51aca8e38dfcc67845538b68773d699219490703 (patch)
tree1fd5e78e1b6a3a2c3356b3e388d76dd2890ea2f8 /src/qt/rpcconsole.cpp
parentMerge pull request #2243 from chromatic/add-sortable-network-stats-to-peers-t... (diff)
parentAdd a form dialog for adding peers (diff)
downloaddiscoin-51aca8e38dfcc67845538b68773d699219490703.tar.xz
discoin-51aca8e38dfcc67845538b68773d699219490703.zip
Merge pull request #1825 from alamshafil/master
[QT] Add a form dialog for adding peers
Diffstat (limited to 'src/qt/rpcconsole.cpp')
-rw-r--r--src/qt/rpcconsole.cpp61
1 files changed, 61 insertions, 0 deletions
diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp
index 7bf01c906..dacbeacdf 100644
--- a/src/qt/rpcconsole.cpp
+++ b/src/qt/rpcconsole.cpp
@@ -2,11 +2,13 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+#include "bitcoingui.h"
#if defined(HAVE_CONFIG_H)
#include "config/bitcoin-config.h"
#endif
#include "rpcconsole.h"
+#include "peerdialog.h"
#include "ui_debugwindow.h"
#include "bantablemodel.h"
@@ -14,6 +16,7 @@
#include "guiutil.h"
#include "platformstyle.h"
#include "bantablemodel.h"
+#include "utilitydialog.h"
#include "chainparams.h"
#include "netbase.h"
@@ -39,6 +42,7 @@
#include <QTime>
#include <QTimer>
#include <QStringList>
+#include <QThread>
#if QT_VERSION < 0x050000
#include <QUrl>
@@ -441,6 +445,15 @@ RPCConsole::RPCConsole(const PlatformStyle *_platformStyle, QWidget *parent) :
connect(ui->fontSmallerButton, SIGNAL(clicked()), this, SLOT(fontSmaller()));
connect(ui->btnClearTrafficGraph, SIGNAL(clicked()), ui->trafficGraph, SLOT(clear()));
+ // Allow user to add new peer
+ connect(ui->peerAdd, SIGNAL(clicked()), this, SLOT(on_addPeer_clicked()));
+
+ // Allow user to remove peer
+ connect(ui->peerRemove, SIGNAL(clicked()), this, SLOT(on_removePeer_clicked()));
+
+ // Allow user to test peer
+ connect(ui->peerTest, SIGNAL(clicked()), this, SLOT(on_testPeer_clicked()));
+
// set library version labels
#ifdef ENABLE_WALLET
ui->berkeleyDBVersion->setText(DbEnv::version(0, 0, 0));
@@ -910,6 +923,54 @@ void RPCConsole::on_openDebugLogfileButton_clicked()
GUIUtil::openDebugLogfile();
}
+void RPCConsole::on_addPeer_clicked()
+{
+
+ QWidget *win = new AddPeerDialog(0);
+
+ win->showNormal();
+ win->show();
+ win->raise();
+ win->activateWindow();
+
+ /** Center window */
+ const QPoint global = ui->tabWidget->mapToGlobal(ui->tabWidget->rect().center());
+ win->move(global.x() - win->width() / 2, global.y() - win->height() / 2);
+}
+
+void RPCConsole::on_removePeer_clicked()
+{
+ QList<QModelIndex> ips = GUIUtil::getEntryData(ui->peerWidget, PeerTableModel::Address);
+
+ if(ips.size() != 0)
+ {
+ QString address = ips[0].data().toString();
+
+ if(QMessageBox::Yes == QMessageBox::question(this, "Remove Peer", "Are you sure you want to remove the peer: " + address + "?", QMessageBox::Yes | QMessageBox::No))
+ {
+ QMessageBox::information(this, "Remove Peer", PeerTools::ManagePeer("remove", address), QMessageBox::Ok, QMessageBox::Ok);
+ }
+
+ } else
+ {
+ QMessageBox::information(this, "Remove Peer", "No peer was selected.", QMessageBox::Ok, QMessageBox::Ok);
+ }
+}
+
+void RPCConsole::on_testPeer_clicked()
+{
+ QWidget *win = new TestPeerDialog(0);
+
+ win->showNormal();
+ win->show();
+ win->raise();
+ win->activateWindow();
+
+ /** Center window */
+ const QPoint global = ui->tabWidget->mapToGlobal(ui->tabWidget->rect().center());
+ win->move(global.x() - win->width() / 2, global.y() - win->height() / 2);
+}
+
void RPCConsole::scrollToEnd()
{
QScrollBar *scrollbar = ui->messagesWidget->verticalScrollBar();