Refactor: Improve power action logic and property setter

- Add braces for better readability in shutdown/reboot logic (Main.cs).
- Prevent redundant OnPropertyChanged calls in _skipPowerActionConfirmation setter (Settings.cs).
This commit is contained in:
DB P 2026-02-20 17:34:37 +09:00
parent 2d7d025682
commit cecd90e675
2 changed files with 15 additions and 10 deletions

View file

@ -222,7 +222,7 @@ namespace Flow.Launcher.Plugin.Sys
Process.Start("shutdown", "/s /t 0"); Process.Start("shutdown", "/s /t 0");
} }
return true; return true;
} }
}, },
new Result new Result
{ {
@ -238,15 +238,15 @@ namespace Flow.Launcher.Plugin.Sys
Localize.flowlauncher_plugin_sys_restart_computer(), Localize.flowlauncher_plugin_sys_restart_computer(),
MessageBoxButton.YesNo, MessageBoxImage.Warning); MessageBoxButton.YesNo, MessageBoxImage.Warning);
if (result == MessageBoxResult.Yes) if (result == MessageBoxResult.Yes)
{ {
Context.API.SaveAppAllSettings(); Context.API.SaveAppAllSettings();
if (EnableShutdownPrivilege()) if (EnableShutdownPrivilege())
PInvoke.ExitWindowsEx(EXIT_WINDOWS_FLAGS.EWX_REBOOT, REASON); PInvoke.ExitWindowsEx(EXIT_WINDOWS_FLAGS.EWX_REBOOT, REASON);
else else
Process.Start("shutdown", "/r /t 0"); Process.Start("shutdown", "/r /t 0");
} }
return true; return true;
} }
}, },
new Result new Result

View file

@ -130,7 +130,12 @@ public class Settings : BaseModel
get => _skipPowerActionConfirmation; get => _skipPowerActionConfirmation;
set set
{ {
if (_skipPowerActionConfirmation == value)
{
return;
}
_skipPowerActionConfirmation = value; _skipPowerActionConfirmation = value;
OnPropertyChanged();
} }
} }
} }