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

set shortcuts for console's resize buttons #281

Merged
merged 3 commits into from
May 20, 2021

Conversation

jarolrod
Copy link
Member

@jarolrod jarolrod commented Apr 14, 2021

On master the only way to resize the console font is to manually move your mouse and click the resize buttons. This PR introduces convenient keyboard shortcuts to resize the console font.

The common resize shortcuts for applications are Ctrl+=/Ctrl++ and Ctrl+-/Ctrl+_. This means that the resize QPushButtons need two shortcuts each, but you cannot assign multiple shortcuts to a QPushButton. See: https://doc.qt.io/qt-5/qabstractbutton.html#shortcut-prop

To get around this, we introduce a new function in guiutil, which connects a supplied QKeySequence shortcut to a QAbstractButton. This function can be reused in other situations where more than one shortcut is needed for a button.

PR on macOS PR on Linux
mac-resize-shortcuts linux-resize-shortcuts

@jarolrod jarolrod changed the title qt: set shortcuts for console's resize buttons set shortcuts for console's resize buttons Apr 14, 2021
@hebasto
Copy link
Member

hebasto commented Apr 14, 2021

Concept ACK.

@jarolrod jarolrod force-pushed the mul-shortcuts-resize branch from 0caccb5 to 3282d36 Compare April 14, 2021 17:31
@jarolrod
Copy link
Member Author

Updated 0caccb5 -> 3282d36

Changes:

  • updated spacing to adhere to clang-format

@hebasto
Copy link
Member

hebasto commented Apr 14, 2021

The common resize shortcuts for applications are Ctrl+=/Ctrl++ and Ctrl+-/Ctrl+_.

Are they and QKeySequence::ZoomIn, QKeySequence::ZoomOut (https://doc.qt.io/qt-5/qkeysequence.html#StandardKey-enum) the same?

@jarolrod
Copy link
Member Author

jarolrod commented Apr 14, 2021

@hebasto See: https://doc.qt.io/qt-5/qkeysequence.html#standard-shortcuts. I don't think it includes Ctrl+= or Ctrl+_

src/qt/guiutil.cpp Outdated Show resolved Hide resolved
@jarolrod jarolrod force-pushed the mul-shortcuts-resize branch from 3282d36 to ab95506 Compare April 14, 2021 18:29
@jarolrod
Copy link
Member Author

Updated from 3282d36 -> ab95506

Changes:

  • Action can be set on the button directly. Remove the parent parameter from function and docs.

@hebasto
Copy link
Member

hebasto commented Apr 14, 2021

@hebasto See: https://doc.qt.io/qt-5/qkeysequence.html#standard-shortcuts. I don't think it includes Ctrl+= or Ctrl+_

Keyboard Layout Issues describe exactly this PR :)

@hebasto
Copy link
Member

hebasto commented Apr 18, 2021

@jarolrod

Do you mind looking into https://github.com/hebasto/gui/commits/pr281-alt?
It seems more general and concise, no?

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.

Any reason to not use https://doc.qt.io/qt-5/qabstractbutton.html#shortcut-prop? And why we want multiple shortcuts for the same button?

@hebasto
Copy link
Member

hebasto commented Apr 19, 2021

And why we want multiple shortcuts for the same button?

https://doc.qt.io/qt-5/qkeysequence.html#keyboard-layout-issues

Ctrl+Plus is, actually, Ctrl+Equal_Sign on some keyboard layouts, no?

@jarolrod
Copy link
Member Author

@promag you can only assign one shortcut directly to a button. The reason to have multiple shortcuts is to allow for the following shortcuts on the resize buttons:

  • Smaller = Ctrl+-, Ctrl+_
  • Bigger = Ctrl+=, Ctrl++
    These two shortcuts are common and standard for resizing and having both of them helps get around any differences in keyboard layouts.

@hebasto's approach seems to be a more focused approach as we're unlikely to need 3 shortcuts for a button. Still looking.

@hebasto
Copy link
Member

hebasto commented Apr 19, 2021

... we're unlikely to need 3 shortcuts for a button.

It will work for any number of shortcuts. But one of them could be considered as "main" one.

@hebasto
Copy link
Member

hebasto commented Apr 19, 2021

Any reason to not use https://doc.qt.io/qt-5/qabstractbutton.html#shortcut-prop?

https://github.com/hebasto/gui/commits/pr281-alt is using it for a "main" shortcut.

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.

Concept ACK

src/qt/guiutil.cpp Outdated Show resolved Hide resolved
src/qt/guiutil.cpp Outdated Show resolved Hide resolved
src/qt/guiutil.cpp Outdated Show resolved Hide resolved
@hebasto hebasto added this to the 22.0 milestone May 8, 2021
@jarolrod jarolrod force-pushed the mul-shortcuts-resize branch 2 times, most recently from cfea5c7 to 2d2632a Compare May 14, 2021 19:31
@jarolrod
Copy link
Member Author

jarolrod commented May 14, 2021

Updated from ab95506 -> 2d2632a

Main Change: adopt @hebasto's approach as it is more focused

Changes from @hebasto's branch:

  • Rename shortcut function from AddShortcut to AddButtonShortcut
  • Add Doxygen comment for AddButtonShortcut function
  • Use translator comments instead of disambiguation strings

Will add test coverage in a follow-up PR as some refactors to the current apptests is required.

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 2d2632a

src/qt/guiutil.h Outdated Show resolved Hide resolved
ui->fontBiggerButton->setIcon(platformStyle->SingleColorIcon(":/icons/fontbigger"));
//: Main shortcut to increase the RPC console font size.
ui->fontBiggerButton->setShortcut(tr("Ctrl++"));
//: Secondary shortcut to increase the RPC console font size.
Copy link
Member

Choose a reason for hiding this comment

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

Maybe add a note that a secondary shortcut differs from a main one only by presence/absence of the <Shift> key in the key sequence?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think this is ok as is. If we include that i'd be worried if someone translates into Ctrl+Shift+_.

hebasto and others added 2 commits May 17, 2021 14:01
Co-authored-by: Jarol Rodriguez <jarolrod@tutanota.com>
Co-authored-by: Jarol Rodriguez <jarolrod@tutanota.com>
@jarolrod jarolrod force-pushed the mul-shortcuts-resize branch from 2d2632a to 2a45134 Compare May 17, 2021 19:37
@jarolrod
Copy link
Member Author

updated from 2d2632a -> 2a45134

Adresses @hebasto's comment:

  • Added a note to make it clear that the reason the AddButtonShort function exists is to get around the one shortcut at a time limitation of the button's shortcut property
  • While here, adjust the formatting of my added Doxygen comment to ascribe to the formatting specified in the dev notes

Doxygen Comment:
Screen Shot 2021-05-17 at 1 56 41 PM

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.

re-ACK 2a45134

@hebasto hebasto added the UX All about "how to get things done" label May 17, 2021
@hebasto hebasto removed the Feature label May 17, 2021
.arg("<b>" + ui->clearButton->shortcut().toString(QKeySequence::NativeText) + "</b>") +
"<br>" +
tr("Use %1 and %2 to increase or decrease the font size.")
.arg("<b>" + ui->fontBiggerButton->shortcut().toString(QKeySequence::NativeText) + "</b>")

Choose a reason for hiding this comment

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

nit: .arg(foo, bar) overload could be used instead of .arg(foo).arg(bar)

Copy link
Member

Choose a reason for hiding this comment

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

But isn't the current code more readable?

Choose a reason for hiding this comment

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

Yes, maybe, though it could be something like

                    .arg(
                    "<b>" + ui->fontBiggerButton->shortcut().toString(QKeySequence::NativeText) + "</b>",
                    "<b>" + ui->fontSmallerButton->shortcut().toString(QKeySequence::NativeText) + "</b>"
                    ) +

Not that bad.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think that should be debated here: #331

Copy link
Member

Choose a reason for hiding this comment

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

@jarolrod

I think that should be debated here: #331

Done :)

Choose a reason for hiding this comment

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

Yes that ends debate.

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 2a45134, tested on Debian Sid with Qt 5.15.2, shortcuts still work.

@laanwj laanwj merged commit 710c8ba into bitcoin-core:master May 20, 2021
@jarolrod jarolrod deleted the mul-shortcuts-resize branch May 20, 2021 21:20
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request May 21, 2021
gwillen pushed a commit to ElementsProject/elements that referenced this pull request Jun 1, 2022
maflcko pushed a commit that referenced this pull request Jun 3, 2022
3a171f7 logging: fix logging empty threadname (klementtan)

Pull request description:

  Currently, `leveldb` background thread does not have a thread name and as a result, an empty thread name is logged.

  This PR fixes this by logging thread name as `"unknown"` if the thread name is empty

  On master:
  ```txt
  2022-06-02T14:30:38Z [] [leveldb:debug] Generated table #281@0: 1862 keys, 138303 bytes
  ```

  On this PR:
  ```txt
  2022-06-02T14:30:38Z [unknown] [leveldb:debug] Generated table #281@0: 1862 keys, 138303 bytes
  ```

ACKs for top commit:
  laanwj:
    Code review ACK 3a171f7
  hebasto:
    ACK 3a171f7

Tree-SHA512: 0af0fa5c4ddd3640c6dab9595fe9d97f74d0e0f4b41287a6630cf8ac5a21240250e0659ec4ac5a561e888d522f5304bf627104de2aba0fd0a86c1222de0897c2
@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.

5 participants