Skip to content

Commit 0a05305

Browse files
Jack251970TBM13
authored andcommitted
Merge pull request Flow-Launcher#4025 from Flow-Launcher/hide_window_before_sleep
Save settings before shutdown/restart to prevent data loss
1 parent 3bba8dd commit 0a05305

File tree

1 file changed

+15
-3
lines changed
  • Plugins/Flow.Launcher.Plugin.Sys

1 file changed

+15
-3
lines changed

Plugins/Flow.Launcher.Plugin.Sys/Main.cs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,15 @@ private static List<Result> Commands(Query query)
195195
MessageBoxButton.YesNo, MessageBoxImage.Warning);
196196

197197
if (result == MessageBoxResult.Yes)
198+
{
199+
// Save settings before shutdown to avoid data loss
200+
Context.API.SaveAppAllSettings();
201+
198202
if (EnableShutdownPrivilege())
199203
PInvoke.ExitWindowsEx(EXIT_WINDOWS_FLAGS.EWX_SHUTDOWN | EXIT_WINDOWS_FLAGS.EWX_POWEROFF, REASON);
200204
else
201205
Process.Start("shutdown", "/s /t 0");
206+
}
202207

203208
return true;
204209
}
@@ -215,10 +220,15 @@ private static List<Result> Commands(Query query)
215220
MessageBoxButton.YesNo, MessageBoxImage.Warning);
216221

217222
if (result == MessageBoxResult.Yes)
223+
{
224+
// Save settings before restart to avoid data loss
225+
Context.API.SaveAppAllSettings();
226+
218227
if (EnableShutdownPrivilege())
219228
PInvoke.ExitWindowsEx(EXIT_WINDOWS_FLAGS.EWX_REBOOT, REASON);
220229
else
221230
Process.Start("shutdown", "/r /t 0");
231+
}
222232

223233
return true;
224234
}
@@ -235,10 +245,15 @@ private static List<Result> Commands(Query query)
235245
MessageBoxButton.YesNo, MessageBoxImage.Warning);
236246

237247
if (result == MessageBoxResult.Yes)
248+
{
249+
// Save settings before advanced restart to avoid data loss
250+
Context.API.SaveAppAllSettings();
251+
238252
if (EnableShutdownPrivilege())
239253
PInvoke.ExitWindowsEx(EXIT_WINDOWS_FLAGS.EWX_REBOOT | EXIT_WINDOWS_FLAGS.EWX_BOOTOPTIONS, REASON);
240254
else
241255
Process.Start("shutdown", "/r /o /t 0");
256+
}
242257

243258
return true;
244259
}
@@ -253,10 +268,8 @@ private static List<Result> Commands(Query query)
253268
Localize.flowlauncher_plugin_sys_dlgtext_logoff_computer(),
254269
Localize.flowlauncher_plugin_sys_log_off(),
255270
MessageBoxButton.YesNo, MessageBoxImage.Warning);
256-
257271
if (result == MessageBoxResult.Yes)
258272
PInvoke.ExitWindowsEx(EXIT_WINDOWS_FLAGS.EWX_LOGOFF, REASON);
259-
260273
return true;
261274
}
262275
},
@@ -307,7 +320,6 @@ private static List<Result> Commands(Query query)
307320
Localize.flowlauncher_plugin_sys_dlgtitle_error(),
308321
MessageBoxButton.OK, MessageBoxImage.Error);
309322
}
310-
311323
return true;
312324
}
313325
},

0 commit comments

Comments
 (0)