diff --git a/src/BasePlatform.js b/src/BasePlatform.js index a97c14bf90..727a9cce93 100644 --- a/src/BasePlatform.js +++ b/src/BasePlatform.js @@ -140,6 +140,18 @@ export default class BasePlatform { throw new Error("Unimplemented"); } + supportsTrayIcon(): boolean { + return false; + } + + async getTrayIconEnabled(): boolean { + return false; + } + + async setTrayIconEnabled(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 5b0b5dbdcf..1b2a4817c8 100644 --- a/src/components/views/settings/tabs/user/PreferencesUserSettingsTab.js +++ b/src/components/views/settings/tabs/user/PreferencesUserSettingsTab.js @@ -69,6 +69,8 @@ export default class PreferencesUserSettingsTab extends React.Component { autoLaunchSupported: false, alwaysShowMenuBar: true, alwaysShowMenuBarSupported: false, + showTrayIcon: false, + showTrayIconSupported: false, minimizeToTray: true, minimizeToTraySupported: false, autocompleteDelay: @@ -85,21 +87,24 @@ export default class PreferencesUserSettingsTab extends React.Component { const autoLaunchSupported = await platform.supportsAutoLaunch(); let autoLaunch = false; - if (autoLaunchSupported) { autoLaunch = await platform.getAutoLaunchEnabled(); } const alwaysShowMenuBarSupported = await platform.supportsAutoHideMenuBar(); let alwaysShowMenuBar = true; - if (alwaysShowMenuBarSupported) { alwaysShowMenuBar = !await platform.getAutoHideMenuBarEnabled(); } + const showTrayIconSupported = await platform.supportsTrayIcon(); + let showTrayIcon = true; + if (showTrayIconSupported) { + showTrayIcon = await platform.getTrayIconEnabled(); + } + const minimizeToTraySupported = await platform.supportsMinimizeToTray(); let minimizeToTray = true; - if (minimizeToTraySupported) { minimizeToTray = await platform.getMinimizeToTrayEnabled(); } @@ -109,6 +114,8 @@ export default class PreferencesUserSettingsTab extends React.Component { autoLaunchSupported, alwaysShowMenuBarSupported, alwaysShowMenuBar, + showTrayIconSupported, + showTrayIcon, minimizeToTraySupported, minimizeToTray, }); @@ -122,6 +129,10 @@ export default class PreferencesUserSettingsTab extends React.Component { PlatformPeg.get().setAutoHideMenuBarEnabled(!checked).then(() => this.setState({alwaysShowMenuBar: checked})); }; + _onShowTrayIconChange = (checked) => { + PlatformPeg.get().setTrayIconEnabled(checked).then(() => this.setState({showTrayIcon: checked})); + }; + _onMinimizeToTrayChange = (checked) => { PlatformPeg.get().setMinimizeToTrayEnabled(checked).then(() => this.setState({minimizeToTray: checked})); }; @@ -163,10 +174,22 @@ export default class PreferencesUserSettingsTab extends React.Component { label={_t('Always show the window menu bar')} />; } + let enableTrayIcon = null; + if (this.state.showTrayIconSupported) { + enableTrayIcon = ; + } + let minimizeToTrayOption = null; if (this.state.minimizeToTraySupported) { + // If tray icon is disabled then this option is not available and forced to off. + // Unless tray icon is not supported (darwin) + const disableOption = this.state.showTrayIconSupported && !this.state.showTrayIcon; minimizeToTrayOption = ; } @@ -186,6 +209,7 @@ export default class PreferencesUserSettingsTab extends React.Component { {_t("Advanced")} {this._renderGroup(PreferencesUserSettingsTab.ADVANCED_SETTINGS)} + {enableTrayIcon} {minimizeToTrayOption} {autoHideMenuOption} {autoLaunchOption}