diff --git a/src/BasePlatform.js b/src/BasePlatform.js index 803fe0e500..a97c14bf90 100644 --- a/src/BasePlatform.js +++ b/src/BasePlatform.js @@ -128,6 +128,18 @@ export default class BasePlatform { throw new Error("Unimplemented"); } + supportsAutoHideMenuBar(): boolean { + return false; + } + + async getAutoHideMenuBarEnabled(): boolean { + return false; + } + + async setAutoHideMenuBarEnabled(enabled: boolean): void { + throw new Error("Unimplemented"); + } + supportsMinimizeToTray(): boolean { return false; } diff --git a/src/components/views/settings/tabs/user/PreferencesUserSettingsTab.js b/src/components/views/settings/tabs/user/PreferencesUserSettingsTab.js index a645632dbc..6507854e59 100644 --- a/src/components/views/settings/tabs/user/PreferencesUserSettingsTab.js +++ b/src/components/views/settings/tabs/user/PreferencesUserSettingsTab.js @@ -1,5 +1,6 @@ /* Copyright 2019 New Vector Ltd +Copyright 2019 Michael Telatynski <7t3chguy@gmail.com> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -20,8 +21,8 @@ import {SettingLevel} from "../../../../../settings/SettingsStore"; import LabelledToggleSwitch from "../../../elements/LabelledToggleSwitch"; import SettingsStore from "../../../../../settings/SettingsStore"; import Field from "../../../elements/Field"; -const sdk = require("../../../../.."); -const PlatformPeg = require("../../../../../PlatformPeg"); +import sdk from "../../../../.."; +import PlatformPeg from "../../../../../PlatformPeg"; export default class PreferencesUserSettingsTab extends React.Component { static COMPOSER_SETTINGS = [ @@ -64,6 +65,8 @@ export default class PreferencesUserSettingsTab extends React.Component { this.state = { autoLaunch: false, autoLaunchSupported: false, + alwaysShowMenuBar: true, + alwaysShowMenuBarSupported: false, minimizeToTray: true, minimizeToTraySupported: false, autocompleteDelay: SettingsStore.getValueAt(SettingLevel.DEVICE, 'autocompleteDelay').toString(10), @@ -80,6 +83,13 @@ export default class PreferencesUserSettingsTab extends React.Component { autoLaunch = await platform.getAutoLaunchEnabled(); } + const alwaysShowMenuBarSupported = await platform.supportsAutoHideMenuBar(); + let alwaysShowMenuBar = true; + + if (alwaysShowMenuBarSupported) { + alwaysShowMenuBar = !await platform.getAutoHideMenuBarEnabled(); + } + const minimizeToTraySupported = await platform.supportsMinimizeToTray(); let minimizeToTray = true; @@ -87,13 +97,24 @@ export default class PreferencesUserSettingsTab extends React.Component { minimizeToTray = await platform.getMinimizeToTrayEnabled(); } - this.setState({autoLaunch, autoLaunchSupported, minimizeToTraySupported, minimizeToTray}); + this.setState({ + autoLaunch, + autoLaunchSupported, + alwaysShowMenuBarSupported, + alwaysShowMenuBar, + minimizeToTraySupported, + minimizeToTray, + }); } _onAutoLaunchChange = (checked) => { PlatformPeg.get().setAutoLaunchEnabled(checked).then(() => this.setState({autoLaunch: checked})); }; + _onAlwaysShowMenuBarChange = (checked) => { + PlatformPeg.get().setAutoHideMenuBarEnabled(!checked).then(() => this.setState({alwaysShowMenuBar: checked})); + }; + _onMinimizeToTrayChange = (checked) => { PlatformPeg.get().setMinimizeToTrayEnabled(checked).then(() => this.setState({minimizeToTray: checked})); }; @@ -111,16 +132,26 @@ export default class PreferencesUserSettingsTab extends React.Component { render() { let autoLaunchOption = null; if (this.state.autoLaunchSupported) { - autoLaunchOption = ; + autoLaunchOption = ; + } + + let autoHideMenuOption = null; + if (this.state.alwaysShowMenuBarSupported) { + autoHideMenuOption = ; } let minimizeToTrayOption = null; if (this.state.minimizeToTraySupported) { - minimizeToTrayOption = ; + minimizeToTrayOption = ; } return ( @@ -139,10 +170,14 @@ export default class PreferencesUserSettingsTab extends React.Component { {_t("Advanced")} {this._renderGroup(PreferencesUserSettingsTab.ADVANCED_SETTINGS)} {minimizeToTrayOption} + {autoHideMenuOption} {autoLaunchOption} - + ); diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 9ad20bf56c..15aa1ff313 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -591,6 +591,7 @@ "Labs": "Labs", "Notifications": "Notifications", "Start automatically after system login": "Start automatically after system login", + "Always show the window menu bar": "Always show the window menu bar", "Close button should minimize window to tray": "Close button should minimize window to tray", "Preferences": "Preferences", "Composer": "Composer",