Skip to content

Commit 063464e

Browse files
committed
Add option to auto-hide menu bar
Closes #151
1 parent a0fa353 commit 063464e

9 files changed

Lines changed: 69 additions & 2 deletions

File tree

app/src/lib/app-state.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,12 @@ export interface IAppState {
374374
*/
375375
readonly hideWindowOnQuit: boolean
376376

377+
/**
378+
* Whether or not the menu bar should be hidden until the user presses Alt.
379+
* Only applicable on Linux.
380+
*/
381+
readonly autoHideMenuBar: boolean
382+
377383
/**
378384
* Whether or not the app should use spell check on commit summary and description
379385
*/

app/src/lib/main-process-config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ import { TitleBarStyle } from '../ui/lib/title-bar-style'
77
export type MainProcessConfig = {
88
titleBarStyle: TitleBarStyle
99
hideWindowOnQuit: boolean
10+
autoHideMenuBar: boolean
1011
}
1112

1213
const DEFAULT_CONFIG: MainProcessConfig = {
1314
titleBarStyle: 'native',
1415
hideWindowOnQuit: false,
16+
autoHideMenuBar: false,
1517
}
1618

1719
let cachedMainProcessConfig: MainProcessConfig | null = null

app/src/lib/stores/app-store.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,7 @@ export class AppStore extends TypedBaseStore<IAppState> {
705705
private readonly lastSidebarWorktreeRefreshAt = new Map<string, number>()
706706
private showCompareTab: boolean = showCompareTabDefault
707707
private hideWindowOnQuit: boolean = __DARWIN__
708+
private autoHideMenuBar: boolean = false
708709

709710
private useWindowsOpenSSH: boolean = false
710711

@@ -1317,6 +1318,7 @@ export class AppStore extends TypedBaseStore<IAppState> {
13171318
currentOnboardingTutorialStep: this.currentOnboardingTutorialStep,
13181319
repositoryIndicatorsEnabled: this.repositoryIndicatorsEnabled,
13191320
hideWindowOnQuit: this.hideWindowOnQuit,
1321+
autoHideMenuBar: this.autoHideMenuBar,
13201322
commitSpellcheckEnabled: this.commitSpellcheckEnabled,
13211323
showCommitAuthorInfo: this.showCommitAuthorInfo,
13221324
currentDragElement: this.currentDragElement,
@@ -2757,6 +2759,7 @@ export class AppStore extends TypedBaseStore<IAppState> {
27572759
const mainProcessConfig = await getMainProcessConfig()
27582760
this.titleBarStyle = mainProcessConfig.titleBarStyle
27592761
this.hideWindowOnQuit = mainProcessConfig.hideWindowOnQuit
2762+
this.autoHideMenuBar = mainProcessConfig.autoHideMenuBar
27602763

27612764
this.lastThankYou = getObject<ILastThankYou>(lastThankYouKey)
27622765

@@ -8429,6 +8432,15 @@ export class AppStore extends TypedBaseStore<IAppState> {
84298432
return updateMainProcessConfig({ hideWindowOnQuit })
84308433
}
84318434

8435+
public _setAutoHideMenuBar(autoHideMenuBar: boolean) {
8436+
if (this.autoHideMenuBar === autoHideMenuBar) {
8437+
return
8438+
}
8439+
this.autoHideMenuBar = autoHideMenuBar
8440+
this.emitUpdate()
8441+
return updateMainProcessConfig({ autoHideMenuBar })
8442+
}
8443+
84328444
public async _resolveCurrentEditor() {
84338445
const match = await findEditorOrDefault(this.selectedExternalEditor)
84348446
const resolvedExternalEditor = match != null ? match.editor : null

app/src/main-process/app-window.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ export class AppWindow {
8383
windowOptions.frame = false
8484
}
8585
windowOptions.icon = join(__dirname, 'static', 'logos', '512x512.png')
86+
windowOptions.autoHideMenuBar = readMainProcessConfig().autoHideMenuBar
8687

8788
// relax restriction here for users trying to run app at a small
8889
// resolution and any other side-effects of dropping this restriction are

app/src/ui/app.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1745,6 +1745,7 @@ export class App extends React.Component<IAppProps, IAppState> {
17451745
showCompareTab={this.state.showCompareTab}
17461746
repositoryIndicatorsEnabled={this.state.repositoryIndicatorsEnabled}
17471747
hideWindowOnQuit={this.state.hideWindowOnQuit}
1748+
autoHideMenuBar={this.state.autoHideMenuBar}
17481749
onEditGlobalGitConfig={this.editGlobalGitConfig}
17491750
underlineLinks={this.state.underlineLinks}
17501751
showDiffCheckMarks={this.state.showDiffCheckMarks}

app/src/ui/dispatcher/dispatcher.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3011,6 +3011,10 @@ export class Dispatcher {
30113011
this.appStore._setHideWindowOnQuit(hideWindowOnQuit)
30123012
}
30133013

3014+
public setAutoHideMenuBar(autoHideMenuBar: boolean) {
3015+
this.appStore._setAutoHideMenuBar(autoHideMenuBar)
3016+
}
3017+
30143018
public setCommitSpellcheckEnabled(commitSpellcheckEnabled: boolean) {
30153019
this.appStore._setCommitSpellcheckEnabled(commitSpellcheckEnabled)
30163020
}

app/src/ui/preferences/advanced.tsx

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ interface IAdvancedPreferencesProps {
1111
readonly useExternalCredentialHelper: boolean
1212
readonly repositoryIndicatorsEnabled: boolean
1313
readonly hideWindowOnQuit: boolean
14+
readonly autoHideMenuBar: boolean
1415
readonly onUseWindowsOpenSSHChanged: (checked: boolean) => void
1516
readonly onOptOutofReportingChanged: (checked: boolean) => void
1617
readonly onUseExternalCredentialHelperChanged: (checked: boolean) => void
1718
readonly onRepositoryIndicatorsEnabledChanged: (enabled: boolean) => void
1819
readonly onHideWindowOnQuitChanged: (enabled: boolean) => void
20+
readonly onAutoHideMenuBarChanged: (enabled: boolean) => void
1921
}
2022

2123
interface IAdvancedPreferencesState {
@@ -82,6 +84,12 @@ export class Advanced extends React.Component<
8284
this.props.onHideWindowOnQuitChanged(event.currentTarget.checked)
8385
}
8486

87+
private onAutoHideMenuBarChanged = (
88+
event: React.FormEvent<HTMLInputElement>
89+
) => {
90+
this.props.onAutoHideMenuBarChanged(event.currentTarget.checked)
91+
}
92+
8593
private reportDesktopUsageLabel() {
8694
return (
8795
<span>
@@ -93,7 +101,7 @@ export class Advanced extends React.Component<
93101

94102
public render() {
95103
return (
96-
<DialogContent>
104+
<DialogContent className="advanced-tab">
97105
{!__DARWIN__ && this.renderAppSettings()}
98106
<div className="advanced-section">
99107
<h2>Background updates</h2>
@@ -201,6 +209,25 @@ export class Advanced extends React.Component<
201209
background. Use Ctrl+Q to completely quit the app.
202210
</p>
203211
</div>
212+
{!__DARWIN__ && (
213+
<div style={{ marginTop: 'var(--spacing)' }}>
214+
<Checkbox
215+
label="Auto-hide menu bar"
216+
value={
217+
this.props.autoHideMenuBar
218+
? CheckboxValue.On
219+
: CheckboxValue.Off
220+
}
221+
onChange={this.onAutoHideMenuBarChanged}
222+
/>
223+
<div className="git-settings-description">
224+
<p>
225+
Hide the menu bar and show it temporarily when Alt is pressed.
226+
Takes effect after restarting the app.
227+
</p>
228+
</div>
229+
</div>
230+
)}
204231
</div>
205232
)
206233
}

app/src/ui/preferences/preferences.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ interface IPreferencesProps {
131131
readonly showBranchNameInRepoList: ShowBranchNameInRepoListSetting
132132
readonly branchSortOrder: BranchSortOrder
133133
readonly hideWindowOnQuit: boolean
134+
readonly autoHideMenuBar: boolean
134135
readonly onEditGlobalGitConfig: () => void
135136
readonly underlineLinks: boolean
136137
readonly showDiffCheckMarks: boolean
@@ -193,6 +194,7 @@ interface IPreferencesState {
193194
readonly showBranchNameInRepoList: ShowBranchNameInRepoListSetting
194195
readonly branchSortOrder: BranchSortOrder
195196
readonly hideWindowOnQuit: boolean
197+
readonly autoHideMenuBar: boolean
196198

197199
readonly initiallySelectedTheme: ApplicationTheme
198200
readonly initiallySelectedTabSize: number
@@ -283,6 +285,7 @@ export class Preferences extends React.Component<
283285
showBranchNameInRepoList: this.props.showBranchNameInRepoList,
284286
branchSortOrder: this.props.branchSortOrder,
285287
hideWindowOnQuit: this.props.hideWindowOnQuit,
288+
autoHideMenuBar: this.props.autoHideMenuBar,
286289
initiallySelectedTheme: this.props.selectedTheme,
287290
initiallySelectedTabSize: this.props.selectedTabSize,
288291
initiallySelectedDiffFontSize: this.props.selectedDiffFontSize,
@@ -781,6 +784,7 @@ export class Preferences extends React.Component<
781784
useExternalCredentialHelper={this.state.useExternalCredentialHelper}
782785
repositoryIndicatorsEnabled={this.state.repositoryIndicatorsEnabled}
783786
hideWindowOnQuit={this.state.hideWindowOnQuit}
787+
autoHideMenuBar={this.state.autoHideMenuBar}
784788
onUseWindowsOpenSSHChanged={this.onUseWindowsOpenSSHChanged}
785789
onOptOutofReportingChanged={this.onOptOutofReportingChanged}
786790
onUseExternalCredentialHelperChanged={
@@ -790,6 +794,7 @@ export class Preferences extends React.Component<
790794
this.onRepositoryIndicatorsEnabledChanged
791795
}
792796
onHideWindowOnQuitChanged={this.onHideWindowOnQuitChanged}
797+
onAutoHideMenuBarChanged={this.onAutoHideMenuBarChanged}
793798
/>
794799
)
795800
break
@@ -829,6 +834,10 @@ export class Preferences extends React.Component<
829834
this.setState({ hideWindowOnQuit })
830835
}
831836

837+
private onAutoHideMenuBarChanged = (autoHideMenuBar: boolean) => {
838+
this.setState({ autoHideMenuBar })
839+
}
840+
832841
private onLockFileDeleted = () => {
833842
this.setState({ existingLockFilePath: undefined })
834843
}
@@ -1176,6 +1185,10 @@ export class Preferences extends React.Component<
11761185
dispatcher.setHideWindowOnQuit(this.state.hideWindowOnQuit)
11771186
}
11781187

1188+
if (this.state.autoHideMenuBar !== this.props.autoHideMenuBar) {
1189+
dispatcher.setAutoHideMenuBar(this.state.autoHideMenuBar)
1190+
}
1191+
11791192
if (this.state.hooksPreferencesDirty) {
11801193
if (this.state.enableGitHookEnv !== undefined) {
11811194
setHooksEnvEnabled(this.state.enableGitHookEnv)

app/styles/ui/_dialog.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,8 @@ dialog {
523523
min-height: $default-tab-height;
524524

525525
&.accounts-tab,
526-
&.appearance-tab {
526+
&.appearance-tab,
527+
&.advanced-tab {
527528
max-height: $default-tab-height;
528529
overflow: auto;
529530
}

0 commit comments

Comments
 (0)