mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Merge pull request #4273 from onesounds/20250220_SkipConfirm
Some checks are pending
Build / build (push) Waiting to run
Some checks are pending
Build / build (push) Waiting to run
Add option to skip confirmation for power actions (Sys Plugin)
This commit is contained in:
commit
11e0f8c3a4
4 changed files with 56 additions and 24 deletions
|
|
@ -3,6 +3,9 @@
|
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||
|
||||
<!-- Setting -->
|
||||
<system:String x:Key="flowlauncher_plugin_sys_skip_confirm">Skip confirmation when Shutting down, Restarting, or Logging off</system:String>
|
||||
|
||||
<!-- Command List -->
|
||||
<system:String x:Key="flowlauncher_plugin_sys_name">Name</system:String>
|
||||
<system:String x:Key="flowlauncher_plugin_sys_desc">Description</system:String>
|
||||
|
|
|
|||
|
|
@ -193,7 +193,7 @@ namespace Flow.Launcher.Plugin.Sys
|
|||
}
|
||||
}
|
||||
|
||||
private static List<Result> Commands(Query query)
|
||||
private List<Result> Commands(Query query)
|
||||
{
|
||||
var results = new List<Result>();
|
||||
var recycleBinFolder = "shell:RecycleBinFolder";
|
||||
|
|
@ -206,15 +206,16 @@ namespace Flow.Launcher.Plugin.Sys
|
|||
IcoPath = "Images\\shutdown.png",
|
||||
Action = c =>
|
||||
{
|
||||
var result = Context.API.ShowMsgBox(
|
||||
Localize.flowlauncher_plugin_sys_dlgtext_shutdown_computer(),
|
||||
Localize.flowlauncher_plugin_sys_shutdown_computer(),
|
||||
MessageBoxButton.YesNo, MessageBoxImage.Warning);
|
||||
var result = _settings.SkipPowerActionConfirmation
|
||||
? MessageBoxResult.Yes
|
||||
: Context.API.ShowMsgBox(
|
||||
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
|
||||
|
|
@ -230,15 +231,16 @@ namespace Flow.Launcher.Plugin.Sys
|
|||
IcoPath = "Images\\restart.png",
|
||||
Action = c =>
|
||||
{
|
||||
var result = Context.API.ShowMsgBox(
|
||||
Localize.flowlauncher_plugin_sys_dlgtext_restart_computer(),
|
||||
Localize.flowlauncher_plugin_sys_restart_computer(),
|
||||
MessageBoxButton.YesNo, MessageBoxImage.Warning);
|
||||
var result = _settings.SkipPowerActionConfirmation
|
||||
? MessageBoxResult.Yes
|
||||
: Context.API.ShowMsgBox(
|
||||
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
|
||||
|
|
@ -254,10 +256,13 @@ namespace Flow.Launcher.Plugin.Sys
|
|||
IcoPath = "Images\\restart_advanced.png",
|
||||
Action = c =>
|
||||
{
|
||||
var result = Context.API.ShowMsgBox(
|
||||
Localize.flowlauncher_plugin_sys_dlgtext_restart_computer_advanced(),
|
||||
Localize.flowlauncher_plugin_sys_restart_computer(),
|
||||
MessageBoxButton.YesNo, MessageBoxImage.Warning);
|
||||
var result = _settings.SkipPowerActionConfirmation
|
||||
? MessageBoxResult.Yes
|
||||
: Context.API.ShowMsgBox(
|
||||
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
|
||||
|
|
@ -278,10 +283,13 @@ namespace Flow.Launcher.Plugin.Sys
|
|||
IcoPath = "Images\\logoff.png",
|
||||
Action = c =>
|
||||
{
|
||||
var result = Context.API.ShowMsgBox(
|
||||
Localize.flowlauncher_plugin_sys_dlgtext_logoff_computer(),
|
||||
Localize.flowlauncher_plugin_sys_log_off(),
|
||||
MessageBoxButton.YesNo, MessageBoxImage.Warning);
|
||||
var result = _settings.SkipPowerActionConfirmation
|
||||
? MessageBoxResult.Yes
|
||||
: Context.API.ShowMsgBox(
|
||||
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;
|
||||
|
|
|
|||
|
|
@ -124,4 +124,18 @@ public class Settings : BaseModel
|
|||
|
||||
[JsonIgnore]
|
||||
public Command SelectedCommand { get; set; }
|
||||
private bool _skipPowerActionConfirmation;
|
||||
public bool SkipPowerActionConfirmation
|
||||
{
|
||||
get => _skipPowerActionConfirmation;
|
||||
set
|
||||
{
|
||||
if (_skipPowerActionConfirmation == value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_skipPowerActionConfirmation = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,13 +12,20 @@
|
|||
|
||||
<Grid Margin="{StaticResource SettingPanelMargin}">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<StackPanel
|
||||
Grid.Row="0"
|
||||
Margin="0 0 0 6"
|
||||
HorizontalAlignment="Left"
|
||||
Orientation="Horizontal">
|
||||
<CheckBox Content="{DynamicResource flowlauncher_plugin_sys_skip_confirm}" IsChecked="{Binding Settings.SkipPowerActionConfirmation}" />
|
||||
</StackPanel>
|
||||
<ListView
|
||||
x:Name="lbxCommands"
|
||||
Grid.Row="0"
|
||||
Grid.Row="1"
|
||||
Margin="{StaticResource SettingPanelItemTopBottomMargin}"
|
||||
BorderBrush="DarkGray"
|
||||
BorderThickness="1"
|
||||
|
|
@ -57,7 +64,7 @@
|
|||
</ListView>
|
||||
|
||||
<StackPanel
|
||||
Grid.Row="1"
|
||||
Grid.Row="2"
|
||||
Margin="{StaticResource SettingPanelItemTopBottomMargin}"
|
||||
HorizontalAlignment="Right"
|
||||
Orientation="Horizontal">
|
||||
|
|
|
|||
Loading…
Reference in a new issue