1
0
mirror of https://github.com/mifi/lossless-cut.git synced 2024-11-22 10:22:31 +01:00

prompt before quit #229

This commit is contained in:
Mikael Finstad 2020-02-18 17:06:57 +08:00
parent f73f7691e1
commit 6906b69996

View File

@ -31,6 +31,19 @@ function createWindow() {
// when you should delete the corresponding element.
mainWindow = null;
});
// https://stackoverflow.com/questions/39574636/prompt-to-save-quit-before-closing-window/47434365
mainWindow.on('close', (e) => {
const choice = electron.dialog.showMessageBoxSync(mainWindow, {
type: 'question',
buttons: ['Yes', 'No'],
title: 'Confirm quit',
message: 'Are you sure you want to quit? You will lose all unsaved work',
});
if (choice === 1) {
e.preventDefault();
}
});
}
// This method will be called when Electron has finished