aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorW. J. van der Laan <laanwj@protonmail.com>2021-05-11 11:06:27 +0200
committerW. J. van der Laan <laanwj@protonmail.com>2021-05-11 11:06:47 +0200
commit39e306009b7444a86eaa963326972f9d0896525e (patch)
tree7bbf3cf0954fc7eddb3552184102f2cd7243e484
parentd2f6d2976f50e7944b1582f022c7ba8dfbc0bfa7 (diff)
parent7962e0dde8bbd0fa3dd702e2224774f1edaadcb6 (diff)
downloadbitcoin-39e306009b7444a86eaa963326972f9d0896525e.tar.xz
Merge bitcoin-core/gui#271: Don't clear console prompt when font resizing
7962e0dde8bbd0fa3dd702e2224774f1edaadcb6 qt: Do not clear console prompt when font resizing (Hennadii Stepanov) d2cc3390054616c73f72a59f864700f6de14067b qt, refactor: Drop redundant history cleaning in RPC console (Hennadii Stepanov) 4f0ae472e22990ad9e734faea4adacef8df449bb qt: Untie irrelevant signal-slot parameters (Hennadii Stepanov) Pull request description: On master, a console resize event will clear the prompt. To fix this, we store the content of the prompt and re-set it upon a resize. This preserves the prompt text throughout resizes. The text will still clear when you click the clear button, as it should. **Master** | Before Resize | After Resize | | ----------------- | ------------ | | ![master-beforeresize](https://user-images.githubusercontent.com/23396902/113553721-2a428d80-95c6-11eb-971b-bb77151bc6d5.png) | ![master-afterresize](https://user-images.githubusercontent.com/23396902/113553769-3d555d80-95c6-11eb-9cdb-9ad1fd7208a9.png) | **PR** | Before Resize | After Resize | | ----------------- | ------------ | | ![pr-beforeresize](https://user-images.githubusercontent.com/23396902/113553885-6f66bf80-95c6-11eb-8317-0975f1ebd444.png) | ![pr-afterresize](https://user-images.githubusercontent.com/23396902/113553906-75f53700-95c6-11eb-9a32-b64d8aba98e5.png) | Closes #269 ACKs for top commit: laanwj: Code review ACK 7962e0dde8bbd0fa3dd702e2224774f1edaadcb6 hebasto: ACK 7962e0dde8bbd0fa3dd702e2224774f1edaadcb6 Talkless: tACK 7962e0dde8bbd0fa3dd702e2224774f1edaadcb6, tested on Debian Sid with Qt 5.15.2 Tree-SHA512: a6f19d3f80e2e47725cff5d6e15862b6cb793a65dfcaded15f23bba051088cd3317f068f93290c9b09d0a90f5fcac1c5a4610cc417cc5961ba6d005fe5049ab0
-rw-r--r--src/qt/rpcconsole.cpp13
-rw-r--r--src/qt/rpcconsole.h2
2 files changed, 5 insertions, 10 deletions
diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp
index 58bca97c78..731d6a4eef 100644
--- a/src/qt/rpcconsole.cpp
+++ b/src/qt/rpcconsole.cpp
@@ -503,7 +503,7 @@ RPCConsole::RPCConsole(interfaces::Node& node, const PlatformStyle *_platformSty
ui->lineEdit->setMaxLength(16 * 1024 * 1024);
ui->messagesWidget->installEventFilter(this);
- connect(ui->clearButton, &QPushButton::clicked, this, &RPCConsole::clear);
+ connect(ui->clearButton, &QPushButton::clicked, [this] { clear(); });
connect(ui->fontBiggerButton, &QPushButton::clicked, this, &RPCConsole::fontBigger);
connect(ui->fontSmallerButton, &QPushButton::clicked, this, &RPCConsole::fontSmaller);
connect(ui->btnClearTrafficGraph, &QPushButton::clicked, ui->trafficGraph, &TrafficGraphWidget::clear);
@@ -771,20 +771,15 @@ void RPCConsole::setFontSize(int newSize)
// clear console (reset icon sizes, default stylesheet) and re-add the content
float oldPosFactor = 1.0 / ui->messagesWidget->verticalScrollBar()->maximum() * ui->messagesWidget->verticalScrollBar()->value();
- clear(false);
+ clear(/* keep_prompt */ true);
ui->messagesWidget->setHtml(str);
ui->messagesWidget->verticalScrollBar()->setValue(oldPosFactor * ui->messagesWidget->verticalScrollBar()->maximum());
}
-void RPCConsole::clear(bool clearHistory)
+void RPCConsole::clear(bool keep_prompt)
{
ui->messagesWidget->clear();
- if(clearHistory)
- {
- history.clear();
- historyPtr = 0;
- }
- ui->lineEdit->clear();
+ if (!keep_prompt) ui->lineEdit->clear();
ui->lineEdit->setFocus();
// Add smoothly scaled icon images.
diff --git a/src/qt/rpcconsole.h b/src/qt/rpcconsole.h
index 5182d60a0d..14d8900716 100644
--- a/src/qt/rpcconsole.h
+++ b/src/qt/rpcconsole.h
@@ -99,7 +99,7 @@ private Q_SLOTS:
void updateDetailWidget();
public Q_SLOTS:
- void clear(bool clearHistory = true);
+ void clear(bool keep_prompt = false);
void fontBigger();
void fontSmaller();
void setFontSize(int newSize);