From 509839e79ecca3383e760215d1dda879e3458601 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 5 Aug 2019 11:58:16 +0100 Subject: [PATCH] Allow setting electron autoHideMenuBar and persist it Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- electron_app/src/electron-main.js | 10 +++++++++- src/vector/platform/ElectronPlatform.js | 22 +++++++++++++++++----- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/electron_app/src/electron-main.js b/electron_app/src/electron-main.js index 6da972fd6c..c7dc4868d2 100644 --- a/electron_app/src/electron-main.js +++ b/electron_app/src/electron-main.js @@ -156,6 +156,14 @@ ipcMain.on('ipcCall', async function(ev, payload) { case 'setMinimizeToTrayEnabled': store.set('minimizeToTray', global.minimizeToTray = args[0]); break; + case 'getAutoHideMenuBarEnabled': + ret = global.mainWindow.isMenuBarAutoHide(); + break; + case 'setAutoHideMenuBarEnabled': + store.set('autoHideMenuBar', args[0]); + global.mainWindow.setAutoHideMenuBar(args[0]); + global.mainWindow.setMenuBarVisibility(!args[0]); + break; case 'getAppVersion': ret = app.getVersion(); break; @@ -320,7 +328,7 @@ app.on('ready', () => { mainWindow = global.mainWindow = new BrowserWindow({ icon: iconPath, show: false, - autoHideMenuBar: true, + autoHideMenuBar: store.get('autoHideMenuBar', true), x: mainWindowState.x, y: mainWindowState.y, diff --git a/src/vector/platform/ElectronPlatform.js b/src/vector/platform/ElectronPlatform.js index 387403a600..8700ae249b 100644 --- a/src/vector/platform/ElectronPlatform.js +++ b/src/vector/platform/ElectronPlatform.js @@ -174,7 +174,7 @@ export default class ElectronPlatform extends VectorBasePlatform { } async getAppVersion(): Promise { - return await this._ipcCall('getAppVersion'); + return this._ipcCall('getAppVersion'); } supportsAutoLaunch(): boolean { @@ -182,11 +182,23 @@ export default class ElectronPlatform extends VectorBasePlatform { } async getAutoLaunchEnabled(): boolean { - return await this._ipcCall('getAutoLaunchEnabled'); + return this._ipcCall('getAutoLaunchEnabled'); } async setAutoLaunchEnabled(enabled: boolean): void { - return await this._ipcCall('setAutoLaunchEnabled', enabled); + return this._ipcCall('setAutoLaunchEnabled', enabled); + } + + supportsAutoHideMenuBar(): boolean { + return true; + } + + async getAutoHideMenuBarEnabled(): boolean { + return this._ipcCall('getAutoHideMenuBarEnabled'); + } + + async setAutoHideMenuBarEnabled(enabled: boolean): void { + return this._ipcCall('setAutoHideMenuBarEnabled', enabled); } supportsMinimizeToTray(): boolean { @@ -194,11 +206,11 @@ export default class ElectronPlatform extends VectorBasePlatform { } async getMinimizeToTrayEnabled(): boolean { - return await this._ipcCall('getMinimizeToTrayEnabled'); + return this._ipcCall('getMinimizeToTrayEnabled'); } async setMinimizeToTrayEnabled(enabled: boolean): void { - return await this._ipcCall('setMinimizeToTrayEnabled', enabled); + return this._ipcCall('setMinimizeToTrayEnabled', enabled); } async canSelfUpdate(): boolean {