Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added 'Quit' option under 'File' #746

Merged
merged 4 commits into from
Sep 22, 2020
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ exports.get = function(props = {}) {
label: i18n.t('menu.file', '&Preferences…'),
accelerator: 'CmdOrCtrl+,',
click: () => sabaki.openDrawer('preferences')
},
{type: 'separator'},
{
label: i18n.t('menu.file', '&Quit'),
accelerator: 'CmdOrCtrl+Q',
click: () => app.quit()
}
]
},
Expand Down Expand Up @@ -863,14 +869,16 @@ exports.get = function(props = {}) {

appMenu.push(...items.slice(0, 2))

// Remove original 'Preferences' menu item
// Remove original 'Preferences' and 'Quit' menu items

let fileMenu = findMenuItem('file')
let preferenceItem = fileMenu.submenu.splice(
fileMenu.submenu.length - 2,
fileMenu.submenu.length - 4,
2
)[1]

fileMenu.submenu.splice(fileMenu.length - 2, 2)[1]

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead you can write

.splice(
  fileMenu.submenu.length - 4,
  4
)[1]

to remove the four last entries, so there's no need for two separate mutations.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have done so. I am sorry for requiring so much feedback, as I am new to JavaScript and I thought that it would be clearer if all that the code defining preferenceItemremoved was the 'Preferences' option.

appMenu.push(
{type: 'separator'},
preferenceItem,
Expand Down