Skip to content

Don't clear console prompt when font resizing - #271

Merged
laanwj merged 3 commits into
bitcoin-core:masterfrom
jarolrod:dont-clear-console
May 11, 2021
Merged

Don't clear console prompt when font resizing#271
laanwj merged 3 commits into
bitcoin-core:masterfrom
jarolrod:dont-clear-console

Conversation

@jarolrod

Copy link
Copy Markdown
Contributor

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 ResizeAfter Resize
master-beforeresizemaster-afterresize

PR

Before ResizeAfter Resize
pr-beforeresizepr-afterresize

Closes#269

@jonatackjonatack left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested ACK dcd7a8c

Naming nit, I'm not sure this applies to the GUI but per doc/developer-notes.md:

  • Symbol naming conventions. These are preferred in new code, but are not
    required when doing so would need changes to significant pieces of existing
    code.
    • Variable (including function arguments) and namespace names are all lowercase and may use _ to separate words (snake_case).

@jarolrod

Copy link
Copy Markdown
ContributorAuthor

Naming nit, I'm not sure this applies to the GUI but per doc/developer-notes.md:

@jonatack Good point, I was following the style of the surrounding code as well as the Qt Coding Style. @hebasto what do you think? This is a good topic for the Qt Dev Notes

@hebasto

Copy link
Copy Markdown
Member

Concept ACK.

This preserves the prompt text throughout resizes.

Why not to implement this idea directly: https://github.com/hebasto/gui/commits/pr271-alt ?

@promagpromag left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concept ACK.

@promag

Copy link
Copy Markdown
Contributor

Concept ACK.

This preserves the prompt text throughout resizes.

Why not to implement this idea directly: https://github.com/hebasto/gui/commits/pr271-alt ?

I prefer this approach.

@Bosch-0

Copy link
Copy Markdown

This doesn't appear to be an issue on Windows 10

@hebasto

Copy link
Copy Markdown
Member

@Bosch-0

This doesn't appear to be an issue on Windows 10

Do you mind elaborating?

Testing bitcoin-0.21.1rc1 (not master) on Windows Pro 20H2 (build 19042.928), and clicking on the "A+" or "A-" buttons indeed clears the console prompt. I see this PR as a UX improvement, no?

@Bosch-0

Copy link
Copy Markdown

Apologies I originally misread, thought this was resizing the window not font. Yes I can replicate this, will test this PR today

QAbstractButton::clicked signal has the `checked` parameter that is
irrelevant to RPCConsole::clear slot parameter.
The default clearHistory=true argument is passed in the RPCConsole ctor
only. This is needless, as the history and historyPtr members are
initialized properly.
@jarolrod

jarolrod commented Apr 23, 2021

Copy link
Copy Markdown
ContributorAuthor

updated from dcd7a8c -> 7962e0d

Changes:

  • use @hebasto's version from branch pr271-alt. This version is the superior implementation.

@hebastohebasto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TalklessTalkless left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tACK 7962e0d, tested on Debian Sid with Qt 5.15.2

Comment threadsrc/qt/rpcconsole.cpp
// 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);

@TalklessTalklessApr 25, 2021

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Offtopic: I feel it would be better to use enums, avoiding /* comments explaining what are we doing */ I've seen here and there. clear(CearMode::KeePrompt) would be self-docummenting, less error prone. But again, that's offtopic for this PR.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The relevant discussion is here bitcoin/bitcoin#21684.

@hebasto

Copy link
Copy Markdown
Member

@Talkless

tACK d2cc339, tested on Debian Sid with Qt 5.15.2

Could you use the top commit hash which is 7962e0d for the current branch state? Just edit your comment will be ok :)

@Talkless

Copy link
Copy Markdown

@Talkless

tACK d2cc339, tested on Debian Sid with Qt 5.15.2

Could you use the top commit hash which is 7962e0d for the current branch state? Just edit your comment will be ok :)

Ouch, sorry, fixed.

@hebastohebasto added this to the 22.0 milestone May 8, 2021
@hebastohebasto added UX All about "how to get things done" and removed Feature labels May 10, 2021
@laanwj

Copy link
Copy Markdown
Member

Code review ACK 7962e0d

I think the PR is named confusedly though and would suggest renaming it: I assumed it was about window resizing too and was really surprised why that would clear anything.

@hebastohebasto changed the title Don't clear console prompt when resizingDon't clear console prompt when font resizingMay 11, 2021
@laanwj
laanwj merged commit 39e3060 into bitcoin-core:masterMay 11, 2021
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request May 11, 2021
@jarolrod
jarolrod deleted the dont-clear-console branch May 20, 2021 21:20
Comment threadsrc/qt/rpcconsole.cpp
ui->messagesWidget->verticalScrollBar()->setValue(oldPosFactor * ui->messagesWidget->verticalScrollBar()->maximum());
}

void RPCConsole::clear(bool clearHistory)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the future, please keep the existing param so calls to eg clear(true) don't silently change behaviour...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't follow... In d2cc339RPCConsole::clear() has no parameters.
Why keep the existing useless param?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case another PR were to use the bool param, this change would silently result in different behaviour when the two are merged together. Using an enum class would also solve it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using an enum class would also solve it.

Agree. bitcoin/bitcoin#21684

gwillen pushed a commit to ElementsProject/elements that referenced this pull request Jun 1, 2022
@bitcoin-corebitcoin-core locked as resolved and limited conversation to collaborators Aug 16, 2022
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

UXAll about "how to get things done"

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Don't Clear Console Prompt When Resizing Text

8 participants

@jarolrod@hebasto@promag@Bosch-0@Talkless@laanwj@luke-jr@jonatack