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 Jun 3, 2020
1 parent 512beff commit 6d6a3d3
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
Expand Up @@ -2,6 +2,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 @@ -67,4 +68,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 @@ -6,6 +6,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 waiverStore = new Store({name: 'waived-workdays'});

Expand Down Expand Up @@ -169,4 +170,6 @@ $(() => {
$('#waive-button').on('click', () => {
addWaiver();
});

bindDevToolsShortcut(window);
});

0 comments on commit 6d6a3d3

Please sign in to comment.