From 2b4ee5f0bc3a5d70e06f7b63c31e110d79597af7 Mon Sep 17 00:00:00 2001 From: Martin Gondermann Date: Sun, 3 Jul 2016 16:12:04 +0200 Subject: [PATCH] Readded the Option to hide the window on close for OSX --- CHANGELOG.md | 2 +- docs/setup.md | 2 ++ src/browser/settings.jsx | 23 ++++++++++++++++++++++- src/main.js | 6 ++++-- test/specs/browser/settings_test.js | 10 ++++++++++ 5 files changed, 39 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d3151021..111b8d88 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,7 @@ #### OS X - Fixed that two icons appear on a notification. -- The main window is now hidden from dock on close +- Added Option to hide Window from dock on close ### Improvements - Added shortcuts diff --git a/docs/setup.md b/docs/setup.md index d2d1690b..fc3a1b87 100644 --- a/docs/setup.md +++ b/docs/setup.md @@ -124,6 +124,8 @@ 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. - **Start app on login** (Windows, Linux) - This option starts the application when you login. + - **Leave app running in notification area when the window is closed** (OS X) + - This option hides the window from the dock, if the window is closed - **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 diff --git a/src/browser/settings.jsx b/src/browser/settings.jsx index c82231c1..ca28f35d 100644 --- a/src/browser/settings.jsx +++ b/src/browser/settings.jsx @@ -61,6 +61,7 @@ var SettingsPage = React.createClass({ trayIconTheme: this.state.trayIconTheme, disablewebsecurity: this.state.disablewebsecurity, version: settings.version, + minimizeToTray: this.state.minimizeToTray, toggleWindowOnTrayIconClick: this.state.toggleWindowOnTrayIconClick, notifications: { flashWindow: this.state.notifications.flashWindow @@ -101,9 +102,16 @@ var SettingsPage = React.createClass({ }); }, handleChangeShowTrayIcon: function() { + var shouldShowTrayIcon = this.refs.showTrayIcon.getChecked(); this.setState({ - showTrayIcon: this.refs.showTrayIcon.getChecked() + showTrayIcon: shouldShowTrayIcon }); + + if (process.platform === 'darwin' && !shouldShowTrayIcon) { + this.setState({ + minimizeToTray: false + }); + } }, handleChangeTrayIconTheme: function() { this.setState({ @@ -115,6 +123,14 @@ var SettingsPage = React.createClass({ autostart: this.refs.autostart.getChecked() }); }, + handleChangeMinimizeToTray: function() { + var shouldMinimizeToTray = (process.platform !== 'darwin' || this.refs.showTrayIcon.getChecked()) + && this.refs.minimizeToTray.getChecked(); + + this.setState({ + minimizeToTray: shouldMinimizeToTray + }); + }, handleChangeToggleWindowOnTrayIconClick: function() { this.setState({ toggleWindowOnTrayIconClick: this.refs.toggleWindowOnTrayIconClick.getChecked() @@ -164,6 +180,11 @@ var SettingsPage = React.createClass({ />); } + if (process.platform === 'darwin') { + options.push(); + } + if (process.platform === 'win32') { options.push(); diff --git a/src/main.js b/src/main.js index 19740b8f..7505751a 100644 --- a/src/main.js +++ b/src/main.js @@ -391,8 +391,10 @@ app.on('ready', function() { break; case 'darwin': mainWindow.hide(); - app.dock.hide(); - mainWindow.isHidden = true; + if (config.minimizeToTray) { + app.dock.hide(); + mainWindow.isHidden = true; + } break; default: } diff --git a/test/specs/browser/settings_test.js b/test/specs/browser/settings_test.js index 3cfff628..92229e7e 100644 --- a/test/specs/browser/settings_test.js +++ b/test/specs/browser/settings_test.js @@ -151,6 +151,16 @@ describe('browser/settings.html', function() { }); }); + describe('Minimize to tray', function() { + it('should appear on darwin', function() { + const expected = (process.platform === 'darwin'); + env.addClientCommands(this.app.client); + return this.app.client + .loadSettingsPage() + .isExisting('#inputMinimizeToTray').should.eventually.equal(expected) + }); + }); + describe('Toggle window visibility when clicking on the tray icon', function() { it('should appear on win32', function() { const expected = (process.platform === 'win32');