Add two globalShortcuts (#351)

Cmd+Shift+L -> Search Vault
Cmd+Shift+G -> Password Generator
This commit is contained in:
Marcelo Dominguez 2019-12-16 10:59:19 -03:00 committed by Kyle Spearrin
parent 594e463e02
commit f7bfe40b71
1 changed files with 21 additions and 1 deletions

View File

@ -1,4 +1,4 @@
import { app } from 'electron'; import { app, globalShortcut } from 'electron';
import * as path from 'path'; import * as path from 'path';
import { I18nService } from './services/i18n.service'; import { I18nService } from './services/i18n.service';
@ -43,6 +43,26 @@ export class Main {
appDataPath = path.join(process.env.SNAP_USER_DATA, 'appdata'); appDataPath = path.join(process.env.SNAP_USER_DATA, 'appdata');
} }
app.on('ready', () => {
globalShortcut.register('CommandOrControl+Shift+L', async () => {
if (this.windowMain.win === null) {
await this.windowMain.createWindow();
}
this.messagingService.send('focusSearch');
this.windowMain.win.show();
});
globalShortcut.register('CommandOrControl+Shift+G', async () => {
if (this.windowMain.win === null) {
await this.windowMain.createWindow();
}
this.messagingService.send('openPasswordGenerator');
this.windowMain.win.show();
});
});
if (appDataPath != null) { if (appDataPath != null) {
app.setPath('userData', appDataPath); app.setPath('userData', appDataPath);
} }