Update menu when the config is updated
This commit is contained in:
parent
ab9bfad73a
commit
a4f119bcae
|
@ -1,6 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const remote = require('electron').remote;
|
const {remote, ipcRenderer} = require('electron');
|
||||||
const settings = require('../common/settings');
|
const settings = require('../common/settings');
|
||||||
|
|
||||||
const React = require('react');
|
const React = require('react');
|
||||||
|
@ -50,6 +50,7 @@ var SettingsPage = React.createClass({
|
||||||
currentWindow.setAutoHideMenuBar(config.hideMenuBar);
|
currentWindow.setAutoHideMenuBar(config.hideMenuBar);
|
||||||
currentWindow.setMenuBarVisibility(!config.hideMenuBar);
|
currentWindow.setMenuBarVisibility(!config.hideMenuBar);
|
||||||
}
|
}
|
||||||
|
ipcRenderer.send('update-menu', config);
|
||||||
backToIndex();
|
backToIndex();
|
||||||
},
|
},
|
||||||
handleCancel: function() {
|
handleCancel: function() {
|
||||||
|
|
10
src/main.js
10
src/main.js
|
@ -231,6 +231,13 @@ 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 application menu
|
||||||
|
ipc.on('update-menu', (event, config) => {
|
||||||
|
var app_menu = appMenu.createMenu(mainWindow, config);
|
||||||
|
Menu.setApplicationMenu(app_menu);
|
||||||
|
});
|
||||||
|
ipc.emit('update-menu', true, config);
|
||||||
|
|
||||||
// Open the DevTools.
|
// Open the DevTools.
|
||||||
// mainWindow.openDevTools();
|
// mainWindow.openDevTools();
|
||||||
|
|
||||||
|
@ -274,9 +281,6 @@ app.on('ready', function() {
|
||||||
saveWindowState(bounds_info_path, mainWindow);
|
saveWindowState(bounds_info_path, mainWindow);
|
||||||
});
|
});
|
||||||
|
|
||||||
var app_menu = appMenu.createMenu(mainWindow, config);
|
|
||||||
Menu.setApplicationMenu(app_menu);
|
|
||||||
|
|
||||||
// Emitted when the window is closed.
|
// Emitted when the window is closed.
|
||||||
mainWindow.on('closed', function() {
|
mainWindow.on('closed', function() {
|
||||||
// Dereference the window object, usually you would store windows
|
// Dereference the window object, usually you would store windows
|
||||||
|
|
|
@ -138,7 +138,7 @@ var createTemplate = function(mainWindow, config) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, separatorItem, {
|
}, separatorItem, {
|
||||||
label: 'Actual size',
|
label: 'Actual Size',
|
||||||
accelerator: 'CmdOrCtrl+0',
|
accelerator: 'CmdOrCtrl+0',
|
||||||
click: () => {
|
click: () => {
|
||||||
mainWindow.webContents.send('zoom-reset');
|
mainWindow.webContents.send('zoom-reset');
|
||||||
|
@ -187,25 +187,21 @@ var createTemplate = function(mainWindow, config) {
|
||||||
mainWindow.webContents.send('switch-tab', i);
|
mainWindow.webContents.send('switch-tab', i);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
})]
|
}), separatorItem, {
|
||||||
}
|
|
||||||
|
|
||||||
if (config.teams.length > 1) {
|
|
||||||
window_menu.submenu = window_menu.submenu.concat([{
|
|
||||||
type: 'separator'
|
|
||||||
}, {
|
|
||||||
label: 'Select Next Team',
|
label: 'Select Next Team',
|
||||||
accelerator: (process.platform === 'darwin') ? 'Alt+Cmd+Right' : 'CmdOrCtrl+Tab',
|
accelerator: (process.platform === 'darwin') ? 'Alt+Cmd+Right' : 'CmdOrCtrl+Tab',
|
||||||
click: () => {
|
click: () => {
|
||||||
mainWindow.webContents.send('select-next-tab');
|
mainWindow.webContents.send('select-next-tab');
|
||||||
}
|
},
|
||||||
|
enabled: (config.teams.length > 1)
|
||||||
}, {
|
}, {
|
||||||
label: 'Select Previous Team',
|
label: 'Select Previous Team',
|
||||||
accelerator: (process.platform === 'darwin') ? 'Alt+Cmd+Left' : 'CmdOrCtrl+Shift+Tab',
|
accelerator: (process.platform === 'darwin') ? 'Alt+Cmd+Left' : 'CmdOrCtrl+Shift+Tab',
|
||||||
click: () => {
|
click: () => {
|
||||||
mainWindow.webContents.send('select-previous-tab');
|
mainWindow.webContents.send('select-previous-tab');
|
||||||
}
|
},
|
||||||
}]);
|
enabled: (config.teams.length > 1)
|
||||||
|
}]
|
||||||
}
|
}
|
||||||
template.push(window_menu);
|
template.push(window_menu);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue