ELECTRON-337: remove dev tools menu item and map the behaviour to global shortcut (#331)

This commit is contained in:
Vishwas Shashidhar 2018-03-29 12:43:54 +05:30 committed by GitHub
parent 923bd3ba1a
commit e449ece7bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 30 additions and 19 deletions

View File

@ -80,15 +80,6 @@ const template = [{
}
}
},
{
label: 'Toggle Developer Tools',
accelerator: isMac ? 'Alt+Command+I' : 'Ctrl+Shift+I',
click(item, focusedWindow) {
if (focusedWindow) {
focusedWindow.webContents.toggleDevTools();
}
}
},
{
label: 'Set Downloads Directory',
click() {

View File

@ -3,6 +3,7 @@
const fs = require('fs');
const electron = require('electron');
const app = electron.app;
const globalShortcut = electron.globalShortcut;
const crashReporter = electron.crashReporter;
const BrowserWindow = electron.BrowserWindow;
const path = require('path');
@ -224,6 +225,7 @@ function doCreateMainWindow(initialUrl, initialBounds, isCustomTitleBar) {
});
});
registerShortcuts();
handlePermissionRequests(mainWindow.webContents);
addWindowKey(key, mainWindow);
@ -505,7 +507,25 @@ function doCreateMainWindow(initialUrl, initialBounds, isCustomTitleBar) {
});
});
// ELECTRON-323: Handle session permission requests
/**
* Register shortcuts for the app
*/
function registerShortcuts() {
// Register dev tools shortcut
globalShortcut.register(isMac ? 'Alt+Command+I' : 'Ctrl+Shift+I', () => {
let focusedWindow = BrowserWindow.getFocusedWindow();
if (focusedWindow && !focusedWindow.isDestroyed()) {
focusedWindow.webContents.toggleDevTools();
}
});
}
/**
* Sets permission requests for the window
* @param webContents Web contents of the window
*/
function handlePermissionRequests(webContents) {
let session = webContents.session;

View File

@ -138,9 +138,9 @@ describe('Tests for Always on top', () => {
robot.setMouseDelay(200);
robot.moveMouse(190, 0);
robot.mouseClick();
// Key tap 10 times as "Always on Top" is in the
// 10th position under view menu item
for (let i = 0; i < 10; i++) {
// Key tap 9 times as "Always on Top" is in the
// 9th position under view menu item
for (let i = 0; i < 9; i++) {
robot.keyTap('down');
}
robot.keyTap('enter');

View File

@ -105,9 +105,9 @@ describe('Tests for Full screen', () => {
robot.mouseClick();
robot.setKeyboardDelay(100);
// Key tap 8 times as "Enter Full Screen" is in the
// 8th position under view menu item
for (let i = 0; i < 8; i++) {
// Key tap 7 times as "Enter Full Screen" is in the
// 7th position under view menu item
for (let i = 0; i < 7; i++) {
robot.keyTap('down');
}
robot.keyTap('enter');

View File

@ -119,9 +119,9 @@ describe('Tests for Minimize on Close', () => {
robot.mouseClick();
robot.setKeyboardDelay(100);
// Key tap 9 times as "Minimize on Close" is in the
// 9th position under view menu item
for (let i = 0; i < 9; i++) {
// Key tap 10 times as "Minimize on Close" is in the
// 10th position under view menu item
for (let i = 0; i < 10; i++) {
robot.keyTap('down');
}
robot.keyTap('enter');