Add devtools shortcut

This commit is contained in:
GHOSCHT 2020-08-07 19:08:05 +02:00
parent 8301dc2e1b
commit 76964f80a3
3 changed files with 36 additions and 5 deletions

View file

@ -1,6 +1,7 @@
import path from 'path';
import { app, BrowserWindow, Menu, Tray } from 'electron';
import screenz from 'screenz';
import els from 'electron-localshortcut';
//App preferences
const windowSize = { width: 620, height: 320 };
@ -62,6 +63,15 @@ if (!gotTheLock) {
mainWindow.setMenu(null);
mainWindow.loadFile(path.resolve(path.join(__dirname, '../renderer/index.html')));
//Register shortcut to open devtools
els.register(mainWindow, 'Ctrl+Shift+I', () => {
if (mainWindow.webContents.isDevToolsOpened()) {
mainWindow.webContents.closeDevTools();
} else {
mainWindow.webContents.openDevTools();
}
});
//Create tray icon with context menu
trayIcon = createTray();
@ -69,11 +79,6 @@ if (!gotTheLock) {
trayIcon.on('click', () => {
mainWindow.show();
});
//Open devtools on startup
mainWindow.webContents.on('did-finish-load', () => {
mainWindow.webContents.openDevTools();
});
});
}

View file

@ -15,6 +15,7 @@
"@serialport/parser-readline": "^9.0.0",
"add": "^2.0.6",
"connected-react-router": "^6.8.0",
"electron-localshortcut": "^3.2.1",
"history": "^4.10.1",
"prop-types": "^15.7.2",
"react": "^16.13.1",

View file

@ -2674,6 +2674,21 @@ electron-devtools-installer@^3.0.0:
semver "^7.2.1"
unzip-crx-3 "^0.2.0"
electron-is-accelerator@^0.1.0:
version "0.1.2"
resolved "https://registry.yarnpkg.com/electron-is-accelerator/-/electron-is-accelerator-0.1.2.tgz#509e510c26a56b55e17f863a4b04e111846ab27b"
integrity sha1-UJ5RDCala1Xhf4Y6SwThEYRqsns=
electron-localshortcut@^3.2.1:
version "3.2.1"
resolved "https://registry.yarnpkg.com/electron-localshortcut/-/electron-localshortcut-3.2.1.tgz#cfc83a3eff5e28faf98ddcc87f80a2ce4f623cd3"
integrity sha512-DWvhKv36GsdXKnaFFhEiK8kZZA+24/yFLgtTwJJHc7AFgDjNRIBJZ/jq62Y/dWv9E4ypYwrVWN2bVrCYw1uv7Q==
dependencies:
debug "^4.0.1"
electron-is-accelerator "^0.1.0"
keyboardevent-from-electron-accelerator "^2.0.0"
keyboardevents-areequal "^0.2.1"
electron-mocha@^8.2.1:
version "8.2.2"
resolved "https://registry.yarnpkg.com/electron-mocha/-/electron-mocha-8.2.2.tgz#871d1fbbffcfdb7b880bbaf299e33ba993b4fe71"
@ -4568,6 +4583,16 @@ just-debounce@^1.0.0:
resolved "https://registry.yarnpkg.com/just-debounce/-/just-debounce-1.0.0.tgz#87fccfaeffc0b68cd19d55f6722943f929ea35ea"
integrity sha1-h/zPrv/AtozRnVX2cilD+SnqNeo=
keyboardevent-from-electron-accelerator@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/keyboardevent-from-electron-accelerator/-/keyboardevent-from-electron-accelerator-2.0.0.tgz#ace21b1aa4e47148815d160057f9edb66567c50c"
integrity sha512-iQcmNA0M4ETMNi0kG/q0h/43wZk7rMeKYrXP7sqKIJbHkTU8Koowgzv+ieR/vWJbOwxx5nDC3UnudZ0aLSu4VA==
keyboardevents-areequal@^0.2.1:
version "0.2.2"
resolved "https://registry.yarnpkg.com/keyboardevents-areequal/-/keyboardevents-areequal-0.2.2.tgz#88191ec738ce9f7591c25e9056de928b40277194"
integrity sha512-Nv+Kr33T0mEjxR500q+I6IWisOQ0lK1GGOncV0kWE6n4KFmpcu7RUX5/2B0EUtX51Cb0HjZ9VJsSY3u4cBa0kw==
keyv@^3.0.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/keyv/-/keyv-3.1.0.tgz#ecc228486f69991e49e9476485a5be1e8fc5c4d9"