@@ -74,6 +74,8 @@ export default class PreferencesUserSettingsTab extends React.Component {
7474 this . state = {
7575 autoLaunch : false ,
7676 autoLaunchSupported : false ,
77+ warnBeforeExit : true ,
78+ warnBeforeExitSupported : false ,
7779 alwaysShowMenuBar : true ,
7880 alwaysShowMenuBarSupported : false ,
7981 minimizeToTray : true ,
@@ -96,6 +98,12 @@ export default class PreferencesUserSettingsTab extends React.Component {
9698 autoLaunch = await platform . getAutoLaunchEnabled ( ) ;
9799 }
98100
101+ const warnBeforeExitSupported = await platform . supportsWarnBeforeExit ( ) ;
102+ let warnBeforeExit = false ;
103+ if ( warnBeforeExitSupported ) {
104+ warnBeforeExit = await platform . shouldWarnBeforeExit ( ) ;
105+ }
106+
99107 const alwaysShowMenuBarSupported = await platform . supportsAutoHideMenuBar ( ) ;
100108 let alwaysShowMenuBar = true ;
101109 if ( alwaysShowMenuBarSupported ) {
@@ -111,6 +119,8 @@ export default class PreferencesUserSettingsTab extends React.Component {
111119 this . setState ( {
112120 autoLaunch,
113121 autoLaunchSupported,
122+ warnBeforeExit,
123+ warnBeforeExitSupported,
114124 alwaysShowMenuBarSupported,
115125 alwaysShowMenuBar,
116126 minimizeToTraySupported,
@@ -122,6 +132,10 @@ export default class PreferencesUserSettingsTab extends React.Component {
122132 PlatformPeg . get ( ) . setAutoLaunchEnabled ( checked ) . then ( ( ) => this . setState ( { autoLaunch : checked } ) ) ;
123133 } ;
124134
135+ _onWarnBeforeExitChange = ( checked ) => {
136+ PlatformPeg . get ( ) . setWarnBeforeExit ( checked ) . then ( ( ) => this . setState ( { warnBeforeExit : checked } ) ) ;
137+ }
138+
125139 _onAlwaysShowMenuBarChange = ( checked ) => {
126140 PlatformPeg . get ( ) . setAutoHideMenuBarEnabled ( ! checked ) . then ( ( ) => this . setState ( { alwaysShowMenuBar : checked } ) ) ;
127141 } ;
@@ -161,6 +175,14 @@ export default class PreferencesUserSettingsTab extends React.Component {
161175 label = { _t ( 'Start automatically after system login' ) } /> ;
162176 }
163177
178+ let warnBeforeExitOption = null ;
179+ if ( this . state . warnBeforeExitSupported ) {
180+ warnBeforeExitOption = < LabelledToggleSwitch
181+ value = { this . state . warnBeforeExit }
182+ onChange = { this . _onWarnBeforeExitChange }
183+ label = { _t ( 'Warn before quitting' ) } /> ;
184+ }
185+
164186 let autoHideMenuOption = null ;
165187 if ( this . state . alwaysShowMenuBarSupported ) {
166188 autoHideMenuOption = < LabelledToggleSwitch
@@ -202,6 +224,7 @@ export default class PreferencesUserSettingsTab extends React.Component {
202224 { minimizeToTrayOption }
203225 { autoHideMenuOption }
204226 { autoLaunchOption }
227+ { warnBeforeExitOption }
205228 < Field
206229 label = { _t ( 'Autocomplete delay (ms)' ) }
207230 type = 'number'
0 commit comments