From 267d0e3ded0e57575fc678f4c4b4906afe49db96 Mon Sep 17 00:00:00 2001 From: Yuya Ochiai Date: Thu, 14 Jan 2016 22:50:12 +0900 Subject: [PATCH] Show menubar in default setttings on Windows, and add the option to hide --- src/browser/settings.jsx | 54 +++++++++++++++++++++++++++++----------- src/main.js | 9 ++++--- 2 files changed, 45 insertions(+), 18 deletions(-) diff --git a/src/browser/settings.jsx b/src/browser/settings.jsx index cc5f9d5d..50c796c0 100644 --- a/src/browser/settings.jsx +++ b/src/browser/settings.jsx @@ -6,6 +6,7 @@ const settings = require('../common/settings'); const Grid = ReactBootstrap.Grid; const Row = ReactBootstrap.Row; const Col = ReactBootstrap.Col; +const Input = ReactBootstrap.Input; const Button = ReactBootstrap.Button; const ListGroup = ReactBootstrap.ListGroup; const ListGroupItem = ReactBootstrap.ListGroupItem; @@ -13,15 +14,11 @@ const Glyphicon = ReactBootstrap.Glyphicon; var SettingsPage = React.createClass({ getInitialState: function() { - return { - teams: [] - }; - }, - componentDidMount: function() { var config = settings.readFileSync(this.props.configFile); - this.setState({ - teams: config.teams - }) + return { + teams: config.teams, + hideMenuBar: config.hideMenuBar + }; }, handleTeamsChange: function(teams) { this.setState({ @@ -31,23 +28,50 @@ var SettingsPage = React.createClass({ handleSave: function() { var config = { teams: this.state.teams, - version: 1 + hideMenuBar: this.refs.hideMenuBar.getChecked(), + version: settings.version }; settings.writeFileSync(this.props.configFile, config); + var currentWindow = remote.getCurrentWindow(); + currentWindow.setAutoHideMenuBar(config.hideMenuBar); + currentWindow.setMenuBarVisibility(!config.hideMenuBar); window.location = './index.html'; }, handleCancel: function() { window.location = './index.html'; }, + handleChangeHideMenuBar: function() { + this.setState({ + hideMenuBar: this.refs.hideMenuBar.getChecked() + }); + }, render: function() { + var teams_row = ( + + +

Teams

+ + +
+ ); + + var options = []; + if (process.platform === 'win32') { + options.push(); + } + var options_row = (options.length > 0) ? ( + + +

Options

+ { options } + +
+ ) : null; + return ( - - -

Teams

- - -
+ { teams_row } + { options_row } diff --git a/src/main.js b/src/main.js index 46121107..37e3eecf 100644 --- a/src/main.js +++ b/src/main.js @@ -28,9 +28,10 @@ else { global['config-file'] = app.getPath('userData') + '/config.json' } +var config = {}; try { var configFile = global['config-file']; - var config = settings.readFileSync(configFile); + config = settings.readFileSync(configFile); if (config.version != settings.version) { config = settings.upgrade(config); settings.writeFileSync(configFile, config); @@ -61,8 +62,10 @@ app.on('window-all-closed', function() { // For win32, auto-hide menu bar. app.on('browser-window-created', function(event, window) { if (process.platform === 'win32') { - window.setAutoHideMenuBar(true); - window.setMenuBarVisibility(false); + if (config.hideMenuBar) { + window.setAutoHideMenuBar(true); + window.setMenuBarVisibility(false); + } } });