Window is hidden also on minimize and a click on the tray icon toggles the window
This commit is contained in:
@@ -61,6 +61,7 @@ var SettingsPage = React.createClass({
|
|||||||
trayIconTheme: this.state.trayIconTheme,
|
trayIconTheme: this.state.trayIconTheme,
|
||||||
disablewebsecurity: this.state.disablewebsecurity,
|
disablewebsecurity: this.state.disablewebsecurity,
|
||||||
version: settings.version,
|
version: settings.version,
|
||||||
|
minimizeToTray: this.state.minimizeToTray,
|
||||||
notifications: {
|
notifications: {
|
||||||
flashWindow: this.state.notifications.flashWindow
|
flashWindow: this.state.notifications.flashWindow
|
||||||
}
|
}
|
||||||
@@ -114,6 +115,11 @@ var SettingsPage = React.createClass({
|
|||||||
autostart: this.refs.autostart.getChecked()
|
autostart: this.refs.autostart.getChecked()
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
handleChangeMinimizeToTray: function() {
|
||||||
|
this.setState({
|
||||||
|
minimizeToTray: this.refs.minimizeToTray.getChecked()
|
||||||
|
});
|
||||||
|
},
|
||||||
toggleShowTeamForm: function() {
|
toggleShowTeamForm: function() {
|
||||||
this.setState({
|
this.setState({
|
||||||
showAddTeamForm: !this.state.showAddTeamForm
|
showAddTeamForm: !this.state.showAddTeamForm
|
||||||
@@ -156,6 +162,8 @@ var SettingsPage = React.createClass({
|
|||||||
if (process.platform === 'win32' || process.platform === 'linux') {
|
if (process.platform === 'win32' || process.platform === 'linux') {
|
||||||
options.push(<Input key="inputAutoStart" id="inputAutoStart" ref="autostart" type="checkbox" label="Start app on login." checked={ this.state.autostart } onChange={ this.handleChangeAutoStart }
|
options.push(<Input key="inputAutoStart" id="inputAutoStart" ref="autostart" type="checkbox" label="Start app on login." checked={ this.state.autostart } onChange={ this.handleChangeAutoStart }
|
||||||
/>);
|
/>);
|
||||||
|
options.push(<Input key="inputMinimizeToTray" id="inputMinimizeToTray" ref="minimizeToTray" type="checkbox" label="Minimize app to tray." checked={ this.state.minimizeToTray } onChange={ this.handleChangeMinimizeToTray }
|
||||||
|
/>);
|
||||||
}
|
}
|
||||||
var options_row = (options.length > 0) ? (
|
var options_row = (options.length > 0) ? (
|
||||||
<Row>
|
<Row>
|
||||||
|
@@ -26,6 +26,7 @@ var loadDefault = function(version) {
|
|||||||
showTrayIcon: false,
|
showTrayIcon: false,
|
||||||
trayIconTheme: '',
|
trayIconTheme: '',
|
||||||
disablewebsecurity: true,
|
disablewebsecurity: true,
|
||||||
|
minimizeToTray: 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
|
||||||
@@ -38,7 +39,7 @@ var upgradeV0toV1 = function(config_v0) {
|
|||||||
var config = loadDefault(1);
|
var config = loadDefault(1);
|
||||||
config.teams.push({
|
config.teams.push({
|
||||||
name: 'Primary team',
|
name: 'Primary team',
|
||||||
url: config_v0.url
|
url: config_v0.url
|
||||||
});
|
});
|
||||||
return config;
|
return config;
|
||||||
};
|
};
|
||||||
|
36
src/main.js
36
src/main.js
@@ -156,6 +156,7 @@ app.on('browser-window-created', function(event, window) {
|
|||||||
// For OSX, show hidden mainWindow when clicking dock icon.
|
// For OSX, show hidden mainWindow when clicking dock icon.
|
||||||
app.on('activate', function(event) {
|
app.on('activate', function(event) {
|
||||||
mainWindow.show();
|
mainWindow.show();
|
||||||
|
mainWindow.isHidden = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
app.on('before-quit', function() {
|
app.on('before-quit', function() {
|
||||||
@@ -227,14 +228,29 @@ app.on('ready', function() {
|
|||||||
|
|
||||||
trayIcon.setToolTip(app.getName());
|
trayIcon.setToolTip(app.getName());
|
||||||
trayIcon.on('click', function() {
|
trayIcon.on('click', function() {
|
||||||
mainWindow.show();
|
if (process.platform === 'win32') {
|
||||||
|
if (config.minimizeToTray) {
|
||||||
|
if (mainWindow.isHidden) {
|
||||||
|
mainWindow.show();
|
||||||
|
mainWindow.isHidden = false;
|
||||||
|
} else {
|
||||||
|
mainWindow.hide();
|
||||||
|
mainWindow.isHidden = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
mainWindow.focus();
|
mainWindow.focus();
|
||||||
});
|
});
|
||||||
trayIcon.on('right-click', () => {
|
trayIcon.on('right-click', () => {
|
||||||
trayIcon.popUpContextMenu();
|
trayIcon.popUpContextMenu();
|
||||||
});
|
});
|
||||||
trayIcon.on('balloon-click', function() {
|
trayIcon.on('balloon-click', function() {
|
||||||
mainWindow.show();
|
if (process.platform === 'win32') {
|
||||||
|
if (config.minimizeToTray) {
|
||||||
|
mainWindow.show();
|
||||||
|
mainWindow.isHidden = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
mainWindow.focus();
|
mainWindow.focus();
|
||||||
});
|
});
|
||||||
ipcMain.on('notified', function(event, arg) {
|
ipcMain.on('notified', function(event, arg) {
|
||||||
@@ -348,7 +364,12 @@ app.on('ready', function() {
|
|||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
switch (process.platform) {
|
switch (process.platform) {
|
||||||
case 'win32':
|
case 'win32':
|
||||||
mainWindow.hide();
|
if (config.minimizeToTray) {
|
||||||
|
mainWindow.hide();
|
||||||
|
mainWindow.isHidden = true;
|
||||||
|
} else {
|
||||||
|
mainWindow.minimize();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'linux':
|
case 'linux':
|
||||||
mainWindow.minimize();
|
mainWindow.minimize();
|
||||||
@@ -361,6 +382,15 @@ app.on('ready', function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (process.platform === 'win32') {
|
||||||
|
mainWindow.on('minimize', function() {
|
||||||
|
if (config.minimizeToTray) {
|
||||||
|
mainWindow.hide();
|
||||||
|
mainWindow.isHidden = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// App should save bounds when a window is closed.
|
// App should save bounds when a window is closed.
|
||||||
// However, 'close' is not fired in some situations(shutdown, ctrl+c)
|
// However, 'close' is not fired in some situations(shutdown, ctrl+c)
|
||||||
// because main process is killed in such situations.
|
// because main process is killed in such situations.
|
||||||
|
Reference in New Issue
Block a user