Make the tray icon to be optional
This commit is contained in:
parent
f027008bd1
commit
8883ce3229
|
@ -30,7 +30,8 @@ var SettingsPage = React.createClass({
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
teams: config.teams,
|
teams: config.teams,
|
||||||
hideMenuBar: config.hideMenuBar
|
hideMenuBar: config.hideMenuBar,
|
||||||
|
showTrayIcon: config.showTrayIcon
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
handleTeamsChange: function(teams) {
|
handleTeamsChange: function(teams) {
|
||||||
|
@ -42,6 +43,7 @@ var SettingsPage = React.createClass({
|
||||||
var config = {
|
var config = {
|
||||||
teams: this.state.teams,
|
teams: this.state.teams,
|
||||||
hideMenuBar: this.state.hideMenuBar,
|
hideMenuBar: this.state.hideMenuBar,
|
||||||
|
showTrayIcon: this.state.showTrayIcon,
|
||||||
version: settings.version
|
version: settings.version
|
||||||
};
|
};
|
||||||
settings.writeFileSync(this.props.configFile, config);
|
settings.writeFileSync(this.props.configFile, config);
|
||||||
|
@ -60,6 +62,11 @@ var SettingsPage = React.createClass({
|
||||||
hideMenuBar: this.refs.hideMenuBar.getChecked()
|
hideMenuBar: this.refs.hideMenuBar.getChecked()
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
handleChangeShowTrayIcon: function() {
|
||||||
|
this.setState({
|
||||||
|
showTrayIcon: this.refs.showTrayIcon.getChecked()
|
||||||
|
});
|
||||||
|
},
|
||||||
render: function() {
|
render: function() {
|
||||||
var teams_row = (
|
var teams_row = (
|
||||||
<Row>
|
<Row>
|
||||||
|
@ -74,6 +81,10 @@ var SettingsPage = React.createClass({
|
||||||
if (process.platform === 'win32' || process.platform === 'linux') {
|
if (process.platform === 'win32' || process.platform === 'linux') {
|
||||||
options.push(<Input ref="hideMenuBar" type="checkbox" label="Hide Menu Bar (Press Alt to show Menu Bar)" checked={ this.state.hideMenuBar } onChange={ this.handleChangeHideMenuBar } />);
|
options.push(<Input ref="hideMenuBar" type="checkbox" label="Hide Menu Bar (Press Alt to show Menu Bar)" checked={ this.state.hideMenuBar } onChange={ this.handleChangeHideMenuBar } />);
|
||||||
}
|
}
|
||||||
|
if (process.platform === 'darwin') {
|
||||||
|
options.push(<Input ref="showTrayIcon" type="checkbox" label="Show Icon on Menu Bar (Need to restart the application)" checked={ this.state.showTrayIcon } onChange={ this.handleChangeShowTrayIcon }
|
||||||
|
/>);
|
||||||
|
}
|
||||||
var options_row = (options.length > 0) ? (
|
var options_row = (options.length > 0) ? (
|
||||||
<Row>
|
<Row>
|
||||||
<Col md={ 12 }>
|
<Col md={ 12 }>
|
||||||
|
|
|
@ -23,6 +23,7 @@ var loadDefault = function(version) {
|
||||||
return {
|
return {
|
||||||
teams: [],
|
teams: [],
|
||||||
hideMenuBar: false,
|
hideMenuBar: false,
|
||||||
|
showTrayIcon: false,
|
||||||
version: 1
|
version: 1
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
12
src/main.js
12
src/main.js
|
@ -69,6 +69,16 @@ const trayImages = function() {
|
||||||
}();
|
}();
|
||||||
var willAppQuit = false;
|
var willAppQuit = false;
|
||||||
|
|
||||||
|
function shouldShowTrayIcon() {
|
||||||
|
if (process.platform === 'win32') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (process.platform === 'darwin' && config.showTrayIcon === true) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
app.on('login', function(event, webContents, request, authInfo, callback) {
|
app.on('login', function(event, webContents, request, authInfo, callback) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
var readlineSync = require('readline-sync');
|
var readlineSync = require('readline-sync');
|
||||||
|
@ -144,7 +154,7 @@ app.on('certificate-error', function(event, webContents, url, error, certificate
|
||||||
// This method will be called when Electron has finished
|
// This method will be called when Electron has finished
|
||||||
// initialization and is ready to create browser windows.
|
// initialization and is ready to create browser windows.
|
||||||
app.on('ready', function() {
|
app.on('ready', function() {
|
||||||
if (process.platform === 'win32' || process.platform === 'darwin') {
|
if (shouldShowTrayIcon()) {
|
||||||
// set up tray icon
|
// set up tray icon
|
||||||
trayIcon = new Tray(trayImages.normal);
|
trayIcon = new Tray(trayImages.normal);
|
||||||
trayIcon.setToolTip(app.getName());
|
trayIcon.setToolTip(app.getName());
|
||||||
|
|
Loading…
Reference in a new issue