Merge pull request #184 from Razzeee/improve-tray-menu
Improve tray menu
This commit is contained in:
commit
cbecbfbc16
|
@ -31,6 +31,7 @@
|
|||
- 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+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 **Edit** button on the team list on the Setting page.
|
||||
- Added **Help** menu to indicate the application version.
|
||||
|
|
|
@ -364,12 +364,9 @@ app.on('ready', function() {
|
|||
ipcMain.on('update-menu', (event, config) => {
|
||||
var app_menu = appMenu.createMenu(mainWindow, config);
|
||||
Menu.setApplicationMenu(app_menu);
|
||||
});
|
||||
ipcMain.emit('update-menu', true, config);
|
||||
|
||||
// set up context menu for tray icon
|
||||
if (shouldShowTrayIcon()) {
|
||||
const tray_menu = require('./main/menus/tray').createDefault(mainWindow);
|
||||
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
|
||||
|
@ -380,6 +377,8 @@ app.on('ready', function() {
|
|||
mainWindow.trayWasVisible = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
ipcMain.emit('update-menu', true, config);
|
||||
|
||||
// Open the DevTools.
|
||||
// mainWindow.openDevTools();
|
||||
|
|
|
@ -21,17 +21,13 @@ var createTemplate = function(mainWindow, config) {
|
|||
message: `${app_name} Desktop ${electron.app.getVersion()}`
|
||||
});
|
||||
}
|
||||
}, {
|
||||
type: 'separator'
|
||||
}, {
|
||||
}, separatorItem, {
|
||||
label: 'Preferences...',
|
||||
accelerator: 'CmdOrCtrl+,',
|
||||
click: function(item, focusedWindow) {
|
||||
mainWindow.loadURL('file://' + __dirname + '/browser/settings.html');
|
||||
}
|
||||
}, {
|
||||
type: 'separator'
|
||||
}, {
|
||||
}, separatorItem, {
|
||||
label: 'Hide ' + app_name,
|
||||
accelerator: 'Command+H',
|
||||
selector: 'hide:'
|
||||
|
@ -42,9 +38,7 @@ var createTemplate = function(mainWindow, config) {
|
|||
}, {
|
||||
label: 'Show All',
|
||||
selector: 'unhideAllApplications:'
|
||||
}, {
|
||||
type: 'separator'
|
||||
}, {
|
||||
}, separatorItem, {
|
||||
label: 'Quit ' + app_name,
|
||||
accelerator: 'CmdOrCtrl+Q',
|
||||
click: function(item, focusedWindow) {
|
||||
|
@ -56,9 +50,7 @@ var createTemplate = function(mainWindow, config) {
|
|||
click: function(item, focusedWindow) {
|
||||
mainWindow.loadURL('file://' + __dirname + '/browser/settings.html');
|
||||
}
|
||||
}, {
|
||||
type: 'separator'
|
||||
}, {
|
||||
}, separatorItem, {
|
||||
label: 'Quit',
|
||||
accelerator: 'CmdOrCtrl+Q',
|
||||
click: function(item, focusedWindow) {
|
||||
|
@ -82,9 +74,7 @@ var createTemplate = function(mainWindow, config) {
|
|||
label: 'Redo',
|
||||
accelerator: 'Shift+CmdOrCtrl+Z',
|
||||
role: 'redo'
|
||||
}, {
|
||||
type: 'separator'
|
||||
}, {
|
||||
}, separatorItem, {
|
||||
label: 'Cut',
|
||||
accelerator: 'CmdOrCtrl+X',
|
||||
role: 'cut'
|
||||
|
@ -192,9 +182,7 @@ var createTemplate = function(mainWindow, config) {
|
|||
focusedWindow.close();
|
||||
}
|
||||
}
|
||||
}, {
|
||||
type: 'separator'
|
||||
}, ...config.teams.slice(0, 9).map((team, i) => {
|
||||
}, separatorItem, ...config.teams.slice(0, 9).map((team, i) => {
|
||||
return {
|
||||
label: team.name,
|
||||
accelerator: `CmdOrCtrl+${i + 1}`,
|
||||
|
|
|
@ -6,11 +6,15 @@ const {
|
|||
MenuItem
|
||||
} = require('electron');
|
||||
|
||||
function createDefault(mainWindow) {
|
||||
return Menu.buildFromTemplate([{
|
||||
label: `Open ${app.getName()}`,
|
||||
click: () => {
|
||||
mainWindow.show();
|
||||
function createTemplate(mainWindow, config) {
|
||||
var template = [
|
||||
...config.teams.slice(0, 9).map((team, i) => {
|
||||
return {
|
||||
label: team.name,
|
||||
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') {
|
||||
|
@ -18,16 +22,23 @@ function createDefault(mainWindow) {
|
|||
mainWindow.focus();
|
||||
}
|
||||
}
|
||||
}, {
|
||||
};
|
||||
}), {
|
||||
type: 'separator'
|
||||
}, {
|
||||
label: 'Quit',
|
||||
click: function(item) {
|
||||
app.quit();
|
||||
}
|
||||
}]);
|
||||
}
|
||||
];
|
||||
return template;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
createDefault: createDefault
|
||||
var createMenu = function(mainWindow, config) {
|
||||
return Menu.buildFromTemplate(createTemplate(mainWindow, config));
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
createMenu: createMenu
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue