Add user settings for warn before exit
This commit is contained in:
parent
760b11f214
commit
25a47b463e
3 changed files with 36 additions and 0 deletions
|
@ -212,6 +212,18 @@ export default abstract class BasePlatform {
|
|||
throw new Error("Unimplemented");
|
||||
}
|
||||
|
||||
supportsWarnBeforeExit(): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
async shouldWarnBeforeExit(): Promise<boolean> {
|
||||
return false;
|
||||
}
|
||||
|
||||
async setWarnBeforeExit(enabled: boolean): Promise<void> {
|
||||
throw new Error("Unimplemented");
|
||||
}
|
||||
|
||||
supportsAutoHideMenuBar(): boolean {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -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 = <LabelledToggleSwitch
|
||||
value={this.state.warnBeforeExit}
|
||||
onChange={this._onWarnBeforeExitChange}
|
||||
label={_t('Warn before quitting')} />;
|
||||
}
|
||||
|
||||
let autoHideMenuOption = null;
|
||||
if (this.state.alwaysShowMenuBarSupported) {
|
||||
autoHideMenuOption = <LabelledToggleSwitch
|
||||
|
@ -202,6 +224,7 @@ export default class PreferencesUserSettingsTab extends React.Component {
|
|||
{minimizeToTrayOption}
|
||||
{autoHideMenuOption}
|
||||
{autoLaunchOption}
|
||||
{warnBeforeExitOption}
|
||||
<Field
|
||||
label={_t('Autocomplete delay (ms)')}
|
||||
type='number'
|
||||
|
|
|
@ -1286,6 +1286,7 @@
|
|||
"Room ID or address of ban list": "Room ID or address of ban list",
|
||||
"Subscribe": "Subscribe",
|
||||
"Start automatically after system login": "Start automatically after system login",
|
||||
"Warn before quitting": "Warn before quitting",
|
||||
"Always show the window menu bar": "Always show the window menu bar",
|
||||
"Show tray icon and minimize window to it on close": "Show tray icon and minimize window to it on close",
|
||||
"Preferences": "Preferences",
|
||||
|
|
Loading…
Reference in a new issue