From f834598d7f4aaebb69c33f53a1a54bd967895b1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Rodr=C3=ADguez?= Date: Thu, 14 Apr 2022 12:03:08 +0200 Subject: [PATCH] Fullscreen shortcut bug (Resolve #18) --- package.json | 2 +- renderer/main_renderer.js | 24 +++++++++--------------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index 31a5b3d..7c3295f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "youtube-tv-electron", "productName": "YouTube TV", - "version": "2.2.3", + "version": "2.2.4", "description": "Cliente de YouTube TV sencillo para escritorio basado en electron.", "main": "main.js", "dependencies": { diff --git a/renderer/main_renderer.js b/renderer/main_renderer.js index 9a87531..3abcf8f 100644 --- a/renderer/main_renderer.js +++ b/renderer/main_renderer.js @@ -39,26 +39,16 @@ class Renderer { try { const { width, height } = JSON.parse(a); this.setResEmulator(width, height); - console.log('Estableciendo resoluciĆ³n preferida'); } catch (error) { this.setResEmulator(3840,2160); } } }) .catch((err) => { - console.log(err) this.setResEmulator(3840,2160); }) - ipcMain.on('network', (_, status) => { - if (typeof status == 'boolean') { - console.log('Estado de primer inicio'); - console.log(status); - } else { - console.log('Cambio de estado de red!'); - console.log(status); - } - }) + //ipcMain.on('network', (_, status) => { }) this.loadURL(); @@ -72,6 +62,7 @@ class Renderer { this.settings = new Settings(); } }) + globalShortcut.register('ctrl+f', () => { this.toggleFullScreen(); }) @@ -148,11 +139,13 @@ class Renderer { `) } + /** + * Conmuta entre estados de pantalla completa. + * @param {boolean} forced Fuerza un estado concreto. + */ toggleFullScreen(forced) { - if (forced == undefined) { - if (this.window.fullScreen) { - this.window.setFullScreen(false) - } + if (!forced || typeof forced !== 'boolean') { + this.window.setFullScreen(!this.window.fullScreen); } else { this.window.setFullScreen(forced); } @@ -174,6 +167,7 @@ class Renderer { !a ? this.window.loadURL(this.url, {userAgent: this.userAgent}) : this.window.loadURL(this.url+a, {userAgent: this.userAgent}); } catch (error) { + debugger; console.error(error); } }