Merge pull request #191 from mattermost/linux-hide-to-tray

Add feature to hide window into system tray in Linux
This commit is contained in:
Yuya Ochiai 2016-07-07 22:14:59 +09:00 committed by GitHub
commit 35a8e1b0d9
6 changed files with 27 additions and 46 deletions

View file

@ -11,12 +11,9 @@
- Fixed the pixelated app icon on the top left of the window.
- Fixed the blurred tray icon.
- Fixed that the redundant description appears in the pinned start menu on Windows 7.
- The main window is now minimized to system tray on close
- Added Option to toggle minimize/restore on click on system tray icon
#### OS X
- Fixed that two icons appear on a notification.
- Added Option to hide Window from dock on close
### Improvements
- Added shortcuts
@ -42,14 +39,18 @@
- Added the tooltip text for the tray icon in order to show count of unread channels/mantions.
- Added the option to launch the application on login.
- Added the option to blink the taskbar icon when a new message has arrived.
- The main window is now minimized to system tray on close
- Added Option to toggle minimize/restore on click on system tray icon
- Added installers (experimental)
#### OS X
- Added colored badges to the menu icon when there are unread channels/mentions.
- Added Option to hide Window from dock on close
#### Linux
- Added the option to show the icon on menu bar. (requires libappindicator1 on Ubuntu)
- Added the option to launch the application on login.
- Added Option to hide Window into tray icon on close
## Release v1.2.1 (Beta)

View file

@ -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.
- **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)
- **Leave app running in notification area when the window is closed** (OS X, Linux)
- 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

View file

@ -27,16 +27,17 @@ function backToIndex() {
var SettingsPage = React.createClass({
getInitialState: function() {
var config;
var initialState;
try {
config = settings.readFileSync(this.props.configFile);
initialState = settings.readFileSync(this.props.configFile);
} catch (e) {
config = settings.loadDefault();
initialState = settings.loadDefault();
}
config.showAddTeamForm = false;
initialState.showAddTeamForm = false;
initialState.trayWasVisible = remote.getCurrentWindow().trayWasVisible;
return config;
return initialState;
},
componentDidMount: function() {
if (process.platform === 'win32' || process.platform === 'linux') {
@ -47,13 +48,6 @@ var SettingsPage = React.createClass({
});
});
}
if (process.platform === 'darwin') {
var currentWindow = remote.getCurrentWindow();
this.setState({
trayWasVisible: currentWindow.trayWasVisible
});
}
},
handleTeamsChange: function(teams) {
this.setState({
@ -188,7 +182,7 @@ var SettingsPage = React.createClass({
/>);
}
if (process.platform === 'darwin') {
if (process.platform === 'darwin' || process.platform === 'linux') {
options.push(<Input key="inputMinimizeToTray" id="inputMinimizeToTray" ref="minimizeToTray" type="checkbox" label={ this.state.trayWasVisible || !this.state.showTrayIcon ? "Leave app running in notification area when the window is closed" : "Leave app running in notification area when the window is closed (available on next restart)" } disabled={ !this.state.showTrayIcon || !this.state.trayWasVisible } checked={ this.state.minimizeToTray }
onChange={ this.handleChangeMinimizeToTray } />);
}

View file

@ -160,7 +160,6 @@ app.on('browser-window-created', function(event, window) {
// For OSX, show hidden mainWindow when clicking dock icon.
app.on('activate', function(event) {
mainWindow.show();
mainWindow.isHidden = false;
});
app.on('before-quit', function() {
@ -232,29 +231,15 @@ app.on('ready', function() {
trayIcon.setToolTip(app.getName());
trayIcon.on('click', function() {
if (process.platform === 'win32') {
if (mainWindow.isHidden || mainWindow.isMinimized()) {
mainWindow.show();
mainWindow.isHidden = false;
mainWindow.focus();
}
else if (config.toggleWindowOnTrayIconClick) {
mainWindow.minimize();
}
else {
mainWindow.focus();
}
}
else if (process.platform === 'darwin') {
if (mainWindow.isHidden || mainWindow.isMinimized()) {
mainWindow.show();
mainWindow.isHidden = false;
mainWindow.focus();
if (!mainWindow.isVisible() || mainWindow.isMinimized()) {
mainWindow.show();
mainWindow.focus();
if (process.platform === 'darwin') {
app.dock.show();
}
else {
mainWindow.focus();
}
}
else if ((process.platform === 'win32') && config.toggleWindowOnTrayIconClick) {
mainWindow.minimize();
}
else {
mainWindow.focus();
@ -267,7 +252,6 @@ app.on('ready', function() {
trayIcon.on('balloon-click', function() {
if (process.platform === 'win32' || process.platform === 'darwin') {
mainWindow.show();
mainWindow.isHidden = false;
}
if (process.platform === 'darwin') {
@ -404,16 +388,19 @@ app.on('ready', function() {
switch (process.platform) {
case 'win32':
mainWindow.hide();
mainWindow.isHidden = true;
break;
case 'linux':
mainWindow.minimize();
if (config.minimizeToTray) {
mainWindow.hide();
}
else {
mainWindow.minimize();
}
break;
case 'darwin':
mainWindow.hide();
if (config.minimizeToTray) {
app.dock.hide();
mainWindow.isHidden = true;
}
break;
default:

View file

@ -15,7 +15,6 @@ function createTemplate(mainWindow, config) {
click: (item, focusedWindow) => {
mainWindow.show(); // for OS X
mainWindow.webContents.send('switch-tab', i);
mainWindow.isHidden = false;
if (process.platform === 'darwin') {
app.dock.show();

View file

@ -152,8 +152,8 @@ describe('browser/settings.html', function() {
});
describe('Minimize to tray', function() {
it('should appear on darwin', function() {
const expected = (process.platform === 'darwin');
it('should appear on darwin or linux', function() {
const expected = (process.platform === 'darwin' || process.platform === 'linux');
env.addClientCommands(this.app.client);
return this.app.client
.loadSettingsPage()