Add a tray icon menu to open the main window
This commit is contained in:
@@ -164,8 +164,6 @@ app.on('ready', function() {
|
|||||||
// set up tray icon
|
// set up tray icon
|
||||||
trayIcon = new Tray(trayImages.normal);
|
trayIcon = new Tray(trayImages.normal);
|
||||||
trayIcon.setToolTip(app.getName());
|
trayIcon.setToolTip(app.getName());
|
||||||
var tray_menu = require('./main/menus/tray').createDefault();
|
|
||||||
trayIcon.setContextMenu(tray_menu);
|
|
||||||
trayIcon.on('click', function() {
|
trayIcon.on('click', function() {
|
||||||
mainWindow.focus();
|
mainWindow.focus();
|
||||||
});
|
});
|
||||||
@@ -227,6 +225,12 @@ app.on('ready', function() {
|
|||||||
// and load the index.html of the app.
|
// and load the index.html of the app.
|
||||||
mainWindow.loadURL('file://' + __dirname + '/browser/index.html');
|
mainWindow.loadURL('file://' + __dirname + '/browser/index.html');
|
||||||
|
|
||||||
|
// set up context menu for tray icon
|
||||||
|
if (shouldShowTrayIcon()) {
|
||||||
|
const tray_menu = require('./main/menus/tray').createDefault(mainWindow);
|
||||||
|
trayIcon.setContextMenu(tray_menu);
|
||||||
|
}
|
||||||
|
|
||||||
// Open the DevTools.
|
// Open the DevTools.
|
||||||
// mainWindow.openDevTools();
|
// mainWindow.openDevTools();
|
||||||
|
|
||||||
|
@@ -1,18 +1,25 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const electron = require('electron');
|
const {
|
||||||
const Menu = electron.Menu;
|
app,
|
||||||
const MenuItem = electron.MenuItem;
|
Menu,
|
||||||
|
MenuItem
|
||||||
|
} = require('electron');
|
||||||
|
|
||||||
var createDefault = function() {
|
function createDefault(mainWindow) {
|
||||||
var menu = new Menu();
|
return Menu.buildFromTemplate([{
|
||||||
menu.append(new MenuItem({
|
label: 'Open Mattermost',
|
||||||
|
click: () => {
|
||||||
|
mainWindow.show();
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
type: 'separator'
|
||||||
|
}, {
|
||||||
label: 'Quit',
|
label: 'Quit',
|
||||||
click: function(item) {
|
click: function(item) {
|
||||||
require('app').quit();
|
app.quit();
|
||||||
}
|
}
|
||||||
}));
|
}]);
|
||||||
return menu;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
Reference in New Issue
Block a user