From d81d960f9a31bad93796d7dbf4fbda9e1b7da1ac Mon Sep 17 00:00:00 2001 From: Brian Clifton Date: Sun, 1 May 2016 23:40:13 -0700 Subject: [PATCH 1/9] Auto hide of the menu bar is now configurable (defaults to false). At the moment, setting only takes effect when launching browser (restart required on change). --- app/extensions/brave/locales/en-US/preferences.properties | 2 ++ js/about/preferences.js | 3 +++ js/constants/appConfig.js | 1 + js/constants/settings.js | 1 + js/stores/appStore.js | 4 +++- 5 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/extensions/brave/locales/en-US/preferences.properties b/app/extensions/brave/locales/en-US/preferences.properties index 09700ce403b..a56e23b91ae 100644 --- a/app/extensions/brave/locales/en-US/preferences.properties +++ b/app/extensions/brave/locales/en-US/preferences.properties @@ -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 diff --git a/js/about/preferences.js b/js/about/preferences.js index 4a530525d5e..a2ec1a0b312 100644 --- a/js/about/preferences.js +++ b/js/about/preferences.js @@ -130,6 +130,9 @@ class GeneralTab extends ImmutableComponent { + + + } } diff --git a/js/constants/appConfig.js b/js/constants/appConfig.js index 8fbe5d4dc4c..f24c1898877 100644 --- a/js/constants/appConfig.js +++ b/js/constants/appConfig.js @@ -76,6 +76,7 @@ module.exports = { 'general.homepage': 'https://www.brave.com', 'general.show-home-button': false, 'general.useragent.value': null, // Set at runtime + 'general.autohide-menubar': false, 'search.default-search-engine': 'content/search/google.xml', 'tabs.switch-to-new-tabs': false, 'tabs.paint-tabs': true, diff --git a/js/constants/settings.js b/js/constants/settings.js index 00d7decdc54..a879a0fea34 100644 --- a/js/constants/settings.js +++ b/js/constants/settings.js @@ -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 diff --git a/js/stores/appStore.js b/js/stores/appStore.js index c8d8f9ca14c..e765eb094f2 100644 --- a/js/stores/appStore.js +++ b/js/stores/appStore.js @@ -109,6 +109,8 @@ const createWindow = (browserOpts, defaults) => { browserOpts.width = browserOpts.width < minWidth ? minWidth : browserOpts.width browserOpts.height = browserOpts.height < minHeight ? minHeight : browserOpts.height + const autoHideMenuBarSetting = getSetting(settings.AUTO_HIDE_MENU_BAR) + let mainWindow = new BrowserWindow(Object.assign({ // smaller min size for "modal" windows minWidth, @@ -117,7 +119,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)) From dac5e1c67958555a28cb14b78663cf2d90b491d1 Mon Sep 17 00:00:00 2001 From: Brian Clifton Date: Sat, 7 May 2016 09:19:52 -0700 Subject: [PATCH 2/9] Moved home button down to new "Appearance settings" area of general --- js/about/preferences.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/about/preferences.js b/js/about/preferences.js index a2ec1a0b312..06d418bfa6f 100644 --- a/js/about/preferences.js +++ b/js/about/preferences.js @@ -124,14 +124,14 @@ class GeneralTab extends ImmutableComponent { value={getSetting(settings.HOMEPAGE, this.props.settings)} onChange={changeSetting.bind(null, this.props.onChangeSetting, settings.HOMEPAGE)} /> - - + + } From 07b6c4b20eef881b42b500ce22b0dd9b3c7290dc Mon Sep 17 00:00:00 2001 From: Brian Clifton Date: Sun, 8 May 2016 02:17:05 -0700 Subject: [PATCH 3/9] Introducing a handler for settings (about:preferences) that change. This first handler will show/hide the application menu. --- js/stores/appStore.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/js/stores/appStore.js b/js/stores/appStore.js index e765eb094f2..7e654805815 100644 --- a/js/stores/appStore.js +++ b/js/stores/appStore.js @@ -244,6 +244,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: @@ -393,6 +405,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' From d84ad70962d323e4375a342a74152c7b2aae410d Mon Sep 17 00:00:00 2001 From: Brian Clifton Date: Sun, 8 May 2016 02:20:05 -0700 Subject: [PATCH 4/9] Default autohide-menubar=true. Per https://github.com/brave/browser-laptop/issues/1524, it should only default to false on Windows (will update in a following commit). --- js/constants/appConfig.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/constants/appConfig.js b/js/constants/appConfig.js index f24c1898877..c6cfb8d625b 100644 --- a/js/constants/appConfig.js +++ b/js/constants/appConfig.js @@ -76,7 +76,7 @@ module.exports = { 'general.homepage': 'https://www.brave.com', 'general.show-home-button': false, 'general.useragent.value': null, // Set at runtime - 'general.autohide-menubar': false, + 'general.autohide-menubar': true, 'search.default-search-engine': 'content/search/google.xml', 'tabs.switch-to-new-tabs': false, 'tabs.paint-tabs': true, From f5ff45010cc471851fcf86ee0321231f5ded57b1 Mon Sep 17 00:00:00 2001 From: Brian Clifton Date: Sun, 8 May 2016 02:50:55 -0700 Subject: [PATCH 5/9] Show "hide the menu bar" in the context menu displayed when you right click in bookmarks toolbar --- app/extensions/brave/locales/en-US/menu.properties | 1 + app/locale.js | 3 ++- js/commonMenu.js | 12 ++++++++++++ js/contextMenus.js | 2 ++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/extensions/brave/locales/en-US/menu.properties b/app/extensions/brave/locales/en-US/menu.properties index 465a7fb7414..0249b2ffdc0 100644 --- a/app/extensions/brave/locales/en-US/menu.properties +++ b/app/extensions/brave/locales/en-US/menu.properties @@ -120,3 +120,4 @@ zoom=Zoom new=New learnSpelling=Learn Spelling ignoreSpelling=Ignore Spelling +autoHideMenuBar=Hide the menu bar diff --git a/app/locale.js b/app/locale.js index 9d57b1c3b0c..05dfb283b3e 100644 --- a/app/locale.js +++ b/app/locale.js @@ -135,7 +135,8 @@ var rendererIdentifiers = function () { 'learnSpelling', 'ignoreSpelling', // Other identifiers - 'urlCopied' + 'urlCopied', + 'autoHideMenuBar' ] } diff --git a/js/commonMenu.js b/js/commonMenu.js index 61304aa4ee7..1096d228906 100644 --- a/js/commonMenu.js +++ b/js/commonMenu.js @@ -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, diff --git a/js/contextMenus.js b/js/contextMenus.js index a06fd2f15cd..852f2619aa9 100644 --- a/js/contextMenus.js +++ b/js/contextMenus.js @@ -82,6 +82,8 @@ function tabsToolbarTemplateInit (activeFrame, closestDestinationDetail, isParen CommonMenu.bookmarksMenuItem(), CommonMenu.bookmarksToolbarMenuItem(), CommonMenu.separatorMenuItem, + CommonMenu.autoHideMenuBarMenuItem(), + CommonMenu.separatorMenuItem, addBookmarkMenuItem('addBookmark', siteUtil.getDetailFromFrame(activeFrame, siteTags.BOOKMARK), closestDestinationDetail, isParent), addFolderMenuItem(closestDestinationDetail, isParent) ] From 7b036c0abc27d516befe5e7357ba6620fe488ca2 Mon Sep 17 00:00:00 2001 From: Brian Clifton Date: Mon, 9 May 2016 00:05:17 -0700 Subject: [PATCH 6/9] Defaults to false (show the menu) on Windows. All other platforms default to true (hide the menu). --- js/constants/appConfig.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/js/constants/appConfig.js b/js/constants/appConfig.js index c6cfb8d625b..fff987b7299 100644 --- a/js/constants/appConfig.js +++ b/js/constants/appConfig.js @@ -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' ? false : true; + module.exports = { name: 'Brave', contactUrl: 'mailto:support+laptop@brave.com', @@ -76,7 +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': true, + 'general.autohide-menubar': autoHideMenuBar, 'search.default-search-engine': 'content/search/google.xml', 'tabs.switch-to-new-tabs': false, 'tabs.paint-tabs': true, From 0a6d5cdcea93067c62907151d9a9de670b5294c8 Mon Sep 17 00:00:00 2001 From: Brian Clifton Date: Mon, 9 May 2016 07:53:11 -0700 Subject: [PATCH 7/9] Fix linting errors. I had to manually run because pre-commit package failed to install when doing a fresh npm install. --- js/constants/appConfig.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/constants/appConfig.js b/js/constants/appConfig.js index fff987b7299..351ef9804c7 100644 --- a/js/constants/appConfig.js +++ b/js/constants/appConfig.js @@ -8,7 +8,7 @@ const winUpdateHost = process.env.BRAVE_WIN_UPDATE_HOST || 'https://brave-downlo const crashURL = process.env.BRAVE_CRASH_URL || 'https://laptop-updates.brave.com/1/crashes' // Windows specific configuration settings. -const autoHideMenuBar = process.platform === 'win32' ? false : true; +const autoHideMenuBar = process.platform !== 'win32' module.exports = { name: 'Brave', From 538108112d61f2af94a4ded1471d9f87c5305238 Mon Sep 17 00:00:00 2001 From: Brian Clifton Date: Mon, 9 May 2016 13:45:26 -0700 Subject: [PATCH 8/9] - Fixed text in the menu.properties file (use recommended wording/casing) - Don't show "hide menu bar" in bookmarks toolbar context menu for OS X - Always set autoHideMenuBar to true (when creating BrowserWindow) for OS X --- .../brave/locales/en-US/menu.properties | 2 +- js/contextMenus.js | 19 +++++++++++++------ js/stores/appStore.js | 3 ++- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/app/extensions/brave/locales/en-US/menu.properties b/app/extensions/brave/locales/en-US/menu.properties index 0249b2ffdc0..142264a5ca1 100644 --- a/app/extensions/brave/locales/en-US/menu.properties +++ b/app/extensions/brave/locales/en-US/menu.properties @@ -120,4 +120,4 @@ zoom=Zoom new=New learnSpelling=Learn Spelling ignoreSpelling=Ignore Spelling -autoHideMenuBar=Hide the menu bar +autoHideMenuBar=Hide Menu Bar diff --git a/js/contextMenus.js b/js/contextMenus.js index 852f2619aa9..cfd910fd3f1 100644 --- a/js/contextMenus.js +++ b/js/contextMenus.js @@ -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 @@ -78,15 +79,21 @@ function inputTemplateInit (e) { } function tabsToolbarTemplateInit (activeFrame, closestDestinationDetail, isParent) { - return [ + const menu = [ CommonMenu.bookmarksMenuItem(), CommonMenu.bookmarksToolbarMenuItem(), - CommonMenu.separatorMenuItem, - CommonMenu.autoHideMenuBarMenuItem(), - 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) { diff --git a/js/stores/appStore.js b/js/stores/appStore.js index 7e654805815..e3a89219742 100644 --- a/js/stores/appStore.js +++ b/js/stores/appStore.js @@ -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' @@ -109,7 +110,7 @@ const createWindow = (browserOpts, defaults) => { browserOpts.width = browserOpts.width < minWidth ? minWidth : browserOpts.width browserOpts.height = browserOpts.height < minHeight ? minHeight : browserOpts.height - const autoHideMenuBarSetting = getSetting(settings.AUTO_HIDE_MENU_BAR) + const autoHideMenuBarSetting = isDarwin || getSetting(settings.AUTO_HIDE_MENU_BAR) let mainWindow = new BrowserWindow(Object.assign({ // smaller min size for "modal" windows From 84e0dd24a993a07b99ae60555c91b74f03c8500d Mon Sep 17 00:00:00 2001 From: Brian Clifton Date: Mon, 9 May 2016 21:02:47 -0700 Subject: [PATCH 9/9] autoHideMenuBar option no longer shows in prefs for OS X --- js/about/preferences.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/js/about/preferences.js b/js/about/preferences.js index 06d418bfa6f..c0aaf6eb0a3 100644 --- a/js/about/preferences.js +++ b/js/about/preferences.js @@ -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 @@ -131,7 +132,9 @@ class GeneralTab extends ImmutableComponent { - + { + isDarwin ? null : + } }