Skip to content

Commit

Permalink
Enhancement thamara#245: DevTools shortcut on Preferences and Waiver …
Browse files Browse the repository at this point in the history
…windows
  • Loading branch information
araujoarthur0 committed May 31, 2020
1 parent 44263a1 commit 29875d9
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
20 changes: 20 additions & 0 deletions js/window-aux.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const { remote } = require('electron');
const { BrowserWindow } = remote;

/**
* Binds to the JS "window" the shortcut CTRL+SHIFT+I to toggle Chrome Dev Tools.
* @param {Window} window
*/
function bindDevToolsShortcut(window) {
window.addEventListener('keyup', (event) => {
if (event.ctrlKey && event.shiftKey && (event.keyCode == 73 || event.keyCode == 105)) { // 'i' or 'I'
BrowserWindow.getFocusedWindow().webContents.toggleDevTools();
event.preventDefault();
return false;
}
}, true);
}

module.exports = {
bindDevToolsShortcut
};
3 changes: 3 additions & 0 deletions src/preferences.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const { ipcRenderer } = require('electron');
const { getUserPreferences } = require('../js/user-preferences.js');
const { applyTheme } = require('../js/themes.js');
const { bindDevToolsShortcut } = require('../js/window-aux.js');

// Global values for preferences page
let usersStyles = getUserPreferences();
Expand Down Expand Up @@ -66,4 +67,6 @@ $(() => {
repetition.change(function() {
notificationsInterval.prop('disabled', !repetition.is(':checked'));
});

bindDevToolsShortcut(window);
});
3 changes: 3 additions & 0 deletions src/workday-waiver.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const { getUserPreferences, showDay } = require('../js/user-preferences.js');
const { validateTime, diffDays } = require('../js/time-math.js');
const { applyTheme } = require('../js/themes.js');
const { getDateStr } = require('../js/date-aux.js');
const { bindDevToolsShortcut } = require('../js/window-aux.js');
const { remote } = require('electron');
const { BrowserWindow, dialog } = remote;
const Store = require('electron-store');
Expand Down Expand Up @@ -171,4 +172,6 @@ $(() => {
$('#waive-button').on('click', function() {
addWaiver();
});

bindDevToolsShortcut(window);
});

0 comments on commit 29875d9

Please sign in to comment.