Skip to content

Commit 5ec13d2

Browse files
shirshak55pimterry
authored andcommitted
Allow autohiding the menu bar
1 parent 4af3339 commit 5ec13d2

File tree

4 files changed

+205
-9
lines changed

4 files changed

+205
-9
lines changed

package-lock.json

Lines changed: 184 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@
113113
"@sentry/integrations": "^6.7.1",
114114
"electron-context-menu": "^0.15.1",
115115
"electron-first-run": "^3.0.0",
116+
"electron-store": "^8.0.0",
116117
"electron-window-state": "^5.0.3",
117118
"os-proxy-config": "^1.1.1",
118119
"rimraf": "^2.7.1",

src/index.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import * as semver from 'semver';
4646
import * as rimraf from 'rimraf';
4747
import * as windowStateKeeper from 'electron-window-state';
4848
import { getSystemProxy } from 'os-proxy-config';
49+
import * as ElectronStore from 'electron-store'
4950

5051
import registerContextMenu = require('electron-context-menu');
5152
registerContextMenu({
@@ -56,6 +57,7 @@ import { reportStartupEvents } from './report-install-event';
5657
import { menu } from './menu';
5758
import { getDeferred, delay } from './util';
5859

60+
const store = new ElectronStore();
5961
const rmRF = promisify(rimraf);
6062

6163
const packageJson = require('../package.json');
@@ -112,6 +114,12 @@ const createWindow = () => {
112114

113115
show: false
114116
});
117+
118+
if (store.get("autoHideMenuBar")) {
119+
window.setAutoHideMenuBar(true);
120+
window.setMenuBarVisibility(false);
121+
}
122+
115123
windows.push(window);
116124

117125
windowState.manage(window);
@@ -566,4 +574,12 @@ if (!amMainInstance) {
566574
app.quit();
567575
}
568576
});
577+
}
578+
579+
export function autoHideMenuBar(status: boolean){
580+
windows.forEach((window) => {
581+
window.setAutoHideMenuBar(status);
582+
window.setMenuBarVisibility(!status);
583+
});
584+
store.set({ autoHideMenuBar: status });
569585
}

src/menu.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { app, Menu, MenuItemConstructorOptions } from 'electron';
2+
import { autoHideMenuBar } from "./index"
23

34
const menuTemplate: MenuItemConstructorOptions[] = [
45
{
@@ -27,6 +28,9 @@ const menuTemplate: MenuItemConstructorOptions[] = [
2728
{ role: 'reload' },
2829
{ role: 'forceReload' },
2930
{ role: 'toggleDevTools' },
31+
{ type: 'checkbox', 'label': 'Toggle Menu Bar', click(event) {
32+
autoHideMenuBar(event.checked || false)
33+
}}
3034
]
3135
},
3236
{

0 commit comments

Comments
 (0)