OSX: Added Option to hide Window from dock on close
This commit is contained in:
@@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
#### OS X
|
#### OS X
|
||||||
- Fixed that two icons appear on a notification.
|
- Fixed that two icons appear on a notification.
|
||||||
|
- Added Option to hide Window from dock on close
|
||||||
|
|
||||||
### Improvements
|
### Improvements
|
||||||
- Added shortcuts
|
- Added shortcuts
|
||||||
|
@@ -124,7 +124,7 @@ The Settings Page is available from the **File** menu under **Settings** (Click
|
|||||||
This option allows such images to be rendered, but please be careful for security.
|
This option allows such images to be rendered, but please be careful for security.
|
||||||
- **Start app on login** (Windows, Linux)
|
- **Start app on login** (Windows, Linux)
|
||||||
- This option starts the application when you login.
|
- This option starts the application when you login.
|
||||||
- **Leave app running in notification area when the window is closed** (Windows)
|
- **Leave app running in notification area when the window is closed** (Windows, OS X)
|
||||||
- This option hides the window to the system tray, if the window is closed
|
- This option hides the window to the system tray, if the window is closed
|
||||||
- **Toggle window visibility when clicking on the tray icon** (Windows)
|
- **Toggle window visibility when clicking on the tray icon** (Windows)
|
||||||
- If checked, then a click on the system tray icon leads to a toggling of the minimized/maximized state of the window
|
- If checked, then a click on the system tray icon leads to a toggling of the minimized/maximized state of the window
|
||||||
|
@@ -102,9 +102,16 @@ var SettingsPage = React.createClass({
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
handleChangeShowTrayIcon: function() {
|
handleChangeShowTrayIcon: function() {
|
||||||
|
var shouldShowTrayIcon = this.refs.showTrayIcon.getChecked();
|
||||||
this.setState({
|
this.setState({
|
||||||
showTrayIcon: this.refs.showTrayIcon.getChecked()
|
showTrayIcon: shouldShowTrayIcon
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (process.platform === 'darwin' && !shouldShowTrayIcon) {
|
||||||
|
this.setState({
|
||||||
|
minimizeToTray: false
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
handleChangeTrayIconTheme: function() {
|
handleChangeTrayIconTheme: function() {
|
||||||
this.setState({
|
this.setState({
|
||||||
@@ -117,8 +124,11 @@ var SettingsPage = React.createClass({
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
handleChangeMinimizeToTray: function() {
|
handleChangeMinimizeToTray: function() {
|
||||||
|
var shouldMinimizeToTray = (process.platform !== 'darwin' || this.refs.showTrayIcon.getChecked())
|
||||||
|
&& this.refs.minimizeToTray.getChecked();
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
minimizeToTray: this.refs.minimizeToTray.getChecked()
|
minimizeToTray: shouldMinimizeToTray
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
handleChangeToggleWindowOnTrayIconClick: function() {
|
handleChangeToggleWindowOnTrayIconClick: function() {
|
||||||
@@ -172,6 +182,12 @@ var SettingsPage = React.createClass({
|
|||||||
if (process.platform === 'win32') {
|
if (process.platform === 'win32') {
|
||||||
options.push(<Input key="inputMinimizeToTray" id="inputMinimizeToTray" ref="minimizeToTray" type="checkbox" label="Leave app running in notification area when the window is closed"
|
options.push(<Input key="inputMinimizeToTray" id="inputMinimizeToTray" ref="minimizeToTray" type="checkbox" label="Leave app running in notification area when the window is closed"
|
||||||
checked={ this.state.minimizeToTray } onChange={ this.handleChangeMinimizeToTray } />);
|
checked={ this.state.minimizeToTray } onChange={ this.handleChangeMinimizeToTray } />);
|
||||||
|
} else if (process.platform === 'darwin') {
|
||||||
|
options.push(<Input key="inputMinimizeToTray" id="inputMinimizeToTray" ref="minimizeToTray" type="checkbox" label="Leave app running in notification area when the window is closed"
|
||||||
|
disabled={ !this.state.showTrayIcon } checked={ this.state.minimizeToTray } onChange={ this.handleChangeMinimizeToTray } />);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (process.platform === 'win32') {
|
||||||
options.push(<Input key="inputToggleWindowOnTrayIconClick" id="inputToggleWindowOnTrayIconClick" ref="toggleWindowOnTrayIconClick" type="checkbox" label="Toggle window visibility when clicking on the tray icon."
|
options.push(<Input key="inputToggleWindowOnTrayIconClick" id="inputToggleWindowOnTrayIconClick" ref="toggleWindowOnTrayIconClick" type="checkbox" label="Toggle window visibility when clicking on the tray icon."
|
||||||
checked={ this.state.toggleWindowOnTrayIconClick } onChange={ this.handleChangeToggleWindowOnTrayIconClick } />);
|
checked={ this.state.toggleWindowOnTrayIconClick } onChange={ this.handleChangeToggleWindowOnTrayIconClick } />);
|
||||||
}
|
}
|
||||||
|
21
src/main.js
21
src/main.js
@@ -241,10 +241,22 @@ app.on('ready', function() {
|
|||||||
mainWindow.focus();
|
mainWindow.focus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (process.platform === 'darwin') {
|
||||||
|
if (mainWindow.isHidden || mainWindow.isMinimized()) {
|
||||||
|
mainWindow.show();
|
||||||
|
mainWindow.isHidden = false;
|
||||||
|
mainWindow.focus();
|
||||||
|
app.dock.show();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
mainWindow.focus();
|
||||||
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
mainWindow.focus();
|
mainWindow.focus();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
trayIcon.on('right-click', () => {
|
trayIcon.on('right-click', () => {
|
||||||
trayIcon.popUpContextMenu();
|
trayIcon.popUpContextMenu();
|
||||||
});
|
});
|
||||||
@@ -380,7 +392,14 @@ app.on('ready', function() {
|
|||||||
mainWindow.minimize();
|
mainWindow.minimize();
|
||||||
break;
|
break;
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
mainWindow.hide();
|
if (config.minimizeToTray) {
|
||||||
|
mainWindow.hide();
|
||||||
|
app.dock.hide();
|
||||||
|
mainWindow.isHidden = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
mainWindow.minimize();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
@@ -11,6 +11,12 @@ function createDefault(mainWindow) {
|
|||||||
label: `Open ${app.getName()}`,
|
label: `Open ${app.getName()}`,
|
||||||
click: () => {
|
click: () => {
|
||||||
mainWindow.show();
|
mainWindow.show();
|
||||||
|
mainWindow.isHidden = false;
|
||||||
|
|
||||||
|
if (process.platform === 'darwin') {
|
||||||
|
app.dock.show();
|
||||||
|
mainWindow.focus();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
type: 'separator'
|
type: 'separator'
|
||||||
|
@@ -152,8 +152,8 @@ describe('browser/settings.html', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('Minimize to tray', function() {
|
describe('Minimize to tray', function() {
|
||||||
it('should appear win32', function() {
|
it('should appear on win32 and darwin', function() {
|
||||||
const expected = (process.platform === 'win32');
|
const expected = (process.platform === 'win32' || process.platform === 'darwin');
|
||||||
env.addClientCommands(this.app.client);
|
env.addClientCommands(this.app.client);
|
||||||
return this.app.client
|
return this.app.client
|
||||||
.loadSettingsPage()
|
.loadSettingsPage()
|
||||||
@@ -162,7 +162,7 @@ describe('browser/settings.html', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('Toggle window visibility when clicking on the tray icon', function() {
|
describe('Toggle window visibility when clicking on the tray icon', function() {
|
||||||
it('should appear win32', function() {
|
it('should appear on win32', function() {
|
||||||
const expected = (process.platform === 'win32');
|
const expected = (process.platform === 'win32');
|
||||||
env.addClientCommands(this.app.client);
|
env.addClientCommands(this.app.client);
|
||||||
return this.app.client
|
return this.app.client
|
||||||
|
Reference in New Issue
Block a user