mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Merge pull request #4025 from Flow-Launcher/hide_window_before_sleep
Save settings before shutdown/restart to prevent data loss
This commit is contained in:
commit
8c98aedac2
1 changed files with 15 additions and 12 deletions
|
|
@ -210,13 +210,16 @@ namespace Flow.Launcher.Plugin.Sys
|
|||
Localize.flowlauncher_plugin_sys_dlgtext_shutdown_computer(),
|
||||
Localize.flowlauncher_plugin_sys_shutdown_computer(),
|
||||
MessageBoxButton.YesNo, MessageBoxImage.Warning);
|
||||
|
||||
if (result == MessageBoxResult.Yes)
|
||||
{
|
||||
// Save settings before shutdown to avoid data loss
|
||||
Context.API.SaveAppAllSettings();
|
||||
|
||||
if (EnableShutdownPrivilege())
|
||||
PInvoke.ExitWindowsEx(EXIT_WINDOWS_FLAGS.EWX_SHUTDOWN | EXIT_WINDOWS_FLAGS.EWX_POWEROFF, REASON);
|
||||
else
|
||||
Process.Start("shutdown", "/s /t 0");
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
|
@ -231,13 +234,16 @@ namespace Flow.Launcher.Plugin.Sys
|
|||
Localize.flowlauncher_plugin_sys_dlgtext_restart_computer(),
|
||||
Localize.flowlauncher_plugin_sys_restart_computer(),
|
||||
MessageBoxButton.YesNo, MessageBoxImage.Warning);
|
||||
|
||||
if (result == MessageBoxResult.Yes)
|
||||
{
|
||||
// Save settings before restart to avoid data loss
|
||||
Context.API.SaveAppAllSettings();
|
||||
|
||||
if (EnableShutdownPrivilege())
|
||||
PInvoke.ExitWindowsEx(EXIT_WINDOWS_FLAGS.EWX_REBOOT, REASON);
|
||||
else
|
||||
Process.Start("shutdown", "/r /t 0");
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
|
@ -252,13 +258,16 @@ namespace Flow.Launcher.Plugin.Sys
|
|||
Localize.flowlauncher_plugin_sys_dlgtext_restart_computer_advanced(),
|
||||
Localize.flowlauncher_plugin_sys_restart_computer(),
|
||||
MessageBoxButton.YesNo, MessageBoxImage.Warning);
|
||||
|
||||
if (result == MessageBoxResult.Yes)
|
||||
{
|
||||
// Save settings before advanced restart to avoid data loss
|
||||
Context.API.SaveAppAllSettings();
|
||||
|
||||
if (EnableShutdownPrivilege())
|
||||
PInvoke.ExitWindowsEx(EXIT_WINDOWS_FLAGS.EWX_REBOOT | EXIT_WINDOWS_FLAGS.EWX_BOOTOPTIONS, REASON);
|
||||
else
|
||||
Process.Start("shutdown", "/r /o /t 0");
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
|
@ -273,10 +282,8 @@ namespace Flow.Launcher.Plugin.Sys
|
|||
Localize.flowlauncher_plugin_sys_dlgtext_logoff_computer(),
|
||||
Localize.flowlauncher_plugin_sys_log_off(),
|
||||
MessageBoxButton.YesNo, MessageBoxImage.Warning);
|
||||
|
||||
if (result == MessageBoxResult.Yes)
|
||||
PInvoke.ExitWindowsEx(EXIT_WINDOWS_FLAGS.EWX_LOGOFF, REASON);
|
||||
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
|
@ -342,7 +349,6 @@ namespace Flow.Launcher.Plugin.Sys
|
|||
Localize.flowlauncher_plugin_sys_dlgtitle_error(),
|
||||
MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
|
@ -416,13 +422,11 @@ namespace Flow.Launcher.Plugin.Sys
|
|||
{
|
||||
// Hide the window first then show msg after done because sometimes the reload could take a while, so not to make user think it's frozen.
|
||||
Context.API.HideMainWindow();
|
||||
|
||||
_ = Context.API.ReloadAllPluginData().ContinueWith(_ =>
|
||||
Context.API.ShowMsg(
|
||||
Localize.flowlauncher_plugin_sys_dlgtitle_success(),
|
||||
Localize.flowlauncher_plugin_sys_dlgtext_all_applicableplugins_reloaded()),
|
||||
TaskScheduler.Current);
|
||||
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
|
@ -502,7 +506,6 @@ namespace Flow.Launcher.Plugin.Sys
|
|||
else
|
||||
{
|
||||
Context.API.ChangeQuery($"{query.ActionKeyword}{Plugin.Query.ActionKeywordSeparator}{ThemeSelector.Keyword}{Plugin.Query.ActionKeywordSeparator}");
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue