-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
45 lines (33 loc) · 1008 Bytes
/
app.js
File metadata and controls
45 lines (33 loc) · 1008 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
"use strict"
const { app, globalShortcut } = require('electron')
const MainWindow = require('./mainWindow.js')
class Application {
constructor() {
this.mainWindow = new MainWindow()
app.whenReady().then(() => {
this.mainWindow.initialize()
this.registerGlobalKeyboardShortcuts()
})
app.on('window-all-closed', () => {
this.unregisterGlobalKeyboardShortcuts()
app.quit()
})
}
registerGlobalKeyboardShortcuts() {
this.registerGlobalKeyboardShortcut('CmdOrCtrl+Shift+D', () => {
this.mainWindow.toggleMute()
})
this.registerGlobalKeyboardShortcut('CmdOrCtrl+Shift+E', () => {
this.mainWindow.toggleCamera()
})
}
registerGlobalKeyboardShortcut(keyCode, callback) {
if (!globalShortcut.register(keyCode, callback)) {
console.warn(`WARN: Registration of global keyboard shortcut (${keyCode}) failed`)
}
}
unregisterGlobalKeyboardShortcuts() {
globalShortcut.unregisterAll()
}
}
new Application()