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 {
|
||||
teams: config.teams,
|
||||
hideMenuBar: config.hideMenuBar
|
||||
hideMenuBar: config.hideMenuBar,
|
||||
showTrayIcon: config.showTrayIcon
|
||||
};
|
||||
},
|
||||
handleTeamsChange: function(teams) {
|
||||
|
@ -42,6 +43,7 @@ var SettingsPage = React.createClass({
|
|||
var config = {
|
||||
teams: this.state.teams,
|
||||
hideMenuBar: this.state.hideMenuBar,
|
||||
showTrayIcon: this.state.showTrayIcon,
|
||||
version: settings.version
|
||||
};
|
||||
settings.writeFileSync(this.props.configFile, config);
|
||||
|
@ -60,6 +62,11 @@ var SettingsPage = React.createClass({
|
|||
hideMenuBar: this.refs.hideMenuBar.getChecked()
|
||||
});
|
||||
},
|
||||
handleChangeShowTrayIcon: function() {
|
||||
this.setState({
|
||||
showTrayIcon: this.refs.showTrayIcon.getChecked()
|
||||
});
|
||||
},
|
||||
render: function() {
|
||||
var teams_row = (
|
||||
<Row>
|
||||
|
@ -74,6 +81,10 @@ var SettingsPage = React.createClass({
|
|||
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 } />);
|
||||
}
|
||||
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) ? (
|
||||
<Row>
|
||||
<Col md={ 12 }>
|
||||
|
|
|
@ -23,6 +23,7 @@ var loadDefault = function(version) {
|
|||
return {
|
||||
teams: [],
|
||||
hideMenuBar: false,
|
||||
showTrayIcon: false,
|
||||
version: 1
|
||||
};
|
||||
}
|
||||
|
|
12
src/main.js
12
src/main.js
|
@ -69,6 +69,16 @@ const trayImages = function() {
|
|||
}();
|
||||
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) {
|
||||
event.preventDefault();
|
||||
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
|
||||
// initialization and is ready to create browser windows.
|
||||
app.on('ready', function() {
|
||||
if (process.platform === 'win32' || process.platform === 'darwin') {
|
||||
if (shouldShowTrayIcon()) {
|
||||
// set up tray icon
|
||||
trayIcon = new Tray(trayImages.normal);
|
||||
trayIcon.setToolTip(app.getName());
|
||||
|
|
Loading…
Reference in a new issue