Allow setting electron autoHideMenuBar and persist it

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski 2019-08-05 11:58:16 +01:00
parent e577f30cb5
commit 509839e79e
2 changed files with 26 additions and 6 deletions

View File

@ -156,6 +156,14 @@ ipcMain.on('ipcCall', async function(ev, payload) {
case 'setMinimizeToTrayEnabled': case 'setMinimizeToTrayEnabled':
store.set('minimizeToTray', global.minimizeToTray = args[0]); store.set('minimizeToTray', global.minimizeToTray = args[0]);
break; 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': case 'getAppVersion':
ret = app.getVersion(); ret = app.getVersion();
break; break;
@ -320,7 +328,7 @@ app.on('ready', () => {
mainWindow = global.mainWindow = new BrowserWindow({ mainWindow = global.mainWindow = new BrowserWindow({
icon: iconPath, icon: iconPath,
show: false, show: false,
autoHideMenuBar: true, autoHideMenuBar: store.get('autoHideMenuBar', true),
x: mainWindowState.x, x: mainWindowState.x,
y: mainWindowState.y, y: mainWindowState.y,

View File

@ -174,7 +174,7 @@ export default class ElectronPlatform extends VectorBasePlatform {
} }
async getAppVersion(): Promise<string> { async getAppVersion(): Promise<string> {
return await this._ipcCall('getAppVersion'); return this._ipcCall('getAppVersion');
} }
supportsAutoLaunch(): boolean { supportsAutoLaunch(): boolean {
@ -182,11 +182,23 @@ export default class ElectronPlatform extends VectorBasePlatform {
} }
async getAutoLaunchEnabled(): boolean { async getAutoLaunchEnabled(): boolean {
return await this._ipcCall('getAutoLaunchEnabled'); return this._ipcCall('getAutoLaunchEnabled');
} }
async setAutoLaunchEnabled(enabled: boolean): void { 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 { supportsMinimizeToTray(): boolean {
@ -194,11 +206,11 @@ export default class ElectronPlatform extends VectorBasePlatform {
} }
async getMinimizeToTrayEnabled(): boolean { async getMinimizeToTrayEnabled(): boolean {
return await this._ipcCall('getMinimizeToTrayEnabled'); return this._ipcCall('getMinimizeToTrayEnabled');
} }
async setMinimizeToTrayEnabled(enabled: boolean): void { async setMinimizeToTrayEnabled(enabled: boolean): void {
return await this._ipcCall('setMinimizeToTrayEnabled', enabled); return this._ipcCall('setMinimizeToTrayEnabled', enabled);
} }
async canSelfUpdate(): boolean { async canSelfUpdate(): boolean {