mirror of
https://github.com/finos/SymphonyElectron.git
synced 2025-02-25 18:55:29 -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 () {
|
app.on('window-all-closed', function () {
|
||||||
// On OS X it is common for applications and their menu bar
|
app.quit();
|
||||||
// to stay active until the user quits explicitly with Cmd + Q
|
|
||||||
if (!isMac) {
|
|
||||||
app.quit();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
app.on('activate', function () {
|
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;
|
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 electron = require('electron');
|
||||||
const app = electron.app;
|
const app = electron.app;
|
||||||
|
const BrowserWindow = electron.BrowserWindow;
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const nodeURL = require('url');
|
const nodeURL = require('url');
|
||||||
const querystring = require('querystring');
|
const querystring = require('querystring');
|
||||||
|
|
||||||
const menuTemplate = require('./menus/menuTemplate.js');
|
const { getTemplate, getMinimizeOnClose } = require('./menus/menuTemplate.js');
|
||||||
const loadErrors = require('./dialogs/showLoadError.js');
|
const loadErrors = require('./dialogs/showLoadError.js');
|
||||||
const {isMac} = require('./utils/misc.js');
|
|
||||||
const isInDisplayBounds = require('./utils/isInDisplayBounds.js');
|
const isInDisplayBounds = require('./utils/isInDisplayBounds.js');
|
||||||
const getGuid = require('./utils/getGuid.js');
|
const getGuid = require('./utils/getGuid.js');
|
||||||
const log = require('./log.js');
|
const log = require('./log.js');
|
||||||
@ -18,7 +18,7 @@ const notify = require('./notify/electron-notify.js');
|
|||||||
const activityDetection = require('./activityDetection/activityDetection.js');
|
const activityDetection = require('./activityDetection/activityDetection.js');
|
||||||
|
|
||||||
const throttle = require('./utils/throttle.js');
|
const throttle = require('./utils/throttle.js');
|
||||||
const {getConfigField, updateConfigField} = require('./config.js');
|
const { getConfigField, updateConfigField } = require('./config.js');
|
||||||
|
|
||||||
//context menu
|
//context menu
|
||||||
const contextMenu = require('./menus/contextMenu.js');
|
const contextMenu = require('./menus/contextMenu.js');
|
||||||
@ -77,7 +77,6 @@ function doCreateMainWindow(initialUrl, initialBounds) {
|
|||||||
sandbox: true,
|
sandbox: true,
|
||||||
nodeIntegration: false,
|
nodeIntegration: false,
|
||||||
preload: preloadMainScript,
|
preload: preloadMainScript,
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -107,7 +106,7 @@ function doCreateMainWindow(initialUrl, initialBounds) {
|
|||||||
// note: augmenting with some custom values
|
// note: augmenting with some custom values
|
||||||
newWinOpts.winKey = key;
|
newWinOpts.winKey = key;
|
||||||
|
|
||||||
mainWindow = new electron.BrowserWindow(newWinOpts);
|
mainWindow = new BrowserWindow(newWinOpts);
|
||||||
mainWindow.winName = 'main';
|
mainWindow.winName = 'main';
|
||||||
|
|
||||||
let throttledMainWinBoundsChange = throttle(5000, saveMainWinBounds);
|
let throttledMainWinBoundsChange = throttle(5000, saveMainWinBounds);
|
||||||
@ -150,18 +149,20 @@ function doCreateMainWindow(initialUrl, initialBounds) {
|
|||||||
addWindowKey(key, mainWindow);
|
addWindowKey(key, mainWindow);
|
||||||
mainWindow.loadURL(url);
|
mainWindow.loadURL(url);
|
||||||
|
|
||||||
const menu = electron.Menu.buildFromTemplate(menuTemplate(app));
|
const menu = electron.Menu.buildFromTemplate(getTemplate(app));
|
||||||
electron.Menu.setApplicationMenu(menu);
|
electron.Menu.setApplicationMenu(menu);
|
||||||
|
|
||||||
mainWindow.on('close', function (e) {
|
mainWindow.on('close', function(e) {
|
||||||
if (willQuitApp) {
|
if (willQuitApp) {
|
||||||
destroyAllWindows();
|
destroyAllWindows();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// mac should hide window when hitting x close
|
|
||||||
if (isMac) {
|
if (getMinimizeOnClose()) {
|
||||||
mainWindow.hide();
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
mainWindow.minimize();
|
||||||
|
} else {
|
||||||
|
app.quit();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -245,7 +246,7 @@ function doCreateMainWindow(initialUrl, initialBounds) {
|
|||||||
let webContents = newWinOptions.webContents;
|
let webContents = newWinOptions.webContents;
|
||||||
|
|
||||||
webContents.once('did-finish-load', function () {
|
webContents.once('did-finish-load', function () {
|
||||||
let browserWin = electron.BrowserWindow.fromWebContents(webContents);
|
let browserWin = BrowserWindow.fromWebContents(webContents);
|
||||||
|
|
||||||
if (browserWin) {
|
if (browserWin) {
|
||||||
browserWin.winName = frameName;
|
browserWin.winName = frameName;
|
||||||
@ -313,7 +314,7 @@ function isMainWindow(win) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function hasWindow(win, winKey) {
|
function hasWindow(win, winKey) {
|
||||||
if (win instanceof electron.BrowserWindow) {
|
if (win instanceof BrowserWindow) {
|
||||||
let browserWin = windows[winKey];
|
let browserWin = windows[winKey];
|
||||||
return browserWin && win === browserWin;
|
return browserWin && win === browserWin;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user