Skip to content

Commit

Permalink
Merge pull request #7 from emrivero/issue_3
Browse files Browse the repository at this point in the history
Issue #3
  • Loading branch information
emrivero authored Oct 5, 2020
2 parents 2e28fe6 + 2102bca commit a365722
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
14 changes: 14 additions & 0 deletions electron/lib/shortcuts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const { globalShortcut, app } = require('electron');

const SHORTCUTS = [{
shortcut: 'CommandOrControl+W',
action: () => app.quit()
}];

const registerShortcuts = () => {
SHORTCUTS.forEach(opt => globalShortcut.register(opt.shortcut, opt.action));
};

module.exports = {
registerShortcuts,
};
2 changes: 2 additions & 0 deletions electron/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const {
computedMaxHeight
} = require('./lib/sizes');

const { registerShortcuts } = require('./lib/shortcuts');
require('dotenv').config();

const { minHeight, minWidth, title } = require('./app.config.json');
Expand Down Expand Up @@ -50,6 +51,7 @@ const createWindow = () => {
app.whenReady().then(() => {
createWindow();
Menu.setApplicationMenu(null);
registerShortcuts();
});

// Quit app when all windows are closed
Expand Down
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
{
"name": "andaluh-electron",
"version": "1.0.0",
"version": "1.1.0",
"license": "GPLv3",
"productName": "Andaluh transcriptor",
"description": "Transliterate spanish spelling to andaluz proposals",
"main": "electron/main.js",
"repository": {
"type": "git",
"url": "https://github.com/andalugeeks/andaluh-electron"
},
"author": {
"name": "Emilio Martinez Rivero",
"email": "[email protected]",
Expand Down

0 comments on commit a365722

Please sign in to comment.