1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 17:56:25 +00:00

added shortcut ctrl+q for quit and quit the app when using the Windows Close button

This commit is contained in:
Maurits Lourens
2017-10-30 22:40:52 +01:00
parent f9643c2503
commit 34e9238cc4
2 changed files with 24 additions and 12 deletions

View File

@@ -37,7 +37,8 @@ const boost = macOS
}, },
{ {
label: 'Quit Boostnote', label: 'Quit Boostnote',
role: 'quit' role: 'quit',
accelerator: 'CommandOrControl+Q'
} }
] ]
} }
@@ -45,7 +46,8 @@ const boost = macOS
label: 'Boostnote', label: 'Boostnote',
submenu: [ submenu: [
{ {
role: 'quit' role: 'quit',
accelerator: 'Control+Q'
} }
] ]
} }
@@ -131,7 +133,8 @@ if (LINUX) {
file.submenu.push({ file.submenu.push({
type: 'separator' type: 'separator'
}, { }, {
role: 'quit' role: 'quit',
accelerator: 'Control+Q'
}) })
} }

View File

@@ -43,7 +43,7 @@ if (process.platform !== 'linux' || process.env.DESKTOP_SESSION === 'cinnamon')
mainWindow.on('close', function (e) { mainWindow.on('close', function (e) {
e.preventDefault() e.preventDefault()
if (process.platform === 'win32') { if (process.platform === 'win32') {
mainWindow.minimize() quitApp()
} else { } else {
if (mainWindow.isFullScreen()) { if (mainWindow.isFullScreen()) {
mainWindow.once('leave-full-screen', function () { mainWindow.once('leave-full-screen', function () {
@@ -51,26 +51,35 @@ if (process.platform !== 'linux' || process.env.DESKTOP_SESSION === 'cinnamon')
}) })
mainWindow.setFullScreen(false) mainWindow.setFullScreen(false)
} else { } else {
mainWindow.hide() quitApp()
} }
} }
}) })
app.on('before-quit', function (e) { app.on('before-quit', function (e) {
try { storeWindowSize()
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
}
mainWindow.removeAllListeners() mainWindow.removeAllListeners()
}) })
} else { } else {
app.on('window-all-closed', function () { 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 () { app.on('activate', function () {
if (mainWindow == null) return null if (mainWindow == null) return null
mainWindow.show() mainWindow.show()