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 = {
|
module.exports = {
|
||||||
init: init
|
init
|
||||||
}
|
}
|
||||||
|
|
||||||
var debug = require('debug')('webtorrent-app:ipcMain')
|
var debug = require('debug')('webtorrent-app:ipcMain')
|
||||||
@@ -23,13 +23,8 @@ function init () {
|
|||||||
app.emit('ipcReady')
|
app.emit('ipcReady')
|
||||||
})
|
})
|
||||||
|
|
||||||
ipcMain.on('showOpenTorrentFile', function (e) {
|
ipcMain.on('showOpenTorrentFile', menu.showOpenTorrentFile)
|
||||||
menu.showOpenTorrentFile()
|
ipcMain.on('showCreateTorrent', menu.showCreateTorrent)
|
||||||
})
|
|
||||||
|
|
||||||
ipcMain.on('showCreateTorrent', function (e) {
|
|
||||||
menu.showCreateTorrent()
|
|
||||||
})
|
|
||||||
|
|
||||||
ipcMain.on('setBounds', function (e, bounds, maximize) {
|
ipcMain.on('setBounds', function (e, bounds, maximize) {
|
||||||
setBounds(bounds, maximize)
|
setBounds(bounds, maximize)
|
||||||
@@ -62,6 +57,9 @@ function init () {
|
|||||||
|
|
||||||
ipcMain.on('blockPowerSave', blockPowerSave)
|
ipcMain.on('blockPowerSave', blockPowerSave)
|
||||||
ipcMain.on('unblockPowerSave', unblockPowerSave)
|
ipcMain.on('unblockPowerSave', unblockPowerSave)
|
||||||
|
|
||||||
|
ipcMain.on('onPlayerOpen', menu.onPlayerOpen)
|
||||||
|
ipcMain.on('onPlayerClose', menu.onPlayerClose)
|
||||||
}
|
}
|
||||||
|
|
||||||
function setBounds (bounds, maximize) {
|
function setBounds (bounds, maximize) {
|
||||||
|
|||||||
53
main/menu.js
53
main/menu.js
@@ -1,11 +1,13 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
init: init,
|
init,
|
||||||
onToggleFullScreen: onToggleFullScreen,
|
onToggleFullScreen,
|
||||||
onWindowHide: onWindowHide,
|
onWindowHide,
|
||||||
onWindowShow: onWindowShow,
|
onWindowShow,
|
||||||
showOpenTorrentFile: showOpenTorrentFile,
|
onPlayerOpen,
|
||||||
showCreateTorrent: showCreateTorrent,
|
onPlayerClose,
|
||||||
toggleFullScreen: toggleFullScreen
|
showCreateTorrent,
|
||||||
|
showOpenTorrentFile,
|
||||||
|
toggleFullScreen
|
||||||
}
|
}
|
||||||
|
|
||||||
var debug = require('debug')('webtorrent-app:menu')
|
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 () {
|
function toggleDevTools () {
|
||||||
debug('toggleDevTools')
|
debug('toggleDevTools')
|
||||||
if (windows.main) {
|
if (windows.main) {
|
||||||
@@ -75,6 +89,16 @@ function onWindowHide () {
|
|||||||
getMenuItem('Float on Top').enabled = false
|
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) {
|
function onToggleFullScreen (isFullScreen) {
|
||||||
isFullScreen = isFullScreen != null ? isFullScreen : windows.main.isFullScreen()
|
isFullScreen = isFullScreen != null ? isFullScreen : windows.main.isFullScreen()
|
||||||
windows.main.setMenuBarVisibility(!isFullScreen)
|
windows.main.setMenuBarVisibility(!isFullScreen)
|
||||||
@@ -196,6 +220,21 @@ function getAppMenuTemplate () {
|
|||||||
{
|
{
|
||||||
type: 'separator'
|
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',
|
label: 'Developer',
|
||||||
submenu: [
|
submenu: [
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
init: init
|
init
|
||||||
}
|
}
|
||||||
|
|
||||||
var electron = require('electron')
|
var electron = require('electron')
|
||||||
@@ -18,8 +18,4 @@ function init () {
|
|||||||
// Electron does not support multiple accelerators for a single menu item, so this
|
// Electron does not support multiple accelerators for a single menu item, so this
|
||||||
// is registered separately here.
|
// is registered separately here.
|
||||||
localShortcut.register('CmdOrCtrl+Shift+F', menu.toggleFullScreen)
|
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
|
// otherwise, play the video
|
||||||
state.window.title = torrentSummary.name
|
state.window.title = torrentSummary.name
|
||||||
update()
|
update()
|
||||||
|
|
||||||
|
ipcRenderer.send('onPlayerOpen')
|
||||||
|
|
||||||
cb()
|
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) {
|
function openFile (torrentSummary, index) {
|
||||||
var torrent = state.client.get(torrentSummary.infoHash)
|
var torrent = state.client.get(torrentSummary.infoHash)
|
||||||
if (!torrent) return
|
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) {
|
function toggleTorrent (torrentSummary) {
|
||||||
if (torrentSummary.status === 'paused') {
|
if (torrentSummary.status === 'paused') {
|
||||||
torrentSummary.status = 'new'
|
torrentSummary.status = 'new'
|
||||||
|
|||||||
Reference in New Issue
Block a user