Begin to create custom application menu

This commit is contained in:
Pierre HUBERT 2019-02-11 18:38:00 +01:00
parent 24643f0867
commit 33b8e4e2b6
2 changed files with 48 additions and 1 deletions

43
ApplicationMenu.js Normal file
View File

@ -0,0 +1,43 @@
/**
* Application menu
*
* @author Comunic Authors
*/
const {app, Menu} = require('electron');
/**
* Get application menu
*
* @param {BrowserWindow} window
* @return {Menu} Application menu
*/
module.exports.Get = function(window){
return Menu.buildFromTemplate([
{
label: "File",
submenu: [
{
label: "Quit",
click: () => {
app.quit();
}
}
]
},
{
label: "Advanced",
submenu: [
{
label: "Toggle developer tools",
click: () => {
window.webContents.toggleDevTools();
}
}
]
}
])
}

View File

@ -6,9 +6,10 @@
const electron = require('electron'); const electron = require('electron');
const BrowserWindow = electron.BrowserWindow; const BrowserWindow = electron.BrowserWindow;
const {Tray} = require('electron'); const {Menu, Tray} = require('electron');
const Config = require("./Config"); const Config = require("./Config");
const TrayMenu = require("./TrayMenu"); const TrayMenu = require("./TrayMenu");
const ApplicationMenu = require("./ApplicationMenu");
let mainWindow; let mainWindow;
@ -48,6 +49,9 @@ exports.show = function(){
console.log("Started successfully"); console.log("Started successfully");
//Set application menu
Menu.setApplicationMenu(ApplicationMenu.Get(mainWindow));
mainWindow.once('ready-to-show', () => { mainWindow.once('ready-to-show', () => {
mainWindow.show(); mainWindow.show();
}); });