aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/qt/rpcconsole.cpp27
-rw-r--r--src/qt/rpcconsole.h5
2 files changed, 26 insertions, 6 deletions
diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp
index 548b8cb34d..fd96f0f82d 100644
--- a/src/qt/rpcconsole.cpp
+++ b/src/qt/rpcconsole.cpp
@@ -469,6 +469,9 @@ RPCConsole::RPCConsole(interfaces::Node& node, const PlatformStyle *_platformSty
ui->splitter->restoreState(settings.value("RPCConsoleWidgetPeersTabSplitterSizes").toByteArray());
}
+ m_peer_widget_header_state = settings.value("PeersTabPeerHeaderState").toByteArray();
+ m_banlist_widget_header_state = settings.value("PeersTabBanlistHeaderState").toByteArray();
+
constexpr QChar nonbreaking_hyphen(8209);
const std::vector<QString> CONNECTION_TYPE_DOC{
tr("Inbound: initiated by peer"),
@@ -552,6 +555,9 @@ RPCConsole::~RPCConsole()
settings.setValue("RPCConsoleWidgetPeersTabSplitterSizes", ui->splitter->saveState());
}
+ settings.setValue("PeersTabPeerHeaderState", m_peer_widget_header_state);
+ settings.setValue("PeersTabBanlistHeaderState", m_banlist_widget_header_state);
+
m_node.rpcUnsetTimerInterface(rpcTimerInterface);
delete rpcTimerInterface;
delete ui;
@@ -640,9 +646,12 @@ void RPCConsole::setClientModel(ClientModel *model, int bestblock_height, int64_
ui->peerWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
ui->peerWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
ui->peerWidget->setContextMenuPolicy(Qt::CustomContextMenu);
- ui->peerWidget->setColumnWidth(PeerTableModel::Address, ADDRESS_COLUMN_WIDTH);
- ui->peerWidget->setColumnWidth(PeerTableModel::Subversion, SUBVERSION_COLUMN_WIDTH);
- ui->peerWidget->setColumnWidth(PeerTableModel::Ping, PING_COLUMN_WIDTH);
+
+ if (!ui->peerWidget->horizontalHeader()->restoreState(m_peer_widget_header_state)) {
+ ui->peerWidget->setColumnWidth(PeerTableModel::Address, ADDRESS_COLUMN_WIDTH);
+ ui->peerWidget->setColumnWidth(PeerTableModel::Subversion, SUBVERSION_COLUMN_WIDTH);
+ ui->peerWidget->setColumnWidth(PeerTableModel::Ping, PING_COLUMN_WIDTH);
+ }
ui->peerWidget->horizontalHeader()->setStretchLastSection(true);
// create peer table context menu
@@ -664,8 +673,11 @@ void RPCConsole::setClientModel(ClientModel *model, int bestblock_height, int64_
ui->banlistWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
ui->banlistWidget->setSelectionMode(QAbstractItemView::SingleSelection);
ui->banlistWidget->setContextMenuPolicy(Qt::CustomContextMenu);
- ui->banlistWidget->setColumnWidth(BanTableModel::Address, BANSUBNET_COLUMN_WIDTH);
- ui->banlistWidget->setColumnWidth(BanTableModel::Bantime, BANTIME_COLUMN_WIDTH);
+
+ if (!ui->banlistWidget->horizontalHeader()->restoreState(m_banlist_widget_header_state)) {
+ ui->banlistWidget->setColumnWidth(BanTableModel::Address, BANSUBNET_COLUMN_WIDTH);
+ ui->banlistWidget->setColumnWidth(BanTableModel::Bantime, BANTIME_COLUMN_WIDTH);
+ }
ui->banlistWidget->horizontalHeader()->setStretchLastSection(true);
// create ban table context menu
@@ -1171,6 +1183,11 @@ void RPCConsole::showEvent(QShowEvent *event)
void RPCConsole::hideEvent(QHideEvent *event)
{
+ // It is too late to call QHeaderView::saveState() in ~RPCConsole(), as all of
+ // the columns of QTableView child widgets will have zero width at that moment.
+ m_peer_widget_header_state = ui->peerWidget->horizontalHeader()->saveState();
+ m_banlist_widget_header_state = ui->banlistWidget->horizontalHeader()->saveState();
+
QWidget::hideEvent(event);
if (!clientModel || !clientModel->getPeerTableModel())
diff --git a/src/qt/rpcconsole.h b/src/qt/rpcconsole.h
index 75f466642b..2412ae543c 100644
--- a/src/qt/rpcconsole.h
+++ b/src/qt/rpcconsole.h
@@ -10,9 +10,10 @@
#include <net.h>
-#include <QWidget>
+#include <QByteArray>
#include <QCompleter>
#include <QThread>
+#include <QWidget>
class ClientModel;
class PlatformStyle;
@@ -167,6 +168,8 @@ private:
QThread thread;
WalletModel* m_last_wallet_model{nullptr};
bool m_is_executing{false};
+ QByteArray m_peer_widget_header_state;
+ QByteArray m_banlist_widget_header_state;
/** Update UI with latest network info from model. */
void updateNetworkState();