mirror of
https://github.com/finos/SymphonyElectron.git
synced 2024-12-27 17:31:36 -06:00
Minimize on close updates (#93)
* Minimize On Close * Minimize on close updates
This commit is contained in:
parent
c851c7b886
commit
d494e23d4e
@ -183,11 +183,7 @@ function handleProtocolAction(uri) {
|
||||
}
|
||||
|
||||
app.on('window-all-closed', function () {
|
||||
// On OS X it is common for applications and their menu bar
|
||||
// to stay active until the user quits explicitly with Cmd + Q
|
||||
if (!isMac) {
|
||||
app.quit();
|
||||
}
|
||||
});
|
||||
|
||||
app.on('activate', function () {
|
||||
|
@ -216,6 +216,17 @@ function getTemplate(app) {
|
||||
}
|
||||
)
|
||||
|
||||
if (!isMac){
|
||||
template[index].submenu.push(
|
||||
{
|
||||
label: 'Quit Symphony',
|
||||
click: function () {
|
||||
app.quit();
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
return template;
|
||||
}
|
||||
|
||||
@ -235,4 +246,11 @@ function setCheckboxValues(){
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = getTemplate;
|
||||
function getMinimizeOnClose(){
|
||||
return minimizeOnClose;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getTemplate : getTemplate,
|
||||
getMinimizeOnClose : getMinimizeOnClose
|
||||
};
|
@ -2,13 +2,13 @@
|
||||
|
||||
const electron = require('electron');
|
||||
const app = electron.app;
|
||||
const BrowserWindow = electron.BrowserWindow;
|
||||
const path = require('path');
|
||||
const nodeURL = require('url');
|
||||
const querystring = require('querystring');
|
||||
|
||||
const menuTemplate = require('./menus/menuTemplate.js');
|
||||
const { getTemplate, getMinimizeOnClose } = require('./menus/menuTemplate.js');
|
||||
const loadErrors = require('./dialogs/showLoadError.js');
|
||||
const {isMac} = require('./utils/misc.js');
|
||||
const isInDisplayBounds = require('./utils/isInDisplayBounds.js');
|
||||
const getGuid = require('./utils/getGuid.js');
|
||||
const log = require('./log.js');
|
||||
@ -77,7 +77,6 @@ function doCreateMainWindow(initialUrl, initialBounds) {
|
||||
sandbox: true,
|
||||
nodeIntegration: false,
|
||||
preload: preloadMainScript,
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
@ -107,7 +106,7 @@ function doCreateMainWindow(initialUrl, initialBounds) {
|
||||
// note: augmenting with some custom values
|
||||
newWinOpts.winKey = key;
|
||||
|
||||
mainWindow = new electron.BrowserWindow(newWinOpts);
|
||||
mainWindow = new BrowserWindow(newWinOpts);
|
||||
mainWindow.winName = 'main';
|
||||
|
||||
let throttledMainWinBoundsChange = throttle(5000, saveMainWinBounds);
|
||||
@ -150,7 +149,7 @@ function doCreateMainWindow(initialUrl, initialBounds) {
|
||||
addWindowKey(key, mainWindow);
|
||||
mainWindow.loadURL(url);
|
||||
|
||||
const menu = electron.Menu.buildFromTemplate(menuTemplate(app));
|
||||
const menu = electron.Menu.buildFromTemplate(getTemplate(app));
|
||||
electron.Menu.setApplicationMenu(menu);
|
||||
|
||||
mainWindow.on('close', function(e) {
|
||||
@ -158,10 +157,12 @@ function doCreateMainWindow(initialUrl, initialBounds) {
|
||||
destroyAllWindows();
|
||||
return;
|
||||
}
|
||||
// mac should hide window when hitting x close
|
||||
if (isMac) {
|
||||
mainWindow.hide();
|
||||
|
||||
if (getMinimizeOnClose()) {
|
||||
e.preventDefault();
|
||||
mainWindow.minimize();
|
||||
} else {
|
||||
app.quit();
|
||||
}
|
||||
});
|
||||
|
||||
@ -245,7 +246,7 @@ function doCreateMainWindow(initialUrl, initialBounds) {
|
||||
let webContents = newWinOptions.webContents;
|
||||
|
||||
webContents.once('did-finish-load', function () {
|
||||
let browserWin = electron.BrowserWindow.fromWebContents(webContents);
|
||||
let browserWin = BrowserWindow.fromWebContents(webContents);
|
||||
|
||||
if (browserWin) {
|
||||
browserWin.winName = frameName;
|
||||
@ -313,7 +314,7 @@ function isMainWindow(win) {
|
||||
}
|
||||
|
||||
function hasWindow(win, winKey) {
|
||||
if (win instanceof electron.BrowserWindow) {
|
||||
if (win instanceof BrowserWindow) {
|
||||
let browserWin = windows[winKey];
|
||||
return browserWin && win === browserWin;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user