-
Notifications
You must be signed in to change notification settings - Fork 38.7k
gui: Add close window shortcut #15768
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
gui: Add close window shortcut #15768
Conversation
|
Thanks! The macOS HIG about Command+W: |
promag
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pressing ESC also closes the dialogs (except the main window). Is this something to keep in macos? (not suggesting it though, just want to mention the redundancy)
src/qt/bitcoingui.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mind moving this to something like GUIUtil::handleHideShortcut(QWdiget*)? There are dialogs, like coin control dialog, transaction details, that could use the same feature.
src/qt/bitcoingui.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to lambda, could just be ... , &QShortcut::activated, this, &QWidget::hide)?
|
FWIW: I've verified that a disassembly of the |
|
utACK, ideally this kind of stuff would be handled by the cross-platform windowing system, so it's a bit disappointing that it's not, but also, this is only a few lines and increases user friendliness. BTW: CTRL-W is also quite a common shortcut for closing windows in applications outside of OS-X, for example in browsers it closes the tab. |
|
I will do the suggested changes and add the functionality to all the windows. Thanks for the review. |
|
|
|
Any reason not to enable this on all platforms? |
20859ae to
263c383
Compare
|
I have updated the PR with the given suggestions and added the shortcut to most windows. The only one without this shortcut is the 'About Qt' as it is part of Qt and I have not been able to add the shortcut to it. If I have missed any other window please let me know. @laanwj @luke-jr CMD+W is usually only used on macOS, more information can be found in the macOS HID posted by @jonasschnelli and in Wikepedia's Table of keyboard shortcuts. |
|
I use Ctrl+W on Linux all the time to close browser tabs. My IRC client seems to use it for closing tabs too. Furthermore, if macOS is using it, we can't use it for anything else (eg, closing wallets?). So overall, I'd say it makes sense to just support it on all platforms. |
|
Note: When extending it to support other platforms, care needs to be taken that the main window is not actually hidden if there's no system tray icon. Probably should minimise in that case? Not sure... |
src/qt/utilitydialog.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want this to be hide-able??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The criteria I followed to make windows hide-able has been what I understand is the common usage in macOS, meaning that every window that has a close button can also be closed using the CMD+W shortcut.
|
Probably a number of windows ought to be closed normally, not merely hidden? |
src/qt/guiutil.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't looked closely at this,... but is there a proper deallocation of that QShortcut?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have followed the official documentation in this regard[0]. If you consider that this is not a correct application please let me know a more appropriate way.
[0] https://doc.qt.io/qt-5/qobject.html
|
@IPGlider Could you address reviewers' comments? |
|
Is working in this PR still worth it? I would like to finish it. @hebasto I will address the comments in a few days. |
I wasn't aware that this shortcut was also commonly used in other OSs other than macOS. Considering this I will remove the ifdef to support all OSs.
I agree and after reading the QT documentation I will replace the Should I continue working on this PR considering that the name of the branch is |
|
@IPGlider No need for a new PR. Just update the PR title, body etc if required. |
8eec051 to
ab589f0
Compare
e0cd6f3 to
fa166a9
Compare
CMD+W/CTRL+W is the standard shortcut to close a window without exiting the program. Github-Pull: bitcoin#15768 Rebased-From: e0cd6f3c9c809f9876ff7d69ae91a9e67434be58
fa166a9 to
77b0232
Compare
CMD+W/CTRL+W is the standard shortcut to close a window without exiting the program. Github-Pull: bitcoin#15768 Rebased-From: 77b0232fcb0f7b7c28a041ebbe18b6205aea5db2
77b0232 to
7d99b3b
Compare
Fix intro dialog labels when the prune button is toggled (bitcoin#17453) Rename debug window (bitcoin#17096) Add close window shortcut (bitcoin#15768) Add privacy to the Overview page (bitcoin#16432) Remove WalletView and BitcoinGUI circular dependency (bitcoin#17937) Force set nPruneSize in QSettings after the intro dialog (bitcoin#17696)
CMD+W/CTRL+W is the standard shortcut to close a window without exiting the program.
7d99b3b to
f5a3a5b
Compare
hebasto
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK f5a3a5b, tested on Linux Mint 19.3 by manually opening available dialogs and sub-windows, and applying the Ctrl+W shortcut. Also tested with "Minimize on close" option enabled / disabled.
|
Tested ACK f5a3a5b |
f5a3a5b gui: Add close window shortcut (Miguel Herranz) Pull request description: CMD+W is the standard shortcut in macOS to close a window without exiting the program. This adds support to use the shortcut in both main and debug windows. ACKs for top commit: jonasschnelli: Tested ACK f5a3a5b hebasto: ACK f5a3a5b, tested on Linux Mint 19.3 by manually opening available dialogs and sub-windows, and applying the `Ctrl+W` shortcut. Also tested with "Minimize on close" option enabled / disabled. Tree-SHA512: 39851f6680cf97c334d5759c6f8597cb45685359417493ff8b0566672edbd32303fa15ac4260ec8ab5ea1458a600a329153014f25609e1db9cf399aa851ae2f9
CMD+W/CTRL+W is the standard shortcut to close a window without exiting the program. Github-Pull: bitcoin#15768 Rebased-From: f5a3a5b
Summary: > CMD+W/CTRL+W is the standard shortcut to close a window without > exiting the program. This is a backport of Core [[bitcoin/bitcoin#15768 | PR15768]] Test Plan: `ninja && src/qt/bitcoin-qt` Try Ctrl+W in various dialogs (e.g. in the RPC console) Reviewers: #bitcoin_abc, majcosta Reviewed By: #bitcoin_abc, majcosta Differential Revision: https://reviews.bitcoinabc.org/D9070
CMD+W is the standard shortcut in macOS to close a window without
exiting the program.
This adds support to use the shortcut in both main and debug windows.