From d363cf8137d5af58448c1e4df5bd3cec0dbf8c90 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Mon, 29 Sep 2025 10:42:19 +0800 Subject: [PATCH] Add property change for settings class & Add localize support for enum --- .../Flow.Launcher.Plugin.Shell/Settings.cs | 123 ++++++++++++++++-- 1 file changed, 114 insertions(+), 9 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Shell/Settings.cs b/Plugins/Flow.Launcher.Plugin.Shell/Settings.cs index 4616a18ec..92db4771e 100644 --- a/Plugins/Flow.Launcher.Plugin.Shell/Settings.cs +++ b/Plugins/Flow.Launcher.Plugin.Shell/Settings.cs @@ -1,24 +1,121 @@ using System.Collections.Generic; +using Flow.Launcher.Localization.Attributes; namespace Flow.Launcher.Plugin.Shell { - public class Settings + public class Settings : BaseModel { - public Shell Shell { get; set; } = Shell.Cmd; + private Shell _shell = Shell.Cmd; + public Shell Shell + { + get => _shell; + set + { + if (_shell != value) + { + _shell = value; + OnPropertyChanged(); + } + } + } - public bool ReplaceWinR { get; set; } = false; + private bool _replaceWinR = false; + public bool ReplaceWinR + { + get => _replaceWinR; + set + { + if (_replaceWinR != value) + { + _replaceWinR = value; + OnPropertyChanged(); + } + } + } - public bool CloseShellAfterPress { get; set; } = false; + private bool _closeShellAfterPress = false; + public bool CloseShellAfterPress + { + get => _closeShellAfterPress; + set + { + if (_closeShellAfterPress != value) + { + _closeShellAfterPress = value; + OnPropertyChanged(); + } + } + } - public bool LeaveShellOpen { get; set; } + private bool _leaveShellOpen; + public bool LeaveShellOpen + { + get => _leaveShellOpen; + set + { + if (_leaveShellOpen != value) + { + _leaveShellOpen = value; + OnPropertyChanged(); + } + } + } - public bool RunAsAdministrator { get; set; } = true; + private bool _runAsAdministrator = true; + public bool RunAsAdministrator + { + get => _runAsAdministrator; + set + { + if (_runAsAdministrator != value) + { + _runAsAdministrator = value; + OnPropertyChanged(); + } + } + } - public bool UseWindowsTerminal { get; set; } = false; + private bool _useWindowsTerminal = false; + public bool UseWindowsTerminal + { + get => _useWindowsTerminal; + set + { + if (_useWindowsTerminal != value) + { + _useWindowsTerminal = value; + OnPropertyChanged(); + } + } + } - public bool ShowOnlyMostUsedCMDs { get; set; } + private bool _showOnlyMostUsedCMDs; + public bool ShowOnlyMostUsedCMDs + { + get => _showOnlyMostUsedCMDs; + set + { + if (_showOnlyMostUsedCMDs != value) + { + _showOnlyMostUsedCMDs = value; + OnPropertyChanged(); + } + } + } - public int ShowOnlyMostUsedCMDsNumber { get; set; } + private int _showOnlyMostUsedCMDsNumber; + public int ShowOnlyMostUsedCMDsNumber + { + get => _showOnlyMostUsedCMDsNumber; + set + { + if (_showOnlyMostUsedCMDsNumber != value) + { + _showOnlyMostUsedCMDsNumber = value; + OnPropertyChanged(); + } + } + } public Dictionary CommandHistory { get; set; } = []; @@ -31,11 +128,19 @@ namespace Flow.Launcher.Plugin.Shell } } + [EnumLocalize] public enum Shell { + [EnumLocalizeValue("CMD")] Cmd = 0, + + [EnumLocalizeValue("PowerShell")] Powershell = 1, + + [EnumLocalizeValue("RunCommand")] RunCommand = 2, + + [EnumLocalizeValue("Pwsh")] Pwsh = 3, } }