@@ -193,7 +193,7 @@ private static unsafe bool EnableShutdownPrivilege()
193193 }
194194 }
195195
196- private static List < Result > Commands ( Query query )
196+ private List < Result > Commands ( Query query )
197197 {
198198 var results = new List < Result > ( ) ;
199199 var recycleBinFolder = "shell:RecycleBinFolder" ;
@@ -206,22 +206,23 @@ private static List<Result> Commands(Query query)
206206 IcoPath = "Images\\ shutdown.png" ,
207207 Action = c =>
208208 {
209- var result = Context . API . ShowMsgBox (
210- Localize . flowlauncher_plugin_sys_dlgtext_shutdown_computer ( ) ,
211- Localize . flowlauncher_plugin_sys_shutdown_computer ( ) ,
212- MessageBoxButton . YesNo , MessageBoxImage . Warning ) ;
209+ MessageBoxResult result = _settings . SkipPowerActionConfirmation
210+ ? MessageBoxResult . Yes
211+ : Context . API . ShowMsgBox (
212+ Localize . flowlauncher_plugin_sys_dlgtext_shutdown_computer ( ) ,
213+ Localize . flowlauncher_plugin_sys_shutdown_computer ( ) ,
214+ MessageBoxButton . YesNo , MessageBoxImage . Warning ) ;
215+
213216 if ( result == MessageBoxResult . Yes )
214217 {
215- // Save settings before shutdown to avoid data loss
216218 Context . API . SaveAppAllSettings ( ) ;
217-
218219 if ( EnableShutdownPrivilege ( ) )
219220 PInvoke . ExitWindowsEx ( EXIT_WINDOWS_FLAGS . EWX_SHUTDOWN | EXIT_WINDOWS_FLAGS . EWX_POWEROFF , REASON ) ;
220221 else
221222 Process . Start ( "shutdown" , "/s /t 0" ) ;
222223 }
223224 return true ;
224- }
225+ }
225226 } ,
226227 new Result
227228 {
@@ -230,21 +231,22 @@ private static List<Result> Commands(Query query)
230231 IcoPath = "Images\\ restart.png" ,
231232 Action = c =>
232233 {
233- var result = Context . API . ShowMsgBox (
234- Localize . flowlauncher_plugin_sys_dlgtext_restart_computer ( ) ,
235- Localize . flowlauncher_plugin_sys_restart_computer ( ) ,
236- MessageBoxButton . YesNo , MessageBoxImage . Warning ) ;
237- if ( result == MessageBoxResult . Yes )
238- {
239- // Save settings before restart to avoid data loss
240- Context . API . SaveAppAllSettings ( ) ;
241-
242- if ( EnableShutdownPrivilege ( ) )
243- PInvoke . ExitWindowsEx ( EXIT_WINDOWS_FLAGS . EWX_REBOOT , REASON ) ;
244- else
245- Process . Start ( "shutdown" , "/r /t 0" ) ;
246- }
247- return true ;
234+ MessageBoxResult result = _settings . SkipPowerActionConfirmation
235+ ? MessageBoxResult . Yes
236+ : Context . API . ShowMsgBox (
237+ Localize . flowlauncher_plugin_sys_dlgtext_restart_computer ( ) ,
238+ Localize . flowlauncher_plugin_sys_restart_computer ( ) ,
239+ MessageBoxButton . YesNo , MessageBoxImage . Warning ) ;
240+
241+ if ( result == MessageBoxResult . Yes )
242+ {
243+ Context . API . SaveAppAllSettings ( ) ;
244+ if ( EnableShutdownPrivilege ( ) )
245+ PInvoke . ExitWindowsEx ( EXIT_WINDOWS_FLAGS . EWX_REBOOT , REASON ) ;
246+ else
247+ Process . Start ( "shutdown" , "/r /t 0" ) ;
248+ }
249+ return true ;
248250 }
249251 } ,
250252 new Result
@@ -254,10 +256,13 @@ private static List<Result> Commands(Query query)
254256 IcoPath = "Images\\ restart_advanced.png" ,
255257 Action = c =>
256258 {
257- var result = Context . API . ShowMsgBox (
258- Localize . flowlauncher_plugin_sys_dlgtext_restart_computer_advanced ( ) ,
259- Localize . flowlauncher_plugin_sys_restart_computer ( ) ,
260- MessageBoxButton . YesNo , MessageBoxImage . Warning ) ;
259+ var result = _settings . SkipPowerActionConfirmation
260+ ? MessageBoxResult . Yes
261+ : Context . API . ShowMsgBox (
262+ Localize . flowlauncher_plugin_sys_dlgtext_restart_computer_advanced ( ) ,
263+ Localize . flowlauncher_plugin_sys_restart_computer ( ) ,
264+ MessageBoxButton . YesNo , MessageBoxImage . Warning ) ;
265+
261266 if ( result == MessageBoxResult . Yes )
262267 {
263268 // Save settings before advanced restart to avoid data loss
@@ -278,13 +283,16 @@ private static List<Result> Commands(Query query)
278283 IcoPath = "Images\\ logoff.png" ,
279284 Action = c =>
280285 {
281- var result = Context . API . ShowMsgBox (
282- Localize . flowlauncher_plugin_sys_dlgtext_logoff_computer ( ) ,
283- Localize . flowlauncher_plugin_sys_log_off ( ) ,
284- MessageBoxButton . YesNo , MessageBoxImage . Warning ) ;
285- if ( result == MessageBoxResult . Yes )
286- PInvoke . ExitWindowsEx ( EXIT_WINDOWS_FLAGS . EWX_LOGOFF , REASON ) ;
287- return true ;
286+ MessageBoxResult result = _settings . SkipPowerActionConfirmation
287+ ? MessageBoxResult . Yes
288+ : Context . API . ShowMsgBox (
289+ Localize . flowlauncher_plugin_sys_dlgtext_logoff_computer ( ) ,
290+ Localize . flowlauncher_plugin_sys_log_off ( ) ,
291+ MessageBoxButton . YesNo , MessageBoxImage . Warning ) ;
292+
293+ if ( result == MessageBoxResult . Yes )
294+ PInvoke . ExitWindowsEx ( EXIT_WINDOWS_FLAGS . EWX_LOGOFF , REASON ) ;
295+ return true ;
288296 }
289297 } ,
290298 new Result
0 commit comments