Add user settings for warn before exit

This commit is contained in:
Germain Souquet 2021-03-25 14:15:04 +00:00
parent c9c0ceb757
commit 68587e84ed

View file

@ -340,6 +340,12 @@ ipcMain.on('ipcCall', async function(ev, payload) {
launcher.disable();
}
break;
case 'shouldWarnBeforeExit':
ret = store.get('warnBeforeExit', true);
break;
case 'setWarnBeforeExit':
store.set('warnBeforeExit', args[0]);
break;
case 'getMinimizeToTrayEnabled':
ret = tray.hasTray();
break;
@ -921,6 +927,7 @@ app.on('ready', async () => {
mainWindow = global.mainWindow = null;
});
mainWindow.on('close', async (e) => {
if (store.get('warnBeforeExit', true)) {
const shouldCancelCloseRequest = dialog.showMessageBoxSync(mainWindow, {
type: "question",
buttons: ["Cancel", "Close Element"],
@ -935,6 +942,7 @@ app.on('ready', async () => {
e.preventDefault();
return false;
}
}
// If we are not quitting and have a tray icon then minimize to tray
if (!global.appQuitting && (tray.hasTray() || process.platform === 'darwin')) {