diff --git a/app/js/index.js b/app/js/index.js index 39e26eb..1458e68 100644 --- a/app/js/index.js +++ b/app/js/index.js @@ -1,9 +1,8 @@ 'use strict'; -var ipc = require('ipc'); -var remote = require('remote'); -var Tray = remote.require('tray'); -var Menu = remote.require('menu'); +const {Tray, Menu} = require('electron').remote; + +const {ipcRenderer} = require('electron'); var path = require('path'); var soundButtons = document.querySelectorAll('.button-sound'); @@ -31,14 +30,14 @@ function prepareButton(buttonEl, soundName) { } closeEl.addEventListener('click', function () { - ipc.send('close-main-window'); + ipcRenderer.send('close-main-window'); }); settingsEl.addEventListener('click', function () { - ipc.send('open-settings-window'); + ipcRenderer.send('open-settings-window'); }); -ipc.on('global-shortcut', function (arg) { +ipcRenderer.on('global-shortcut', (arg) => { var event = new MouseEvent('click'); soundButtons[arg].dispatchEvent(event); }); @@ -58,13 +57,13 @@ var trayMenuTemplate = [ { label: 'Settings', click: function () { - ipc.send('open-settings-window'); + ipcRenderer.send('open-settings-window'); } }, { label: 'Quit', click: function () { - ipc.send('close-main-window'); + ipcRenderer.send('close-main-window'); } } ]; diff --git a/app/js/settings.js b/app/js/settings.js index aeaaeba..d21d9fd 100644 --- a/app/js/settings.js +++ b/app/js/settings.js @@ -1,13 +1,13 @@ 'use strict'; -var ipc = require('ipc'); +const {ipcRenderer} = require('electron'); var configuration = require('../configuration'); var modifierCheckboxes = document.querySelectorAll('.global-shortcut'); var closeEl = document.querySelector('.close'); closeEl.addEventListener('click', function (e) { - ipc.send('close-settings-window'); + ipcRenderer.send('close-settings-window'); }); for (var i = 0; i < modifierCheckboxes.length; i++) { @@ -33,5 +33,5 @@ function bindModifierCheckboxes(e) { } configuration.saveSettings('shortcutKeys', shortcutKeys); - ipc.send('set-global-shortcuts'); + ipcRenderer.send('set-global-shortcuts'); } \ No newline at end of file diff --git a/main.js b/main.js index cf5f201..e7263b1 100644 --- a/main.js +++ b/main.js @@ -1,10 +1,7 @@ 'use strict'; -var app = require('app'); -var BrowserWindow = require('browser-window'); -var globalShortcut = require('global-shortcut'); +const {app, BrowserWindow, globalShortcut, ipcMain} = require('electron'); var configuration = require('./configuration'); -var ipc = require('ipc'); var mainWindow = null; var settingsWindow = null; @@ -21,7 +18,7 @@ app.on('ready', function() { width: 368 }); - mainWindow.loadUrl('file://' + __dirname + '/app/index.html'); + mainWindow.loadURL('file://' + __dirname + '/app/index.html'); setGlobalShortcuts(); }); @@ -40,11 +37,11 @@ function setGlobalShortcuts() { }); } -ipc.on('close-main-window', function () { +ipcMain.on('close-main-window', () => { app.quit(); }); -ipc.on('open-settings-window', function () { +ipcMain.on('open-settings-window', () => { if (settingsWindow) { return; } @@ -56,19 +53,19 @@ ipc.on('open-settings-window', function () { width: 200 }); - settingsWindow.loadUrl('file://' + __dirname + '/app/settings.html'); + settingsWindow.loadURL('file://' + __dirname + '/app/settings.html'); settingsWindow.on('closed', function () { settingsWindow = null; }); }); -ipc.on('close-settings-window', function () { +ipcMain.on('close-settings-window', function () { if (settingsWindow) { settingsWindow.close(); } }); -ipc.on('set-global-shortcuts', function () { +ipcMain.on('set-global-shortcuts', function () { setGlobalShortcuts(); }); \ No newline at end of file