mirror of
https://github.com/CringeStudios/element-desktop.git
synced 2025-01-19 07:54:59 +01:00
Add user settings for warn before exit
This commit is contained in:
parent
c9c0ceb757
commit
68587e84ed
@ -340,6 +340,12 @@ ipcMain.on('ipcCall', async function(ev, payload) {
|
|||||||
launcher.disable();
|
launcher.disable();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'shouldWarnBeforeExit':
|
||||||
|
ret = store.get('warnBeforeExit', true);
|
||||||
|
break;
|
||||||
|
case 'setWarnBeforeExit':
|
||||||
|
store.set('warnBeforeExit', args[0]);
|
||||||
|
break;
|
||||||
case 'getMinimizeToTrayEnabled':
|
case 'getMinimizeToTrayEnabled':
|
||||||
ret = tray.hasTray();
|
ret = tray.hasTray();
|
||||||
break;
|
break;
|
||||||
@ -921,19 +927,21 @@ app.on('ready', async () => {
|
|||||||
mainWindow = global.mainWindow = null;
|
mainWindow = global.mainWindow = null;
|
||||||
});
|
});
|
||||||
mainWindow.on('close', async (e) => {
|
mainWindow.on('close', async (e) => {
|
||||||
const shouldCancelCloseRequest = dialog.showMessageBoxSync(mainWindow, {
|
if (store.get('warnBeforeExit', true)) {
|
||||||
type: "question",
|
const shouldCancelCloseRequest = dialog.showMessageBoxSync(mainWindow, {
|
||||||
buttons: ["Cancel", "Close Element"],
|
type: "question",
|
||||||
message: "Are you sure you want to quit?",
|
buttons: ["Cancel", "Close Element"],
|
||||||
defaultId: 1,
|
message: "Are you sure you want to quit?",
|
||||||
cancelId: 0,
|
defaultId: 1,
|
||||||
checkboxLabel: "Do not show this again",
|
cancelId: 0,
|
||||||
checkboxChecked: false,
|
checkboxLabel: "Do not show this again",
|
||||||
}) === 0;
|
checkboxChecked: false,
|
||||||
|
}) === 0;
|
||||||
|
|
||||||
if (shouldCancelCloseRequest) {
|
if (shouldCancelCloseRequest) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we are not quitting and have a tray icon then minimize to tray
|
// If we are not quitting and have a tray icon then minimize to tray
|
||||||
|
Loading…
Reference in New Issue
Block a user