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+{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();
|
||||||
|
|
||||||
|
|
|
@ -21,17 +21,13 @@ var createTemplate = function(mainWindow, config) {
|
||||||
message: `${app_name} Desktop ${electron.app.getVersion()}`
|
message: `${app_name} Desktop ${electron.app.getVersion()}`
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, {
|
}, separatorItem, {
|
||||||
type: 'separator'
|
|
||||||
}, {
|
|
||||||
label: 'Preferences...',
|
label: 'Preferences...',
|
||||||
accelerator: 'CmdOrCtrl+,',
|
accelerator: 'CmdOrCtrl+,',
|
||||||
click: function(item, focusedWindow) {
|
click: function(item, focusedWindow) {
|
||||||
mainWindow.loadURL('file://' + __dirname + '/browser/settings.html');
|
mainWindow.loadURL('file://' + __dirname + '/browser/settings.html');
|
||||||
}
|
}
|
||||||
}, {
|
}, separatorItem, {
|
||||||
type: 'separator'
|
|
||||||
}, {
|
|
||||||
label: 'Hide ' + app_name,
|
label: 'Hide ' + app_name,
|
||||||
accelerator: 'Command+H',
|
accelerator: 'Command+H',
|
||||||
selector: 'hide:'
|
selector: 'hide:'
|
||||||
|
@ -42,9 +38,7 @@ var createTemplate = function(mainWindow, config) {
|
||||||
}, {
|
}, {
|
||||||
label: 'Show All',
|
label: 'Show All',
|
||||||
selector: 'unhideAllApplications:'
|
selector: 'unhideAllApplications:'
|
||||||
}, {
|
}, separatorItem, {
|
||||||
type: 'separator'
|
|
||||||
}, {
|
|
||||||
label: 'Quit ' + app_name,
|
label: 'Quit ' + app_name,
|
||||||
accelerator: 'CmdOrCtrl+Q',
|
accelerator: 'CmdOrCtrl+Q',
|
||||||
click: function(item, focusedWindow) {
|
click: function(item, focusedWindow) {
|
||||||
|
@ -56,9 +50,7 @@ var createTemplate = function(mainWindow, config) {
|
||||||
click: function(item, focusedWindow) {
|
click: function(item, focusedWindow) {
|
||||||
mainWindow.loadURL('file://' + __dirname + '/browser/settings.html');
|
mainWindow.loadURL('file://' + __dirname + '/browser/settings.html');
|
||||||
}
|
}
|
||||||
}, {
|
}, separatorItem, {
|
||||||
type: 'separator'
|
|
||||||
}, {
|
|
||||||
label: 'Quit',
|
label: 'Quit',
|
||||||
accelerator: 'CmdOrCtrl+Q',
|
accelerator: 'CmdOrCtrl+Q',
|
||||||
click: function(item, focusedWindow) {
|
click: function(item, focusedWindow) {
|
||||||
|
@ -82,9 +74,7 @@ var createTemplate = function(mainWindow, config) {
|
||||||
label: 'Redo',
|
label: 'Redo',
|
||||||
accelerator: 'Shift+CmdOrCtrl+Z',
|
accelerator: 'Shift+CmdOrCtrl+Z',
|
||||||
role: 'redo'
|
role: 'redo'
|
||||||
}, {
|
}, separatorItem, {
|
||||||
type: 'separator'
|
|
||||||
}, {
|
|
||||||
label: 'Cut',
|
label: 'Cut',
|
||||||
accelerator: 'CmdOrCtrl+X',
|
accelerator: 'CmdOrCtrl+X',
|
||||||
role: 'cut'
|
role: 'cut'
|
||||||
|
@ -192,9 +182,7 @@ var createTemplate = function(mainWindow, config) {
|
||||||
focusedWindow.close();
|
focusedWindow.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, {
|
}, separatorItem, ...config.teams.slice(0, 9).map((team, i) => {
|
||||||
type: 'separator'
|
|
||||||
}, ...config.teams.slice(0, 9).map((team, i) => {
|
|
||||||
return {
|
return {
|
||||||
label: team.name,
|
label: team.name,
|
||||||
accelerator: `CmdOrCtrl+${i + 1}`,
|
accelerator: `CmdOrCtrl+${i + 1}`,
|
||||||
|
|
|
@ -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
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue