1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 17:56:25 +00:00

Merge pull request #2759 from richardtks/toggle-menu-bar-settings

allow menu bar visibility to be set in the settings
This commit is contained in:
Junyoung Choi
2019-01-08 08:27:41 +09:00
committed by GitHub
7 changed files with 44 additions and 5 deletions

View File

@@ -172,10 +172,21 @@ class Main extends React.Component {
delete CodeMirror.keyMap.emacs['Ctrl-V'] delete CodeMirror.keyMap.emacs['Ctrl-V']
eventEmitter.on('editor:fullscreen', this.toggleFullScreen) eventEmitter.on('editor:fullscreen', this.toggleFullScreen)
eventEmitter.on('menubar:togglemenubar', this.toggleMenuBarVisible.bind(this))
} }
componentWillUnmount () { componentWillUnmount () {
eventEmitter.off('editor:fullscreen', this.toggleFullScreen) eventEmitter.off('editor:fullscreen', this.toggleFullScreen)
eventEmitter.off('menubar:togglemenubar', this.toggleMenuBarVisible.bind(this))
}
toggleMenuBarVisible () {
const { config } = this.props
const { ui } = config
const newUI = Object.assign(ui, {showMenuBar: !ui.showMenuBar})
const newConfig = Object.assign(config, newUI)
ConfigManager.set(newConfig)
} }
handleLeftSlideMouseDown (e) { handleLeftSlideMouseDown (e) {

View File

@@ -26,14 +26,16 @@ export const DEFAULT_CONFIG = {
toggleMain: OSX ? 'Command + Alt + L' : 'Super + Alt + E', toggleMain: OSX ? 'Command + Alt + L' : 'Super + Alt + E',
toggleMode: OSX ? 'Command + Alt + M' : 'Ctrl + M', toggleMode: OSX ? 'Command + Alt + M' : 'Ctrl + M',
deleteNote: OSX ? 'Command + Shift + Backspace' : 'Ctrl + Shift + Backspace', deleteNote: OSX ? 'Command + Shift + Backspace' : 'Ctrl + Shift + Backspace',
pasteSmartly: OSX ? 'Command + Shift + V' : 'Ctrl + Shift + V' pasteSmartly: OSX ? 'Command + Shift + V' : 'Ctrl + Shift + V',
toggleMenuBar: 'Alt'
}, },
ui: { ui: {
language: 'en', language: 'en',
theme: 'default', theme: 'default',
showCopyNotification: true, showCopyNotification: true,
disableDirectWrite: false, disableDirectWrite: false,
defaultNote: 'ALWAYS_ASK' // 'ALWAYS_ASK', 'SNIPPET_NOTE', 'MARKDOWN_NOTE' defaultNote: 'ALWAYS_ASK', // 'ALWAYS_ASK', 'SNIPPET_NOTE', 'MARKDOWN_NOTE'
showMenuBar: false
}, },
editor: { editor: {
theme: 'base16-light', theme: 'base16-light',

View File

@@ -6,5 +6,8 @@ module.exports = {
}, },
'deleteNote': () => { 'deleteNote': () => {
ee.emit('hotkey:deletenote') ee.emit('hotkey:deletenote')
},
'toggleMenuBar': () => {
ee.emit('menubar:togglemenubar')
} }
} }

View File

@@ -80,7 +80,8 @@ class HotkeyTab extends React.Component {
toggleMain: this.refs.toggleMain.value, toggleMain: this.refs.toggleMain.value,
toggleMode: this.refs.toggleMode.value, toggleMode: this.refs.toggleMode.value,
deleteNote: this.refs.deleteNote.value, deleteNote: this.refs.deleteNote.value,
pasteSmartly: this.refs.pasteSmartly.value pasteSmartly: this.refs.pasteSmartly.value,
toggleMenuBar: this.refs.toggleMenuBar.value
} }
this.setState({ this.setState({
config config
@@ -128,6 +129,17 @@ class HotkeyTab extends React.Component {
/> />
</div> </div>
</div> </div>
<div styleName='group-section'>
<div styleName='group-section-label'>{i18n.__('Show/Hide Menu Bar')}</div>
<div styleName='group-section-control'>
<input styleName='group-section-control-input'
onChange={(e) => this.handleHotkeyChange(e)}
ref='toggleMenuBar'
value={config.hotkey.toggleMenuBar}
type='text'
/>
</div>
</div>
<div styleName='group-section'> <div styleName='group-section'>
<div styleName='group-section-label'>{i18n.__('Toggle Editor Mode')}</div> <div styleName='group-section-label'>{i18n.__('Toggle Editor Mode')}</div>
<div styleName='group-section-control'> <div styleName='group-section-control'>

View File

@@ -75,6 +75,7 @@ class UiTab extends React.Component {
showTagsAlphabetically: this.refs.showTagsAlphabetically.checked, showTagsAlphabetically: this.refs.showTagsAlphabetically.checked,
saveTagsAlphabetically: this.refs.saveTagsAlphabetically.checked, saveTagsAlphabetically: this.refs.saveTagsAlphabetically.checked,
enableLiveNoteCounts: this.refs.enableLiveNoteCounts.checked, enableLiveNoteCounts: this.refs.enableLiveNoteCounts.checked,
showMenuBar: this.refs.showMenuBar.checked,
disableDirectWrite: this.refs.uiD2w != null disableDirectWrite: this.refs.uiD2w != null
? this.refs.uiD2w.checked ? this.refs.uiD2w.checked
: false : false
@@ -238,6 +239,16 @@ class UiTab extends React.Component {
</div> </div>
</div> </div>
<div styleName='group-checkBoxSection'>
<label>
<input onChange={(e) => this.handleUIChange(e)}
checked={this.state.config.ui.showMenuBar}
ref='showMenuBar'
type='checkbox'
/>&nbsp;
{i18n.__('Show menu bar')}
</label>
</div>
<div styleName='group-checkBoxSection'> <div styleName='group-checkBoxSection'>
<label> <label>
<input onChange={(e) => this.handleUIChange(e)} <input onChange={(e) => this.handleUIChange(e)}

View File

@@ -32,6 +32,7 @@ ipcMain.on('config-renew', (e, payload) => {
globalShortcut.unregisterAll() globalShortcut.unregisterAll()
var { config } = payload var { config } = payload
mainWindow.setMenuBarVisibility(config.ui.showMenuBar)
var errors = [] var errors = []
try { try {
globalShortcut.register(config.hotkey.toggleMain, toggleMainWindow) globalShortcut.register(config.hotkey.toggleMain, toggleMainWindow)

View File

@@ -6,7 +6,6 @@ const Config = require('electron-config')
const config = new Config() const config = new Config()
const _ = require('lodash') const _ = require('lodash')
var showMenu = process.platform !== 'win32'
const windowSize = config.get('windowsize') || { const windowSize = config.get('windowsize') || {
x: null, x: null,
y: null, y: null,
@@ -22,7 +21,6 @@ const mainWindow = new BrowserWindow({
useContentSize: true, useContentSize: true,
minWidth: 500, minWidth: 500,
minHeight: 320, minHeight: 320,
autoHideMenuBar: showMenu,
webPreferences: { webPreferences: {
zoomFactor: 1.0, zoomFactor: 1.0,
enableBlinkFeatures: 'OverlayScrollbars' enableBlinkFeatures: 'OverlayScrollbars'
@@ -33,6 +31,7 @@ const mainWindow = new BrowserWindow({
const url = path.resolve(__dirname, './main.html') const url = path.resolve(__dirname, './main.html')
mainWindow.loadURL('file://' + url) mainWindow.loadURL('file://' + url)
mainWindow.setMenuBarVisibility(false)
mainWindow.webContents.on('new-window', function (e) { mainWindow.webContents.on('new-window', function (e) {
e.preventDefault() e.preventDefault()