Allow configuration of whether closing window closes or minimizes to tray
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
150c941340
commit
b02b371250
3 changed files with 51 additions and 3 deletions
|
@ -113,4 +113,29 @@ export default class BasePlatform {
|
||||||
reload() {
|
reload() {
|
||||||
throw new Error("reload not implemented!");
|
throw new Error("reload not implemented!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
supportsAutoLaunch() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// XXX: Surely this should be a setting like any other?
|
||||||
|
async getAutoLaunchEnabled() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
async setAutoLaunchEnabled(enabled) {
|
||||||
|
throw new Error("Unimplemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
supportsMinimizeToTray() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
async getMinimizeToTrayEnabled() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
async setMinimizeToTrayEnabled() {
|
||||||
|
throw new Error("Unimplemented");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,24 +59,39 @@ export default class PreferencesSettingsTab extends React.Component {
|
||||||
this.state = {
|
this.state = {
|
||||||
autoLaunch: false,
|
autoLaunch: false,
|
||||||
autoLaunchSupported: false,
|
autoLaunchSupported: false,
|
||||||
|
minimizeToTray: true,
|
||||||
|
minimizeToTraySupported: false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
async componentWillMount(): void {
|
async componentWillMount(): void {
|
||||||
const autoLaunchSupported = await PlatformPeg.get().supportsAutoLaunch();
|
const platform = PlatformPeg.get();
|
||||||
|
|
||||||
|
const autoLaunchSupported = await platform.supportsAutoLaunch();
|
||||||
let autoLaunch = false;
|
let autoLaunch = false;
|
||||||
|
|
||||||
if (autoLaunchSupported) {
|
if (autoLaunchSupported) {
|
||||||
autoLaunch = await PlatformPeg.get().getAutoLaunchEnabled();
|
autoLaunch = await platform.getAutoLaunchEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setState({autoLaunch, autoLaunchSupported});
|
const minimizeToTraySupported = await platform.supportsMinimizeToTray();
|
||||||
|
let minimizeToTray = true;
|
||||||
|
|
||||||
|
if (minimizeToTraySupported) {
|
||||||
|
minimizeToTray = await platform.getMinimizeToTrayEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setState({autoLaunch, autoLaunchSupported, minimizeToTraySupported, minimizeToTray});
|
||||||
}
|
}
|
||||||
|
|
||||||
_onAutoLaunchChange = (checked) => {
|
_onAutoLaunchChange = (checked) => {
|
||||||
PlatformPeg.get().setAutoLaunchEnabled(checked).then(() => this.setState({autoLaunch: checked}));
|
PlatformPeg.get().setAutoLaunchEnabled(checked).then(() => this.setState({autoLaunch: checked}));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
_onMinimizeToTrayChange = (checked) => {
|
||||||
|
PlatformPeg.get().setMinimizeToTrayEnabled(checked).then(() => this.setState({minimizeToTray: checked}));
|
||||||
|
};
|
||||||
|
|
||||||
_onAutocompleteDelayChange = (e) => {
|
_onAutocompleteDelayChange = (e) => {
|
||||||
SettingsStore.setValue("autocompleteDelay", null, SettingLevel.DEVICE, e.target.value);
|
SettingsStore.setValue("autocompleteDelay", null, SettingLevel.DEVICE, e.target.value);
|
||||||
};
|
};
|
||||||
|
@ -93,6 +108,12 @@ export default class PreferencesSettingsTab extends React.Component {
|
||||||
onChange={this._onAutoLaunchChange}
|
onChange={this._onAutoLaunchChange}
|
||||||
label={_t('Start automatically after system login')} />;
|
label={_t('Start automatically after system login')} />;
|
||||||
}
|
}
|
||||||
|
let minimizeToTrayOption = null;
|
||||||
|
if (this.state.minimizeToTraySupported) {
|
||||||
|
minimizeToTrayOption = <LabelledToggleSwitch value={this.state.minimizeToTray}
|
||||||
|
onChange={this._onMinimizeToTrayChange}
|
||||||
|
label={_t('Close button should minimize window to tray')} />;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="mx_SettingsTab mx_PreferencesSettingsTab">
|
<div className="mx_SettingsTab mx_PreferencesSettingsTab">
|
||||||
|
@ -106,6 +127,7 @@ export default class PreferencesSettingsTab extends React.Component {
|
||||||
|
|
||||||
<span className="mx_SettingsTab_subheading">{_t("Advanced")}</span>
|
<span className="mx_SettingsTab_subheading">{_t("Advanced")}</span>
|
||||||
{this._renderGroup(PreferencesSettingsTab.ADVANCED_SETTINGS)}
|
{this._renderGroup(PreferencesSettingsTab.ADVANCED_SETTINGS)}
|
||||||
|
{minimizeToTrayOption}
|
||||||
{autoLaunchOption}
|
{autoLaunchOption}
|
||||||
<Field id={"autocompleteDelay"} label={_t('Autocomplete delay (ms)')} type='number'
|
<Field id={"autocompleteDelay"} label={_t('Autocomplete delay (ms)')} type='number'
|
||||||
value={SettingsStore.getValueAt(SettingLevel.DEVICE, 'autocompleteDelay')}
|
value={SettingsStore.getValueAt(SettingLevel.DEVICE, 'autocompleteDelay')}
|
||||||
|
|
|
@ -551,6 +551,7 @@
|
||||||
"Labs": "Labs",
|
"Labs": "Labs",
|
||||||
"Notifications": "Notifications",
|
"Notifications": "Notifications",
|
||||||
"Start automatically after system login": "Start automatically after system login",
|
"Start automatically after system login": "Start automatically after system login",
|
||||||
|
"Close button should minimize window to tray": "Close button should minimize window to tray",
|
||||||
"Preferences": "Preferences",
|
"Preferences": "Preferences",
|
||||||
"Composer": "Composer",
|
"Composer": "Composer",
|
||||||
"Timeline": "Timeline",
|
"Timeline": "Timeline",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue