Replace generic "Open mattermost" by a menu entry for each team.
This commit is contained in:
@@ -31,6 +31,7 @@
|
|||||||
- Ctrl+{1-9} (Window -> *Team name*): Open the *n*-th tab.
|
- Ctrl+{1-9} (Window -> *Team name*): Open the *n*-th tab.
|
||||||
- Ctrl+Tab or Alt+Command+Right (Window -> Select Next Team): Open the right tab.
|
- Ctrl+Tab or Alt+Command+Right (Window -> Select Next Team): Open the right tab.
|
||||||
- Ctrl+Shift+Tab or Alt+Command+Left (Window -> Select Previous Team): Open the left tab.
|
- Ctrl+Shift+Tab or Alt+Command+Left (Window -> Select Previous Team): Open the left tab.
|
||||||
|
- Right click on the tray item, to see an overview of all your teams. You can also select one and jump right into it.
|
||||||
- Added **Add** button next to the "Teams" label on the Setting page.
|
- Added **Add** button next to the "Teams" label on the Setting page.
|
||||||
- Added **Edit** button on the team list on the Setting page.
|
- Added **Edit** button on the team list on the Setting page.
|
||||||
- Added **Help** menu to indicate the application version.
|
- Added **Help** menu to indicate the application version.
|
||||||
|
27
src/main.js
27
src/main.js
@@ -364,23 +364,22 @@ app.on('ready', function() {
|
|||||||
ipcMain.on('update-menu', (event, config) => {
|
ipcMain.on('update-menu', (event, config) => {
|
||||||
var app_menu = appMenu.createMenu(mainWindow, config);
|
var app_menu = appMenu.createMenu(mainWindow, config);
|
||||||
Menu.setApplicationMenu(app_menu);
|
Menu.setApplicationMenu(app_menu);
|
||||||
|
// set up context menu for tray icon
|
||||||
|
if (shouldShowTrayIcon()) {
|
||||||
|
const tray_menu = require('./main/menus/tray').createMenu(mainWindow, config);
|
||||||
|
trayIcon.setContextMenu(tray_menu);
|
||||||
|
if (process.platform === 'darwin') {
|
||||||
|
// store the information, if the tray was initialized, for checking in the settings, if the application
|
||||||
|
// was restarted after setting "Show icon on menu bar"
|
||||||
|
if (trayIcon)
|
||||||
|
mainWindow.trayWasVisible = true;
|
||||||
|
else
|
||||||
|
mainWindow.trayWasVisible = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
ipcMain.emit('update-menu', true, config);
|
ipcMain.emit('update-menu', true, config);
|
||||||
|
|
||||||
// set up context menu for tray icon
|
|
||||||
if (shouldShowTrayIcon()) {
|
|
||||||
const tray_menu = require('./main/menus/tray').createDefault(mainWindow);
|
|
||||||
trayIcon.setContextMenu(tray_menu);
|
|
||||||
if (process.platform === 'darwin') {
|
|
||||||
// store the information, if the tray was initialized, for checking in the settings, if the application
|
|
||||||
// was restarted after setting "Show icon on menu bar"
|
|
||||||
if (trayIcon)
|
|
||||||
mainWindow.trayWasVisible = true;
|
|
||||||
else
|
|
||||||
mainWindow.trayWasVisible = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Open the DevTools.
|
// Open the DevTools.
|
||||||
// mainWindow.openDevTools();
|
// mainWindow.openDevTools();
|
||||||
|
|
||||||
|
@@ -6,28 +6,39 @@ const {
|
|||||||
MenuItem
|
MenuItem
|
||||||
} = require('electron');
|
} = require('electron');
|
||||||
|
|
||||||
function createDefault(mainWindow) {
|
function createTemplate(mainWindow, config) {
|
||||||
return Menu.buildFromTemplate([{
|
var template = [
|
||||||
label: `Open ${app.getName()}`,
|
...config.teams.slice(0, 9).map((team, i) => {
|
||||||
click: () => {
|
return {
|
||||||
mainWindow.show();
|
label: team.name,
|
||||||
mainWindow.isHidden = false;
|
accelerator: `CmdOrCtrl+${i + 1}`,
|
||||||
|
click: (item, focusedWindow) => {
|
||||||
|
mainWindow.show(); // for OS X
|
||||||
|
mainWindow.webContents.send('switch-tab', i);
|
||||||
|
mainWindow.isHidden = false;
|
||||||
|
|
||||||
if (process.platform === 'darwin') {
|
if (process.platform === 'darwin') {
|
||||||
app.dock.show();
|
app.dock.show();
|
||||||
mainWindow.focus();
|
mainWindow.focus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}), {
|
||||||
|
type: 'separator'
|
||||||
|
}, {
|
||||||
|
label: 'Quit',
|
||||||
|
click: function(item) {
|
||||||
|
app.quit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, {
|
];
|
||||||
type: 'separator'
|
return template;
|
||||||
}, {
|
|
||||||
label: 'Quit',
|
|
||||||
click: function(item) {
|
|
||||||
app.quit();
|
|
||||||
}
|
|
||||||
}]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
var createMenu = function(mainWindow, config) {
|
||||||
createDefault: createDefault
|
return Menu.buildFromTemplate(createTemplate(mainWindow, config));
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
createMenu: createMenu
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user