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

Merge pull request #1043 from mslourens/close-in-windows

added shortcut ctrl+q for quit and quit the app when using the Windows Close button
This commit is contained in:
Kazu Yokomizo
2017-11-05 12:13:34 +09:00
committed by GitHub
2 changed files with 24 additions and 12 deletions

View File

@@ -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'
})
}

View File

@@ -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()