From dc3f663947287a9cee926b23991bccc3dc9cf6f1 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Sun, 16 Mar 2025 10:25:22 +0800 Subject: [PATCH] Use property changed to change --- Flow.Launcher.Infrastructure/UserSettings/Settings.cs | 11 ++++++++++- Flow.Launcher/MainWindow.xaml.cs | 5 ++++- .../ViewModels/SettingsPaneGeneralViewModel.cs | 11 ----------- .../SettingPages/Views/SettingsPaneGeneral.xaml | 2 +- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs index 97ee49ef2..df49630c5 100644 --- a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs +++ b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs @@ -275,7 +275,16 @@ namespace Flow.Launcher.Infrastructure.UserSettings public bool LeaveCmdOpen { get; set; } public bool HideWhenDeactivated { get; set; } = true; - public bool SearchQueryResultsWithDelay { get; set; } = false; + bool _searchQueryResultsWithDelay { get; set; } + public bool SearchQueryResultsWithDelay + { + get => _searchQueryResultsWithDelay; + set + { + _searchQueryResultsWithDelay = value; + OnPropertyChanged(); + } + } public int SearchInputDelay { get; set; } = 120; [JsonConverter(typeof(JsonStringEnumConverter))] diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index 9e7b380ed..a7dc8c1d1 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -297,6 +297,9 @@ namespace Flow.Launcher case nameof(Settings.WindowTop): Top = _settings.WindowTop; break; + case nameof(Settings.SearchQueryResultsWithDelay): + SetupSearchTextBoxReactiveness(_settings.SearchQueryResultsWithDelay); + break; } }; } @@ -865,7 +868,7 @@ namespace Flow.Launcher private IDisposable _reactiveSubscription; - public void SetupSearchTextBoxReactiveness(bool showResultsWithDelay) + private void SetupSearchTextBoxReactiveness(bool showResultsWithDelay) { if (_reactiveSubscription != null) { diff --git a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs index 72bdb609b..ced565bc2 100644 --- a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs +++ b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs @@ -139,17 +139,6 @@ public partial class SettingsPaneGeneralViewModel : BaseModel } } - public bool SearchQueryResultsWithDelay - { - get => Settings.SearchQueryResultsWithDelay; - set - { - Settings.SearchQueryResultsWithDelay = value; - - ((MainWindow)System.Windows.Application.Current.MainWindow).SetupSearchTextBoxReactiveness(value); - } - } - public IEnumerable SearchInputDelayRange => new List() { 30, 60, 90, 120, 150, 180, 210, 240, 270, 300 diff --git a/Flow.Launcher/SettingPages/Views/SettingsPaneGeneral.xaml b/Flow.Launcher/SettingPages/Views/SettingsPaneGeneral.xaml index 986e822e2..ffb58d094 100644 --- a/Flow.Launcher/SettingPages/Views/SettingsPaneGeneral.xaml +++ b/Flow.Launcher/SettingPages/Views/SettingsPaneGeneral.xaml @@ -178,7 +178,7 @@ Icon="" Sub="{DynamicResource searchDelayToolTip}">