Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

about:preferences now has "autohide menu" option #1630

Closed
wants to merge 9 commits into from
1 change: 1 addition & 0 deletions app/extensions/brave/locales/en-US/menu.properties
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,4 @@ zoom=Zoom
new=New
learnSpelling=Learn Spelling
ignoreSpelling=Ignore Spelling
autoHideMenuBar=Hide Menu Bar
2 changes: 2 additions & 0 deletions app/extensions/brave/locales/en-US/preferences.properties
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,5 @@ fullscreenPermission=Fullscreen access
openExternalPermission=Open external applications
alwaysAllow=Always allow
alwaysDeny=Always deny
appearanceSettings=Appearance settings
autoHideMenuBar=Hide the menu bar by default
3 changes: 2 additions & 1 deletion app/locale.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ var rendererIdentifiers = function () {
'learnSpelling',
'ignoreSpelling',
// Other identifiers
'urlCopied'
'urlCopied',
'autoHideMenuBar'
]
}

Expand Down
8 changes: 7 additions & 1 deletion js/about/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const messages = require('../constants/messages')
const settings = require('../constants/settings')
const aboutActions = require('./aboutActions')
const getSetting = require('../settings').getSetting
const isDarwin = process.platform === 'darwin'

// TODO: Determine this from the l20n file automatically
const hintCount = 3
Expand Down Expand Up @@ -124,12 +125,17 @@ class GeneralTab extends ImmutableComponent {
value={getSetting(settings.HOMEPAGE, this.props.settings)}
onChange={changeSetting.bind(null, this.props.onChangeSetting, settings.HOMEPAGE)} />
</SettingItem>
<SettingCheckbox dataL10nId='showHomeButton' prefKey={settings.SHOW_HOME_BUTTON} settings={this.props.settings} onChangeSetting={this.props.onChangeSetting} />
</SettingsList>
<SettingsList dataL10nId='bookmarkToolbarSettings'>
<SettingCheckbox dataL10nId='bookmarkToolbar' prefKey={settings.SHOW_BOOKMARKS_TOOLBAR} settings={this.props.settings} onChangeSetting={this.props.onChangeSetting} />
<SettingCheckbox dataL10nId='bookmarkToolbarShowFavicon' prefKey={settings.SHOW_BOOKMARKS_TOOLBAR_FAVICON} settings={this.props.settings} onChangeSetting={this.props.onChangeSetting} />
</SettingsList>
<SettingsList dataL10nId='appearanceSettings'>
<SettingCheckbox dataL10nId='showHomeButton' prefKey={settings.SHOW_HOME_BUTTON} settings={this.props.settings} onChangeSetting={this.props.onChangeSetting} />
{
isDarwin ? null : <SettingCheckbox dataL10nId='autoHideMenuBar' prefKey={settings.AUTO_HIDE_MENU_BAR} settings={this.props.settings} onChangeSetting={this.props.onChangeSetting} />
}
</SettingsList>
</SettingsList>
}
}
Expand Down
12 changes: 12 additions & 0 deletions js/commonMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,18 @@ module.exports.bookmarksToolbarMenuItem = () => {
}
}

module.exports.autoHideMenuBarMenuItem = () => {
const autoHideMenuBar = getSetting(settings.AUTO_HIDE_MENU_BAR)
return {
label: locale.translation('autoHideMenuBar'),
type: 'checkbox',
checked: autoHideMenuBar,
click: (item, focusedWindow) => {
appActions.changeSetting(settings.AUTO_HIDE_MENU_BAR, !autoHideMenuBar)
}
}
}

module.exports.aboutBraveMenuItem = () => {
return {
label: locale.translation('about') + ' ' + appConfig.name,
Expand Down
4 changes: 4 additions & 0 deletions js/constants/appConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ const updateHost = process.env.BRAVE_UPDATE_HOST || 'https://brave-laptop-update
const winUpdateHost = process.env.BRAVE_WIN_UPDATE_HOST || 'https://brave-download.global.ssl.fastly.net'
const crashURL = process.env.BRAVE_CRASH_URL || 'https://laptop-updates.brave.com/1/crashes'

// Windows specific configuration settings.
const autoHideMenuBar = process.platform !== 'win32'

module.exports = {
name: 'Brave',
contactUrl: 'mailto:support+laptop@brave.com',
Expand Down Expand Up @@ -76,6 +79,7 @@ module.exports = {
'general.homepage': 'https://www.brave.com',
'general.show-home-button': false,
'general.useragent.value': null, // Set at runtime
'general.autohide-menubar': autoHideMenuBar,
'search.default-search-engine': 'content/search/google.xml',
'tabs.switch-to-new-tabs': false,
'tabs.paint-tabs': true,
Expand Down
1 change: 1 addition & 0 deletions js/constants/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const settings = {
SHOW_HOME_BUTTON: 'general.show-home-button',
USERAGENT: 'general.useragent.value',
DEFAULT_DOWNLOAD_SAVE_PATH: 'general.downloads.default-save-path',
AUTO_HIDE_MENU_BAR: 'general.autohide-menubar',
// Search tab
DEFAULT_SEARCH_ENGINE: 'search.default-search-engine',
// Tabs tab
Expand Down
17 changes: 13 additions & 4 deletions js/contextMenus.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const ipc = global.require('electron').ipcRenderer
const locale = require('../js/l10n')
const getSetting = require('./settings').getSetting
const settings = require('./constants/settings')
const isDarwin = process.platform === 'darwin'

/**
* Obtains an add bookmark menu item
Expand Down Expand Up @@ -78,13 +79,21 @@ function inputTemplateInit (e) {
}

function tabsToolbarTemplateInit (activeFrame, closestDestinationDetail, isParent) {
return [
const menu = [
CommonMenu.bookmarksMenuItem(),
CommonMenu.bookmarksToolbarMenuItem(),
CommonMenu.separatorMenuItem,
addBookmarkMenuItem('addBookmark', siteUtil.getDetailFromFrame(activeFrame, siteTags.BOOKMARK), closestDestinationDetail, isParent),
addFolderMenuItem(closestDestinationDetail, isParent)
CommonMenu.separatorMenuItem
]

if (!isDarwin) {
menu.push(CommonMenu.autoHideMenuBarMenuItem(),
CommonMenu.separatorMenuItem)
}

menu.push(addBookmarkMenuItem('addBookmark', siteUtil.getDetailFromFrame(activeFrame, siteTags.BOOKMARK), closestDestinationDetail, isParent),
addFolderMenuItem(closestDestinationDetail, isParent))

return menu
}

function downloadsToolbarTemplateInit (downloadId, downloadItem) {
Expand Down
18 changes: 17 additions & 1 deletion js/stores/appStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const EventEmitter = require('events').EventEmitter
const Immutable = require('immutable')
const diff = require('immutablediff')
const debounce = require('../lib/debounce.js')
const isDarwin = process.platform === 'darwin'

// Only used internally
const CHANGE_EVENT = 'app-state-change'
Expand Down Expand Up @@ -109,6 +110,8 @@ const createWindow = (browserOpts, defaults) => {
browserOpts.width = browserOpts.width < minWidth ? minWidth : browserOpts.width
browserOpts.height = browserOpts.height < minHeight ? minHeight : browserOpts.height

const autoHideMenuBarSetting = isDarwin || getSetting(settings.AUTO_HIDE_MENU_BAR)

let mainWindow = new BrowserWindow(Object.assign({
// smaller min size for "modal" windows
minWidth,
Expand All @@ -117,7 +120,7 @@ const createWindow = (browserOpts, defaults) => {
// frame: false,
// A frame but no title bar and windows buttons in titlebar 10.10 OSX and up only?
titleBarStyle: 'hidden-inset',
autoHideMenuBar: true,
autoHideMenuBar: autoHideMenuBarSetting,
title: appConfig.name,
webPreferences: defaults.webPreferences
}, browserOpts))
Expand Down Expand Up @@ -242,6 +245,18 @@ const filterOutNonRecents = debounce(() => {
emitChanges()
}, 60 * 1000)

function handleChangeSettingAction (settingKey, settingValue) {
switch (settingKey) {
case settings.AUTO_HIDE_MENU_BAR:
BrowserWindow.getAllWindows().forEach(function (wnd) {
wnd.setAutoHideMenuBar(settingValue)
wnd.setMenuBarVisibility(!settingValue)
})
break
default:
}
}

const handleAppAction = (action) => {
switch (action.actionType) {
case AppConstants.APP_SET_STATE:
Expand Down Expand Up @@ -391,6 +406,7 @@ const handleAppAction = (action) => {
break
case AppConstants.APP_CHANGE_SETTING:
appState = appState.setIn(['settings', action.key], action.value)
handleChangeSettingAction(action.key, action.value)
break
case AppConstants.APP_CHANGE_SITE_SETTING:
let propertyName = action.temporary ? 'temporarySiteSettings' : 'siteSettings'
Expand Down