Skip to content

Commit

Permalink
added shortcut ctrl+q for quit and quit the app when using the Window…
Browse files Browse the repository at this point in the history
…s Close button
  • Loading branch information
Maurits Lourens authored and Maurits Lourens committed Oct 31, 2017
1 parent f9643c2 commit 34e9238
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
9 changes: 6 additions & 3 deletions lib/main-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,17 @@ const boost = macOS
},
{
label: 'Quit Boostnote',
role: 'quit'
role: 'quit',
accelerator: 'CommandOrControl+Q'
}
]
}
: {
label: 'Boostnote',
submenu: [
{
role: 'quit'
role: 'quit',
accelerator: 'Control+Q'
}
]
}
Expand Down Expand Up @@ -131,7 +133,8 @@ if (LINUX) {
file.submenu.push({
type: 'separator'
}, {
role: 'quit'
role: 'quit',
accelerator: 'Control+Q'
})
}

Expand Down
27 changes: 18 additions & 9 deletions lib/main-window.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,34 +43,43 @@ 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 () {
mainWindow.hide()
})
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()
Expand Down

0 comments on commit 34e9238

Please sign in to comment.