Add setting for "Toggle the window on tray icon click"

This commit is contained in:
Martin Gondermann 2016-06-28 15:07:29 +02:00
parent d6de73458c
commit 1f312e1f7f
3 changed files with 23 additions and 2 deletions

View file

@ -62,6 +62,7 @@ var SettingsPage = React.createClass({
disablewebsecurity: this.state.disablewebsecurity, disablewebsecurity: this.state.disablewebsecurity,
version: settings.version, version: settings.version,
minimizeToTray: this.state.minimizeToTray, minimizeToTray: this.state.minimizeToTray,
toggleWindowOnTrayIconClick: this.state.toggleWindowOnTrayIconClick,
notifications: { notifications: {
flashWindow: this.state.notifications.flashWindow flashWindow: this.state.notifications.flashWindow
} }
@ -116,9 +117,27 @@ var SettingsPage = React.createClass({
}); });
}, },
handleChangeMinimizeToTray: function() { handleChangeMinimizeToTray: function() {
var isChecked = this.refs.minimizeToTray.getChecked();
this.setState({ this.setState({
minimizeToTray: this.refs.minimizeToTray.getChecked() minimizeToTray: isChecked
}); });
if (!isChecked) {
this.setState({
toggleWindowOnTrayIconClick: false
});
}
},
handleChangeToggleWindowOnTrayIconClick: function() {
if (this.refs.minimizeToTray.getChecked()) {
this.setState({
toggleWindowOnTrayIconClick: this.refs.toggleWindowOnTrayIconClick.getChecked()
});
} else {
this.setState({
toggleWindowOnTrayIconClick: false
});
}
}, },
toggleShowTeamForm: function() { toggleShowTeamForm: function() {
this.setState({ this.setState({
@ -166,6 +185,7 @@ var SettingsPage = React.createClass({
if (process.platform === 'win32') { if (process.platform === 'win32') {
options.push(<Input key="inputMinimizeToTray" id="inputMinimizeToTray" ref="minimizeToTray" type="checkbox" label="Minimize app to tray." checked={ this.state.minimizeToTray } onChange={ this.handleChangeMinimizeToTray } options.push(<Input key="inputMinimizeToTray" id="inputMinimizeToTray" ref="minimizeToTray" type="checkbox" label="Minimize app to tray." checked={ this.state.minimizeToTray } onChange={ this.handleChangeMinimizeToTray }
/>); />);
options.push(<Input key="inputToggleWindowOnTrayIconClick" id="inputToggleWindowOnTrayIconClick" ref="toggleWindowOnTrayIconClick" type="checkbox" label="Toggle window visibility when clicking on the tray icon." disabled={ !this.state.minimizeToTray } checked={ this.state.toggleWindowOnTrayIconClick } onChange={ this.handleChangeToggleWindowOnTrayIconClick }/>);
} }
var options_row = (options.length > 0) ? ( var options_row = (options.length > 0) ? (
<Row> <Row>

View file

@ -27,6 +27,7 @@ var loadDefault = function(version) {
trayIconTheme: '', trayIconTheme: '',
disablewebsecurity: true, disablewebsecurity: true,
minimizeToTray: false, minimizeToTray: false,
toggleWindowOnTrayIconClick: false,
version: 1, version: 1,
notifications: { notifications: {
flashWindow: 0 // 0 = flash never, 1 = only when idle (after 10 seconds), 2 = always flashWindow: 0 // 0 = flash never, 1 = only when idle (after 10 seconds), 2 = always

View file

@ -234,7 +234,7 @@ app.on('ready', function() {
mainWindow.show(); mainWindow.show();
mainWindow.isHidden = false; mainWindow.isHidden = false;
} }
else { else if (config.toggleWindowOnTrayIconClick) {
mainWindow.hide(); mainWindow.hide();
mainWindow.isHidden = true; mainWindow.isHidden = true;
} }