mirror of
https://github.com/aaif-goose/goose.git
synced 2026-07-03 14:10:03 +02:00
prevent accidental quit (#2688)
This commit is contained in:
@@ -1290,6 +1290,32 @@ app.on('will-quit', () => {
|
||||
});
|
||||
|
||||
// Quit when all windows are closed, except on macOS or if we have a tray icon.
|
||||
// Add confirmation dialog when quitting with Cmd+Q
|
||||
app.on('before-quit', (event) => {
|
||||
// Prevent the default quit behavior
|
||||
event.preventDefault();
|
||||
|
||||
// Show confirmation dialog
|
||||
dialog
|
||||
.showMessageBox({
|
||||
type: 'question',
|
||||
buttons: ['Quit', 'Cancel'],
|
||||
defaultId: 1, // Default to Cancel
|
||||
title: 'Confirm Quit',
|
||||
message: 'Are you sure you want to quit Goose?',
|
||||
detail: 'Any unsaved changes may be lost.',
|
||||
})
|
||||
.then(({ response }) => {
|
||||
if (response === 0) {
|
||||
// User clicked "Quit"
|
||||
// Set a flag to avoid showing the dialog again
|
||||
app.removeAllListeners('before-quit');
|
||||
// Actually quit the app
|
||||
app.quit();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
app.on('window-all-closed', () => {
|
||||
// Only quit if we're not on macOS or don't have a tray icon
|
||||
if (process.platform !== 'darwin' || !tray) {
|
||||
|
||||
Reference in New Issue
Block a user