joplin
joplin copied to clipboard
Desktop: Resolves #1752: Added capability to toggle visibility of the Menu Bar from the View menu
Add menu option and shortcut to toggle visibility of the menu bar
What this does:
This PR adds a new item to the View Menu called "Toggle Menu Bar", and proposes Ctrl+Shift+M
as its default keyboard shortcut. Clicking on this item or using the shortcut toggles the visibility of the menu bar. Also, when the bar is hidden, pressing Alt
will temporarily show the menu bar
EDIT: The menu item is not shown on Mac since macOS does not allow for hiding menus.
This feature has been requested via the following issues:
- #1752
- #3894
It has also been requested on the Joplin Forum:
- https://discourse.joplinapp.org/t/hide-menubar/8731
- https://discourse.joplinapp.org/t/fr-toggle-tool-bar-and-menu-bar-distraction-free-mode/4430
How implemented:
Builds on @tinyoverflow's previously submitted pull request to address the same issue. This work incorporates @laurent22's feedback in that PR to add this capability as a View Menu item instead of it being present on the settings page.
- Added a new entry to the 'View' Menu, called "Toggle menu bar", with a proposed keyboard shortcut
Ctrl+Shift+M
(defined inlib/services/KeymapService.ts
), and a localization string added totools/locales/joplin.pot
and english translationtools/locales/en_US.po
- Added a new, non-public setting called
hideMenuBar
, a boolean with the default value offalse
, applicable only to the Desktop App (defined inlib/models/Setting.ts
) - Created a MainScreen Command called
toggleMenuBar()
, which contains the main implementation. This flips the value of thehideMenuBar
setting and then correspondingly callssetAutoHideMenuBar()
andsetMenuBarVisibility()
on the Electron Window. - Added a similar function called
updateMenuBar()
inapp-desktop/app.ts
- Called during initializatoin, this function callssetAutoHideMenuBar()
andsetMenuBarVisibility()
based on the value of thehideMenuBar
setting. -
toggleMenuBar()
andupdateMenuBar()
do not do anything on Mac.
Usage with screenshots:
The new menu entry:
When the setting is toggled:
Toggling again brings the menu back:
Issues:
Sometimes, after hiding the menu bar, the window is left with a white empty area, indicating that the contents aren't painted correctly. @tinyoverflow also mentioned this issue in their PR. I've tried debugging this, but haven't been able to fix it. My guess is that Electron isn't repainting the window properly after the menu bar is hidden.
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅
I have read the CLA Document and I hereby sign the CLA
Hi @laurent22, please let me know if you have any further suggestions. Thanks so much!
That looks good now, thanks @LightTreasure!