-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Desktop: Resolves #1752: Added capability to toggle visibility of the Menu Bar from the View menu #10324
Desktop: Resolves #1752: Added capability to toggle visibility of the Menu Bar from the View menu #10324
Changes from 2 commits
736ae78
a16097e
0aa1da8
bb2da50
17f2b7b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { CommandDeclaration, CommandRuntime } from '@joplin/lib/services/CommandService'; | ||
import bridge from '../../../services/bridge'; | ||
import shim from '@joplin/lib/shim'; | ||
import Setting from '@joplin/lib/models/Setting'; | ||
import { _ } from '@joplin/lib/locale'; | ||
|
||
export const declaration: CommandDeclaration = { | ||
name: 'toggleMenuBar', | ||
label: () => _('Toggle menu bar'), | ||
}; | ||
|
||
export const runtime = (): CommandRuntime => { | ||
return { | ||
execute: async () => { | ||
// Defensive code: macOS disallows hiding the menu bar, so ignore this Command | ||
if (shim.isMac()) return; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At this stage it's not necessary to handle this, since you already handle it where it matters There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh yup that makes sense. Removed in the newest commit. |
||
|
||
const electronWindow = bridge().window(); | ||
Setting.toggle('hideMenuBar'); | ||
|
||
// Now apply the setting | ||
electronWindow.setAutoHideMenuBar(Setting.value('hideMenuBar')); | ||
electronWindow.setMenuBarVisibility(!Setting.value('hideMenuBar')); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove, since you're already doing this in the reducer middleware There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've removed this file and the references to this command in the latest commit |
||
}, | ||
}; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1283,6 +1283,13 @@ class Setting extends BaseModel { | |
isGlobal: true, | ||
}, | ||
|
||
hideMenuBar: { | ||
value: false, | ||
type: SettingItemType.Bool, | ||
public: false, | ||
appTypes: [AppType.Desktop], | ||
}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry would you mind naming it "showMenuBar" and setting it to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed, I'll change it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed in the latest commit. |
||
|
||
startMinimized: { value: false, type: SettingItemType.Bool, storage: SettingStorage.File, isGlobal: true, section: 'application', public: true, appTypes: [AppType.Desktop], label: () => _('Start application minimised in the tray icon') }, | ||
|
||
collapsedFolderIds: { value: [], type: SettingItemType.Array, public: false }, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4938,6 +4938,10 @@ msgstr "" | |
msgid "Toggle external editing" | ||
msgstr "" | ||
|
||
#: packages/app-desktop/gui/MainScreen/commands/toggleMenuBar.ts:9 | ||
msgid "Toggle menu bar" | ||
msgstr "" | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You don't need to add this here - that will be done automatically as long as you wrap the translatable strings in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've removed this in the latest commit |
||
#: packages/lib/models/Setting.ts:2714 | ||
msgid "Toggle note history, keep notes for" | ||
msgstr "" | ||
|
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.
We have a
MenuBar
component to handle the menu. Would you mind moving the logic over there? If you need some help implementing this please let me know.Essentially you'll need to add this to
mapStateToProps
:showMenuBar: state.settings.showMenuBar,
Then check the value of
props.showMenuBar
from the component and hide/show it based on this.The reason for doing it that way is to encapsulate all menu bar related logic in the same place, and to avoid the need to sync the settings and the state in the middleware.
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.
Thanks for the review! Makes sense - I'll try implementing it this way and reply back here.
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.
Moved the implementation to the
MenuBar
component in the latest commit. That simplifies things a lot!