diff --git a/src/BasePlatform.ts b/src/BasePlatform.ts index 9d7077097b..b6012d7597 100644 --- a/src/BasePlatform.ts +++ b/src/BasePlatform.ts @@ -212,6 +212,18 @@ export default abstract class BasePlatform { throw new Error("Unimplemented"); } + supportsWarnBeforeExit(): boolean { + return false; + } + + async shouldWarnBeforeExit(): Promise { + return false; + } + + async setWarnBeforeExit(enabled: boolean): Promise { + throw new Error("Unimplemented"); + } + supportsAutoHideMenuBar(): boolean { return false; } diff --git a/src/components/views/settings/tabs/user/PreferencesUserSettingsTab.js b/src/components/views/settings/tabs/user/PreferencesUserSettingsTab.js index 238f875e22..0cd3dd6698 100644 --- a/src/components/views/settings/tabs/user/PreferencesUserSettingsTab.js +++ b/src/components/views/settings/tabs/user/PreferencesUserSettingsTab.js @@ -74,6 +74,8 @@ export default class PreferencesUserSettingsTab extends React.Component { this.state = { autoLaunch: false, autoLaunchSupported: false, + warnBeforeExit: true, + warnBeforeExitSupported: false, alwaysShowMenuBar: true, alwaysShowMenuBarSupported: false, minimizeToTray: true, @@ -96,6 +98,12 @@ export default class PreferencesUserSettingsTab extends React.Component { autoLaunch = await platform.getAutoLaunchEnabled(); } + const warnBeforeExitSupported = await platform.supportsWarnBeforeExit(); + let warnBeforeExit = false; + if (warnBeforeExitSupported) { + warnBeforeExit = await platform.shouldWarnBeforeExit(); + } + const alwaysShowMenuBarSupported = await platform.supportsAutoHideMenuBar(); let alwaysShowMenuBar = true; if (alwaysShowMenuBarSupported) { @@ -111,6 +119,8 @@ export default class PreferencesUserSettingsTab extends React.Component { this.setState({ autoLaunch, autoLaunchSupported, + warnBeforeExit, + warnBeforeExitSupported, alwaysShowMenuBarSupported, alwaysShowMenuBar, minimizeToTraySupported, @@ -122,6 +132,10 @@ export default class PreferencesUserSettingsTab extends React.Component { PlatformPeg.get().setAutoLaunchEnabled(checked).then(() => this.setState({autoLaunch: checked})); }; + _onWarnBeforeExitChange = (checked) => { + PlatformPeg.get().setWarnBeforeExit(checked).then(() => this.setState({warnBeforeExit: checked})); + } + _onAlwaysShowMenuBarChange = (checked) => { PlatformPeg.get().setAutoHideMenuBarEnabled(!checked).then(() => this.setState({alwaysShowMenuBar: checked})); }; @@ -161,6 +175,14 @@ export default class PreferencesUserSettingsTab extends React.Component { label={_t('Start automatically after system login')} />; } + let warnBeforeExitOption = null; + if (this.state.warnBeforeExitSupported) { + warnBeforeExitOption = ; + } + let autoHideMenuOption = null; if (this.state.alwaysShowMenuBarSupported) { autoHideMenuOption =