Skip to content

Commit

Permalink
qt: don't clear console prompt when resizing
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jarolrod committed Apr 5, 2021
1 parent 590e49c commit dcd7a8c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/qt/rpcconsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -764,11 +764,12 @@ void RPCConsole::setFontSize(int newSize)
if (newSize < FONT_RANGE.width() || newSize > FONT_RANGE.height())
return;

// temp. store the console content
QString str = ui->messagesWidget->toHtml();
// temp. store the console and prompt content
QString strConsole = ui->messagesWidget->toHtml();
QString strPrompt = ui->lineEdit->text();

// replace font tags size in current content
str.replace(QString("font-size:%1pt").arg(consoleFontSize), QString("font-size:%1pt").arg(newSize));
strConsole.replace(QString("font-size:%1pt").arg(consoleFontSize), QString("font-size:%1pt").arg(newSize));

// store the new font size
consoleFontSize = newSize;
Expand All @@ -777,8 +778,9 @@ 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);
ui->messagesWidget->setHtml(str);
ui->messagesWidget->setHtml(strConsole);
ui->messagesWidget->verticalScrollBar()->setValue(oldPosFactor * ui->messagesWidget->verticalScrollBar()->maximum());
ui->lineEdit->setText(strPrompt);
}

void RPCConsole::clear(bool clearHistory)
Expand Down

0 comments on commit dcd7a8c

Please sign in to comment.