Skip to content

Commit 6d4cee0

Browse files
committed
allow menu bar to be set in the settings
1 parent 13c2f47 commit 6d4cee0

File tree

7 files changed

+44
-5
lines changed

7 files changed

+44
-5
lines changed

browser/main/Main.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,21 @@ class Main extends React.Component {
172172
delete CodeMirror.keyMap.emacs['Ctrl-V']
173173

174174
eventEmitter.on('editor:fullscreen', this.toggleFullScreen)
175+
eventEmitter.on('menubar:togglemenubar', this.toggleMenuBarVisible.bind(this))
175176
}
176177

177178
componentWillUnmount () {
178179
eventEmitter.off('editor:fullscreen', this.toggleFullScreen)
180+
eventEmitter.off('menubar:togglemenubar', this.toggleMenuBarVisible.bind(this))
181+
}
182+
183+
toggleMenuBarVisible () {
184+
const { config } = this.props
185+
const { ui } = config
186+
187+
const newUI = Object.assign(ui, {showMenuBar: !ui.showMenuBar})
188+
const newConfig = Object.assign(config, newUI)
189+
ConfigManager.set(newConfig)
179190
}
180191

181192
handleLeftSlideMouseDown (e) {

browser/main/lib/ConfigManager.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,16 @@ export const DEFAULT_CONFIG = {
2626
toggleMain: OSX ? 'Command + Alt + L' : 'Super + Alt + E',
2727
toggleMode: OSX ? 'Command + Alt + M' : 'Ctrl + M',
2828
deleteNote: OSX ? 'Command + Shift + Backspace' : 'Ctrl + Shift + Backspace',
29-
pasteSmartly: OSX ? 'Command + Shift + V' : 'Ctrl + Shift + V'
29+
pasteSmartly: OSX ? 'Command + Shift + V' : 'Ctrl + Shift + V',
30+
toggleMenuBar: 'Alt'
3031
},
3132
ui: {
3233
language: 'en',
3334
theme: 'default',
3435
showCopyNotification: true,
3536
disableDirectWrite: false,
36-
defaultNote: 'ALWAYS_ASK' // 'ALWAYS_ASK', 'SNIPPET_NOTE', 'MARKDOWN_NOTE'
37+
defaultNote: 'ALWAYS_ASK', // 'ALWAYS_ASK', 'SNIPPET_NOTE', 'MARKDOWN_NOTE'
38+
showMenuBar: false
3739
},
3840
editor: {
3941
theme: 'base16-light',

browser/main/lib/shortcut.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,8 @@ module.exports = {
66
},
77
'deleteNote': () => {
88
ee.emit('hotkey:deletenote')
9+
},
10+
'toggleMenuBar': () => {
11+
ee.emit('menubar:togglemenubar')
912
}
1013
}

browser/main/modals/PreferencesModal/HotkeyTab.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ class HotkeyTab extends React.Component {
8080
toggleMain: this.refs.toggleMain.value,
8181
toggleMode: this.refs.toggleMode.value,
8282
deleteNote: this.refs.deleteNote.value,
83-
pasteSmartly: this.refs.pasteSmartly.value
83+
pasteSmartly: this.refs.pasteSmartly.value,
84+
toggleMenuBar: this.refs.toggleMenuBar.value
8485
}
8586
this.setState({
8687
config
@@ -128,6 +129,17 @@ class HotkeyTab extends React.Component {
128129
/>
129130
</div>
130131
</div>
132+
<div styleName='group-section'>
133+
<div styleName='group-section-label'>{i18n.__('Show/Hide Menu Bar')}</div>
134+
<div styleName='group-section-control'>
135+
<input styleName='group-section-control-input'
136+
onChange={(e) => this.handleHotkeyChange(e)}
137+
ref='toggleMenuBar'
138+
value={config.hotkey.toggleMenuBar}
139+
type='text'
140+
/>
141+
</div>
142+
</div>
131143
<div styleName='group-section'>
132144
<div styleName='group-section-label'>{i18n.__('Toggle Editor Mode')}</div>
133145
<div styleName='group-section-control'>

browser/main/modals/PreferencesModal/UiTab.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ class UiTab extends React.Component {
7575
showTagsAlphabetically: this.refs.showTagsAlphabetically.checked,
7676
saveTagsAlphabetically: this.refs.saveTagsAlphabetically.checked,
7777
enableLiveNoteCounts: this.refs.enableLiveNoteCounts.checked,
78+
showMenuBar: this.refs.showMenuBar.checked,
7879
disableDirectWrite: this.refs.uiD2w != null
7980
? this.refs.uiD2w.checked
8081
: false
@@ -238,6 +239,16 @@ class UiTab extends React.Component {
238239
</div>
239240
</div>
240241

242+
<div styleName='group-checkBoxSection'>
243+
<label>
244+
<input onChange={(e) => this.handleUIChange(e)}
245+
checked={this.state.config.ui.showMenuBar}
246+
ref='showMenuBar'
247+
type='checkbox'
248+
/>&nbsp;
249+
{i18n.__('Show menu bar')}
250+
</label>
251+
</div>
241252
<div styleName='group-checkBoxSection'>
242253
<label>
243254
<input onChange={(e) => this.handleUIChange(e)}

lib/ipcServer.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ ipcMain.on('config-renew', (e, payload) => {
3232
globalShortcut.unregisterAll()
3333
var { config } = payload
3434

35+
mainWindow.setMenuBarVisibility(config.ui.showMenuBar)
3536
var errors = []
3637
try {
3738
globalShortcut.register(config.hotkey.toggleMain, toggleMainWindow)

lib/main-window.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ const Config = require('electron-config')
66
const config = new Config()
77
const _ = require('lodash')
88

9-
var showMenu = process.platform !== 'win32'
109
const windowSize = config.get('windowsize') || {
1110
x: null,
1211
y: null,
@@ -22,7 +21,6 @@ const mainWindow = new BrowserWindow({
2221
useContentSize: true,
2322
minWidth: 500,
2423
minHeight: 320,
25-
autoHideMenuBar: showMenu,
2624
webPreferences: {
2725
zoomFactor: 1.0,
2826
enableBlinkFeatures: 'OverlayScrollbars'
@@ -33,6 +31,7 @@ const mainWindow = new BrowserWindow({
3331
const url = path.resolve(__dirname, './main.html')
3432

3533
mainWindow.loadURL('file://' + url)
34+
mainWindow.setMenuBarVisibility(false)
3635

3736
mainWindow.webContents.on('new-window', function (e) {
3837
e.preventDefault()

0 commit comments

Comments
 (0)