Skip to content

Commit e6dff7c

Browse files
committed
exit confirmation
1 parent 4e9fbfc commit e6dff7c

File tree

2 files changed

+30
-19
lines changed

2 files changed

+30
-19
lines changed

Electron/main.js

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -394,11 +394,15 @@ const buildMenu = (opts) => {
394394
{ role: 'unhide' },
395395
{ type: 'separator' },
396396
...(options.footermenu),
397-
{
398-
label: 'Close App',
399-
role: 'quit',
400-
accelerator: shortcut('close')
401-
}
397+
{ label: 'Close app', accelerator: shortcut('quit'), click: (ev) => {
398+
console.warn('Quit dialog');
399+
dialog.showMessageBox({message: 'Are you sure you want to quit?', type:'question', buttons:['Yes', 'No']}).then((res) => {
400+
if (res.response == 0) {
401+
app.quit();
402+
}
403+
})
404+
405+
}}
402406
]
403407
}] : []),
404408
// { role: 'fileMenu' }
@@ -558,10 +562,20 @@ const buildMenu = (opts) => {
558562
windows.focused.call('checkupdates', true);
559563
}
560564
},
561-
...(isMac ? [{ type: 'separator' }] : [])
565+
...(isMac ? [{ type: 'separator' }] : [
566+
{ label: 'Close app', accelerator: shortcut('quit'), click: (ev) => {
567+
console.warn('Quit dialog');
568+
dialog.showMessageBox({message: 'Are you sure you want to quit?', type:'question', buttons:['Yes', 'No']}).then((res) => {
569+
if (res.response == 0) {
570+
app.quit();
571+
}
572+
})
573+
574+
}}
575+
])
562576
] : []),
563577
//win.webContents.send('context', 'Iconize');
564-
...(isMac ? [{ role: 'close' }] : [{ type: 'separator' }, ...(options.footermenu)])
578+
...(isMac ? [] : [{ type: 'separator' }, ...(options.footermenu)])
565579
]
566580
},
567581
// { role: 'editMenu' }
@@ -659,16 +673,8 @@ const buildMenu = (opts) => {
659673
{ role: 'togglefullscreen' },
660674
...(isMac ? [
661675
{ type: 'separator' },
662-
{ role: 'front' },
663-
{ type: 'separator' },
664-
{ role: 'window' }
665-
] : [
666-
{
667-
label: 'Close Window',
668-
role: 'close',
669-
accelerator: shortcut('close')
670-
}
671-
])
676+
{ role: 'front' }
677+
] : [])
672678
]
673679
},
674680

@@ -911,7 +917,11 @@ callFakeMenu["checkupdates"] = () => {
911917
}
912918

913919
callFakeMenu["exit"] = () => {
914-
app.quit();
920+
dialog.showMessageBox({message: 'Are you sure you want to quit?', type:'question', buttons:['Yes', 'No']}).then((res) => {
921+
if (res.response == 0) {
922+
app.quit();
923+
}
924+
})
915925
}
916926

917927
const devicesHID = {};

Electron/shortcuts.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@
1212
"evaluate_init" : ["Cmd+i", "Alt+i"],
1313
"clear_outputs" : ["Cmd+u", "Alt+u"],
1414
"evaluate_all" : ["Cmd+a", "Alt+a"],
15-
"close" : ["Cmd+q", "Alt+q"]
15+
"close" : ["Cmd+q", "Alt+q"],
16+
"quit" : ["Cmd+q", "Ctrl+q"]
1617
}

0 commit comments

Comments
 (0)