Keyboard shortcuts: volume shortcuts should be local

`globalShortcut` will register the shortcut at the OS level, even when
the app is not focused.

Using `localShortcut` would work, but let's put it in the top menu
instead, where all the other shortcuts are.
This commit is contained in:
Feross Aboukhadijeh
2016-03-26 19:57:39 -07:00
parent 0cf89600c0
commit 9ef1d0a605
4 changed files with 64 additions and 27 deletions

View File

@@ -3,6 +3,8 @@ module.exports = {
onToggleFullScreen,
onWindowHide,
onWindowShow,
onPlayerOpen,
onPlayerClose,
showCreateTorrent,
showOpenTorrentFile,
toggleFullScreen
@@ -44,6 +46,18 @@ function toggleFloatOnTop (flag) {
}
}
function increaseVolume () {
if (windows.main) {
windows.main.send('dispatch', 'changeVolume', 0.1)
}
}
function decreaseVolume () {
if (windows.main) {
windows.main.send('dispatch', 'changeVolume', -0.1)
}
}
function toggleDevTools () {
debug('toggleDevTools')
if (windows.main) {
@@ -75,6 +89,16 @@ function onWindowHide () {
getMenuItem('Float on Top').enabled = false
}
function onPlayerOpen () {
getMenuItem('Increase Volume').enabled = true
getMenuItem('Decrease Volume').enabled = true
}
function onPlayerClose () {
getMenuItem('Increase Volume').enabled = false
getMenuItem('Decrease Volume').enabled = false
}
function onToggleFullScreen (isFullScreen) {
isFullScreen = isFullScreen != null ? isFullScreen : windows.main.isFullScreen()
windows.main.setMenuBarVisibility(!isFullScreen)
@@ -196,6 +220,21 @@ function getAppMenuTemplate () {
{
type: 'separator'
},
{
label: 'Increase Volume',
accelerator: 'CmdOrCtrl+Up',
click: increaseVolume,
enabled: false
},
{
label: 'Decrease Volume',
accelerator: 'CmdOrCtrl+Down',
click: decreaseVolume,
enabled: false
},
{
type: 'separator'
},
{
label: 'Developer',
submenu: [