From 77d2cd8dc112ce775cb2734a69dc35e63b643bb1 Mon Sep 17 00:00:00 2001 From: ShH Y <74806550+1208nn@users.noreply.github.com> Date: Fri, 8 Nov 2024 23:36:43 +0800 Subject: [PATCH] Add setting to select all query text on window reopen * **SettingsPaneGeneralViewModel.cs** - Add `SelectAllQueryOnReopen` property - Bind the new property to the settings in the constructor * **MainWindow.xaml.cs** - Update `OnLoaded` method to select all query text if the new setting is enabled - Add `SelectAllQueryText` method to handle selecting all query text * **MainWindow.xaml** - Bind `QueryTextBox` to the new setting to select all query text when the window is reopened * **SettingWindow.xaml.cs** - Initialize the new checkbox based on the settings --- Flow.Launcher/MainWindow.xaml | 3 ++- Flow.Launcher/MainWindow.xaml.cs | 10 ++++++++++ .../ViewModels/SettingsPaneGeneralViewModel.cs | 6 ++++++ Flow.Launcher/SettingWindow.xaml | 2 +- Flow.Launcher/SettingWindow.xaml.cs | 7 +++++++ 5 files changed, 26 insertions(+), 2 deletions(-) diff --git a/Flow.Launcher/MainWindow.xaml b/Flow.Launcher/MainWindow.xaml index f5fd729d45b..2a5b7057953 100644 --- a/Flow.Launcher/MainWindow.xaml +++ b/Flow.Launcher/MainWindow.xaml @@ -244,7 +244,8 @@ Style="{DynamicResource QueryBoxStyle}" Text="{Binding QueryText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Visibility="Visible" - WindowChrome.IsHitTestVisibleInChrome="True"> + WindowChrome.IsHitTestVisibleInChrome="True" + Loaded="SelectAllQueryText"> diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index 8ca153afc34..51ac56c77c3 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -293,6 +293,11 @@ private void OnLoaded(object sender, RoutedEventArgs _) break; } }; + + if (_settings.SelectAllQueryOnReopen) + { + SelectAllQueryText(); + } } private void InitializePosition() @@ -852,5 +857,10 @@ private void QueryTextBox_KeyUp(object sender, KeyEventArgs e) be.UpdateSource(); } } + + private void SelectAllQueryText() + { + QueryTextBox.SelectAll(); + } } } diff --git a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs index 3d94355e687..39a6ff3a005 100644 --- a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs +++ b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs @@ -25,6 +25,7 @@ public SettingsPaneGeneralViewModel(Settings settings, Updater updater, IPortabl _updater = updater; _portable = portable; UpdateEnumDropdownLocalizations(); + SelectAllQueryOnReopen = settings.SelectAllQueryOnReopen; // Pfa33 } public class SearchWindowScreenData : DropdownDataGeneric { } @@ -54,6 +55,11 @@ public bool StartFlowLauncherOnSystemStartup } } + public bool SelectAllQueryOnReopen // Pbff7 + { + get => Settings.SelectAllQueryOnReopen; + set => Settings.SelectAllQueryOnReopen = value; + } public List SearchWindowScreens { get; } = DropdownDataGeneric.GetValues("SearchWindowScreen"); diff --git a/Flow.Launcher/SettingWindow.xaml b/Flow.Launcher/SettingWindow.xaml index a81d9e0d108..abbf18c8930 100644 --- a/Flow.Launcher/SettingWindow.xaml +++ b/Flow.Launcher/SettingWindow.xaml @@ -1,4 +1,4 @@ -