Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't clear console prompt when font resizing #271

Merged
merged 3 commits into from
May 11, 2021

Conversation

jarolrod
Copy link
Member

@jarolrod jarolrod commented Apr 5, 2021

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 master-afterresize

PR

Before Resize After Resize
pr-beforeresize pr-afterresize

Closes #269

Copy link
Member

@jonatack jonatack left a comment

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
Member Author

jarolrod commented Apr 5, 2021

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
Member

hebasto commented Apr 10, 2021

Concept ACK.

This preserves the prompt text throughout resizes.

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

Copy link
Contributor

@promag promag left a comment

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
Contributor

promag commented Apr 17, 2021

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

Bosch-0 commented Apr 20, 2021

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

@hebasto
Copy link
Member

hebasto commented Apr 20, 2021

@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

Bosch-0 commented Apr 21, 2021

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
Copy link
Member Author

jarolrod commented Apr 23, 2021

updated from dcd7a8c -> 7962e0d

Changes:

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

Copy link
Member

@hebasto hebasto left a comment

Choose a reason for hiding this comment

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

ACK 7962e0d

Copy link

@Talkless Talkless left a comment

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

@@ -776,20 +776,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);
Copy link

@Talkless Talkless Apr 25, 2021

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
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
Member

hebasto commented Apr 25, 2021

@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

@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.

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

laanwj commented May 11, 2021

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.

@hebasto hebasto changed the title Don't clear console prompt when resizing Don't clear console prompt when font resizing May 11, 2021
@laanwj laanwj merged commit 39e3060 into bitcoin-core:master May 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
ui->messagesWidget->setHtml(str);
ui->messagesWidget->verticalScrollBar()->setValue(oldPosFactor * ui->messagesWidget->verticalScrollBar()->maximum());
}

void RPCConsole::clear(bool clearHistory)
Copy link
Member

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
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 d2cc339 RPCConsole::clear() has no parameters.
Why keep the existing useless param?

Copy link
Member

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
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-core bitcoin-core locked as resolved and limited conversation to collaborators Aug 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
UX All 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