Merge pull request #31 from feross/fix-26

Add alternate fullscreen shortcut ⌘+Shift+F (fix #26)
This commit is contained in:
Feross Aboukhadijeh
2016-03-05 17:25:44 -08:00
5 changed files with 22 additions and 6 deletions

View File

@@ -4,6 +4,7 @@ var electron = require('electron')
var ipc = require('./ipc')
var menu = require('./menu')
var windows = require('./windows')
var shortcuts = require('./shortcuts')
var app = electron.app
@@ -15,6 +16,7 @@ app.on('open-url', onOpen)
app.on('ready', function () {
electron.Menu.setApplicationMenu(menu.appMenu)
windows.createMainWindow(menu)
shortcuts.init(menu)
})
app.on('activate', function () {

View File

@@ -1,12 +1,12 @@
module.exports = {
init: init
}
var electron = require('electron')
var debug = require('debug')('webtorrent-app:ipcMain')
var ipcMain = electron.ipcMain
var windows = require('./windows')
module.exports = {
init: init
}
function init () {
ipcMain.on('addTorrentFromPaste', function (e) {
addTorrentFromPaste()

View File

@@ -18,7 +18,7 @@ function onWindowHide () {
function toggleFullScreen () {
debug('toggleFullScreen')
if (windows.main) {
if (windows.main && windows.main.isVisible()) {
windows.main.setFullScreen(!windows.main.isFullScreen())
}
}
@@ -289,7 +289,8 @@ var menu = {
appMenu: appMenu,
onToggleFullScreen: onToggleFullScreen,
onWindowHide: onWindowHide,
onWindowShow: onWindowShow
onWindowShow: onWindowShow,
toggleFullScreen: toggleFullScreen
}
module.exports = menu

12
main/shortcuts.js Normal file
View File

@@ -0,0 +1,12 @@
module.exports = {
init: init
}
var localShortcut = require('electron-localshortcut')
function init (menu) {
// ⌘+Shift+F is an alternative fullscreen shortcut to the one defined in menu.js.
// Electron does not support multiple accelerators for a single menu item, so this
// is registered separately here.
localShortcut.register('CmdOrCtrl+Shift+F', menu.toggleFullScreen)
}

View File

@@ -16,6 +16,7 @@
"create-torrent": "^3.22.1",
"debug": "^2.2.0",
"drag-drop": "^2.3.1",
"electron-localshortcut": "^0.6.0",
"hyperx": "^2.0.0",
"main-loop": "^3.2.0",
"network-address": "^1.1.0",