Add ability to hide tray icon on non-Mac (which has no tray icon)
This commit is contained in:
parent
814917d9ed
commit
cd37ffcef2
2 changed files with 40 additions and 4 deletions
|
@ -140,6 +140,18 @@ export default class BasePlatform {
|
||||||
throw new Error("Unimplemented");
|
throw new Error("Unimplemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
supportsTrayIcon(): boolean {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
async getTrayIconEnabled(): boolean {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
async setTrayIconEnabled(enabled: boolean): void {
|
||||||
|
throw new Error("Unimplemented");
|
||||||
|
}
|
||||||
|
|
||||||
supportsMinimizeToTray(): boolean {
|
supportsMinimizeToTray(): boolean {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,6 +69,8 @@ export default class PreferencesUserSettingsTab extends React.Component {
|
||||||
autoLaunchSupported: false,
|
autoLaunchSupported: false,
|
||||||
alwaysShowMenuBar: true,
|
alwaysShowMenuBar: true,
|
||||||
alwaysShowMenuBarSupported: false,
|
alwaysShowMenuBarSupported: false,
|
||||||
|
showTrayIcon: false,
|
||||||
|
showTrayIconSupported: false,
|
||||||
minimizeToTray: true,
|
minimizeToTray: true,
|
||||||
minimizeToTraySupported: false,
|
minimizeToTraySupported: false,
|
||||||
autocompleteDelay:
|
autocompleteDelay:
|
||||||
|
@ -85,21 +87,24 @@ export default class PreferencesUserSettingsTab extends React.Component {
|
||||||
|
|
||||||
const autoLaunchSupported = await platform.supportsAutoLaunch();
|
const autoLaunchSupported = await platform.supportsAutoLaunch();
|
||||||
let autoLaunch = false;
|
let autoLaunch = false;
|
||||||
|
|
||||||
if (autoLaunchSupported) {
|
if (autoLaunchSupported) {
|
||||||
autoLaunch = await platform.getAutoLaunchEnabled();
|
autoLaunch = await platform.getAutoLaunchEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
const alwaysShowMenuBarSupported = await platform.supportsAutoHideMenuBar();
|
const alwaysShowMenuBarSupported = await platform.supportsAutoHideMenuBar();
|
||||||
let alwaysShowMenuBar = true;
|
let alwaysShowMenuBar = true;
|
||||||
|
|
||||||
if (alwaysShowMenuBarSupported) {
|
if (alwaysShowMenuBarSupported) {
|
||||||
alwaysShowMenuBar = !await platform.getAutoHideMenuBarEnabled();
|
alwaysShowMenuBar = !await platform.getAutoHideMenuBarEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const showTrayIconSupported = await platform.supportsTrayIcon();
|
||||||
|
let showTrayIcon = true;
|
||||||
|
if (showTrayIconSupported) {
|
||||||
|
showTrayIcon = await platform.getTrayIconEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
const minimizeToTraySupported = await platform.supportsMinimizeToTray();
|
const minimizeToTraySupported = await platform.supportsMinimizeToTray();
|
||||||
let minimizeToTray = true;
|
let minimizeToTray = true;
|
||||||
|
|
||||||
if (minimizeToTraySupported) {
|
if (minimizeToTraySupported) {
|
||||||
minimizeToTray = await platform.getMinimizeToTrayEnabled();
|
minimizeToTray = await platform.getMinimizeToTrayEnabled();
|
||||||
}
|
}
|
||||||
|
@ -109,6 +114,8 @@ export default class PreferencesUserSettingsTab extends React.Component {
|
||||||
autoLaunchSupported,
|
autoLaunchSupported,
|
||||||
alwaysShowMenuBarSupported,
|
alwaysShowMenuBarSupported,
|
||||||
alwaysShowMenuBar,
|
alwaysShowMenuBar,
|
||||||
|
showTrayIconSupported,
|
||||||
|
showTrayIcon,
|
||||||
minimizeToTraySupported,
|
minimizeToTraySupported,
|
||||||
minimizeToTray,
|
minimizeToTray,
|
||||||
});
|
});
|
||||||
|
@ -122,6 +129,10 @@ export default class PreferencesUserSettingsTab extends React.Component {
|
||||||
PlatformPeg.get().setAutoHideMenuBarEnabled(!checked).then(() => this.setState({alwaysShowMenuBar: checked}));
|
PlatformPeg.get().setAutoHideMenuBarEnabled(!checked).then(() => this.setState({alwaysShowMenuBar: checked}));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
_onShowTrayIconChange = (checked) => {
|
||||||
|
PlatformPeg.get().setTrayIconEnabled(checked).then(() => this.setState({showTrayIcon: checked}));
|
||||||
|
};
|
||||||
|
|
||||||
_onMinimizeToTrayChange = (checked) => {
|
_onMinimizeToTrayChange = (checked) => {
|
||||||
PlatformPeg.get().setMinimizeToTrayEnabled(checked).then(() => this.setState({minimizeToTray: 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')} />;
|
label={_t('Always show the window menu bar')} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let enableTrayIcon = null;
|
||||||
|
if (this.state.showTrayIconSupported) {
|
||||||
|
enableTrayIcon = <LabelledToggleSwitch
|
||||||
|
value={this.state.showTrayIcon}
|
||||||
|
onChange={this._onShowTrayIconChange}
|
||||||
|
label={_t('Show tray icon')} />;
|
||||||
|
}
|
||||||
|
|
||||||
let minimizeToTrayOption = null;
|
let minimizeToTrayOption = null;
|
||||||
if (this.state.minimizeToTraySupported) {
|
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 = <LabelledToggleSwitch
|
minimizeToTrayOption = <LabelledToggleSwitch
|
||||||
value={this.state.minimizeToTray}
|
value={!disableOption && this.state.minimizeToTray}
|
||||||
|
disabled={disableOption}
|
||||||
onChange={this._onMinimizeToTrayChange}
|
onChange={this._onMinimizeToTrayChange}
|
||||||
label={_t('Close button should minimize window to tray')} />;
|
label={_t('Close button should minimize window to tray')} />;
|
||||||
}
|
}
|
||||||
|
@ -186,6 +209,7 @@ export default class PreferencesUserSettingsTab extends React.Component {
|
||||||
|
|
||||||
<span className="mx_SettingsTab_subheading">{_t("Advanced")}</span>
|
<span className="mx_SettingsTab_subheading">{_t("Advanced")}</span>
|
||||||
{this._renderGroup(PreferencesUserSettingsTab.ADVANCED_SETTINGS)}
|
{this._renderGroup(PreferencesUserSettingsTab.ADVANCED_SETTINGS)}
|
||||||
|
{enableTrayIcon}
|
||||||
{minimizeToTrayOption}
|
{minimizeToTrayOption}
|
||||||
{autoHideMenuOption}
|
{autoHideMenuOption}
|
||||||
{autoLaunchOption}
|
{autoLaunchOption}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue