Merge pull request #231 from feross/shortcut-fix
Keyboard shortcuts: volume shortcuts should be local
This commit is contained in:
14
main/ipc.js
14
main/ipc.js
@@ -1,5 +1,5 @@
|
||||
module.exports = {
|
||||
init: init
|
||||
init
|
||||
}
|
||||
|
||||
var debug = require('debug')('webtorrent-app:ipcMain')
|
||||
@@ -23,13 +23,8 @@ function init () {
|
||||
app.emit('ipcReady')
|
||||
})
|
||||
|
||||
ipcMain.on('showOpenTorrentFile', function (e) {
|
||||
menu.showOpenTorrentFile()
|
||||
})
|
||||
|
||||
ipcMain.on('showCreateTorrent', function (e) {
|
||||
menu.showCreateTorrent()
|
||||
})
|
||||
ipcMain.on('showOpenTorrentFile', menu.showOpenTorrentFile)
|
||||
ipcMain.on('showCreateTorrent', menu.showCreateTorrent)
|
||||
|
||||
ipcMain.on('setBounds', function (e, bounds, maximize) {
|
||||
setBounds(bounds, maximize)
|
||||
@@ -62,6 +57,9 @@ function init () {
|
||||
|
||||
ipcMain.on('blockPowerSave', blockPowerSave)
|
||||
ipcMain.on('unblockPowerSave', unblockPowerSave)
|
||||
|
||||
ipcMain.on('onPlayerOpen', menu.onPlayerOpen)
|
||||
ipcMain.on('onPlayerClose', menu.onPlayerClose)
|
||||
}
|
||||
|
||||
function setBounds (bounds, maximize) {
|
||||
|
||||
53
main/menu.js
53
main/menu.js
@@ -1,11 +1,13 @@
|
||||
module.exports = {
|
||||
init: init,
|
||||
onToggleFullScreen: onToggleFullScreen,
|
||||
onWindowHide: onWindowHide,
|
||||
onWindowShow: onWindowShow,
|
||||
showOpenTorrentFile: showOpenTorrentFile,
|
||||
showCreateTorrent: showCreateTorrent,
|
||||
toggleFullScreen: toggleFullScreen
|
||||
init,
|
||||
onToggleFullScreen,
|
||||
onWindowHide,
|
||||
onWindowShow,
|
||||
onPlayerOpen,
|
||||
onPlayerClose,
|
||||
showCreateTorrent,
|
||||
showOpenTorrentFile,
|
||||
toggleFullScreen
|
||||
}
|
||||
|
||||
var debug = require('debug')('webtorrent-app:menu')
|
||||
@@ -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: [
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
module.exports = {
|
||||
init: init
|
||||
init
|
||||
}
|
||||
|
||||
var electron = require('electron')
|
||||
@@ -18,8 +18,4 @@ function init () {
|
||||
// Electron does not support multiple accelerators for a single menu item, so this
|
||||
// is registered separately here.
|
||||
localShortcut.register('CmdOrCtrl+Shift+F', menu.toggleFullScreen)
|
||||
|
||||
// Control Volume
|
||||
globalShortcut.register('CmdOrCtrl+Up', () => windows.main.send('dispatch', 'changeVolume', 0.1))
|
||||
globalShortcut.register('CmdOrCtrl+Down', () => windows.main.send('dispatch', 'changeVolume', -0.1))
|
||||
}
|
||||
|
||||
@@ -716,10 +716,30 @@ function openPlayer (torrentSummary, index, cb) {
|
||||
// otherwise, play the video
|
||||
state.window.title = torrentSummary.name
|
||||
update()
|
||||
|
||||
ipcRenderer.send('onPlayerOpen')
|
||||
|
||||
cb()
|
||||
})
|
||||
}
|
||||
|
||||
function closePlayer (cb) {
|
||||
state.window.title = config.APP_WINDOW_TITLE
|
||||
update()
|
||||
|
||||
if (state.window.isFullScreen) {
|
||||
dispatch('toggleFullScreen', false)
|
||||
}
|
||||
restoreBounds()
|
||||
stopServer()
|
||||
update()
|
||||
|
||||
ipcRenderer.send('unblockPowerSave')
|
||||
ipcRenderer.send('onPlayerClose')
|
||||
|
||||
cb()
|
||||
}
|
||||
|
||||
function openFile (torrentSummary, index) {
|
||||
var torrent = state.client.get(torrentSummary.infoHash)
|
||||
if (!torrent) return
|
||||
@@ -743,22 +763,6 @@ function openFolder (torrentSummary) {
|
||||
})
|
||||
}
|
||||
|
||||
function closePlayer (cb) {
|
||||
state.window.title = config.APP_WINDOW_TITLE
|
||||
update()
|
||||
|
||||
if (state.window.isFullScreen) {
|
||||
dispatch('toggleFullScreen', false)
|
||||
}
|
||||
restoreBounds()
|
||||
stopServer()
|
||||
update()
|
||||
|
||||
ipcRenderer.send('unblockPowerSave')
|
||||
|
||||
cb()
|
||||
}
|
||||
|
||||
function toggleTorrent (torrentSummary) {
|
||||
if (torrentSummary.status === 'paused') {
|
||||
torrentSummary.status = 'new'
|
||||
|
||||
Reference in New Issue
Block a user