diff --git a/lib/main-menu.js b/lib/main-menu.js index 6ec9a6af0..3125d0971 100644 --- a/lib/main-menu.js +++ b/lib/main-menu.js @@ -37,7 +37,8 @@ const boost = macOS }, { label: 'Quit Boostnote', - role: 'quit' + role: 'quit', + accelerator: 'CommandOrControl+Q' } ] } @@ -45,7 +46,8 @@ const boost = macOS label: 'Boostnote', submenu: [ { - role: 'quit' + role: 'quit', + accelerator: 'Control+Q' } ] } @@ -131,7 +133,8 @@ if (LINUX) { file.submenu.push({ type: 'separator' }, { - role: 'quit' + role: 'quit', + accelerator: 'Control+Q' }) } diff --git a/lib/main-window.js b/lib/main-window.js index 5b53448dd..d97733c0c 100644 --- a/lib/main-window.js +++ b/lib/main-window.js @@ -43,7 +43,7 @@ if (process.platform !== 'linux' || process.env.DESKTOP_SESSION === 'cinnamon') mainWindow.on('close', function (e) { e.preventDefault() if (process.platform === 'win32') { - mainWindow.minimize() + quitApp() } else { if (mainWindow.isFullScreen()) { mainWindow.once('leave-full-screen', function () { @@ -51,26 +51,35 @@ if (process.platform !== 'linux' || process.env.DESKTOP_SESSION === 'cinnamon') }) mainWindow.setFullScreen(false) } else { - mainWindow.hide() + quitApp() } } }) app.on('before-quit', function (e) { - try { - config.set('windowsize', mainWindow.getBounds()) - } catch (e) { - // ignore any errors because an error occurs only on update - // refs: https://github.com/BoostIO/Boostnote/issues/243 - } + storeWindowSize() mainWindow.removeAllListeners() }) } else { app.on('window-all-closed', function () { - app.quit() + quitApp() }) } +function quitApp () { + storeWindowSize() + app.quit() +} + +function storeWindowSize () { + try { + config.set('windowsize', mainWindow.getBounds()) + } catch (e) { + // ignore any errors because an error occurs only on update + // refs: https://github.com/BoostIO/Boostnote/issues/243 + } +} + app.on('activate', function () { if (mainWindow == null) return null mainWindow.show()