joplin icon indicating copy to clipboard operation
joplin copied to clipboard

Desktop: Resolves #1752: Added capability to toggle visibility of the Menu Bar from the View menu

Open LightTreasure opened this issue 2 months ago • 2 comments

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 in lib/services/KeymapService.ts), and a localization string added to tools/locales/joplin.pot and english translation tools/locales/en_US.po
  • Added a new, non-public setting called hideMenuBar, a boolean with the default value of false, applicable only to the Desktop App (defined in lib/models/Setting.ts)
  • Created a MainScreen Command called toggleMenuBar(), which contains the main implementation. This flips the value of the hideMenuBar setting and then correspondingly calls setAutoHideMenuBar() and setMenuBarVisibility() on the Electron Window.
  • Added a similar function called updateMenuBar() in app-desktop/app.ts - Called during initializatoin, this function calls setAutoHideMenuBar() and setMenuBarVisibility() based on the value of the hideMenuBar setting.
  • toggleMenuBar() and updateMenuBar() do not do anything on Mac.

Usage with screenshots:

The new menu entry: joplin_menuentry

When the setting is toggled: joplin_nomenu

Toggling again brings the menu back: joplin_start

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

LightTreasure avatar Apr 18 '24 03:04 LightTreasure

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

github-actions[bot] avatar Apr 18 '24 03:04 github-actions[bot]

I have read the CLA Document and I hereby sign the CLA

LightTreasure avatar Apr 18 '24 03:04 LightTreasure

Hi @laurent22, please let me know if you have any further suggestions. Thanks so much!

LightTreasure avatar May 06 '24 19:05 LightTreasure

That looks good now, thanks @LightTreasure!

laurent22 avatar May 07 '24 09:05 laurent22