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
This commit is contained in:
ShH Y 2024-11-08 23:36:43 +08:00
parent a9d77d8bcf
commit 77d2cd8dc1
5 changed files with 26 additions and 2 deletions

View file

@ -244,7 +244,8 @@
Style="{DynamicResource QueryBoxStyle}" Style="{DynamicResource QueryBoxStyle}"
Text="{Binding QueryText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Text="{Binding QueryText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Visibility="Visible" Visibility="Visible"
WindowChrome.IsHitTestVisibleInChrome="True"> WindowChrome.IsHitTestVisibleInChrome="True"
Loaded="SelectAllQueryText">
<TextBox.CommandBindings> <TextBox.CommandBindings>
<CommandBinding Command="ApplicationCommands.Copy" Executed="OnCopy" /> <CommandBinding Command="ApplicationCommands.Copy" Executed="OnCopy" />
</TextBox.CommandBindings> </TextBox.CommandBindings>

View file

@ -293,6 +293,11 @@ namespace Flow.Launcher
break; break;
} }
}; };
if (_settings.SelectAllQueryOnReopen)
{
SelectAllQueryText();
}
} }
private void InitializePosition() private void InitializePosition()
@ -852,5 +857,10 @@ namespace Flow.Launcher
be.UpdateSource(); be.UpdateSource();
} }
} }
private void SelectAllQueryText()
{
QueryTextBox.SelectAll();
}
} }
} }

View file

@ -25,6 +25,7 @@ public partial class SettingsPaneGeneralViewModel : BaseModel
_updater = updater; _updater = updater;
_portable = portable; _portable = portable;
UpdateEnumDropdownLocalizations(); UpdateEnumDropdownLocalizations();
SelectAllQueryOnReopen = settings.SelectAllQueryOnReopen; // Pfa33
} }
public class SearchWindowScreenData : DropdownDataGeneric<SearchWindowScreens> { } public class SearchWindowScreenData : DropdownDataGeneric<SearchWindowScreens> { }
@ -54,6 +55,11 @@ public partial class SettingsPaneGeneralViewModel : BaseModel
} }
} }
public bool SelectAllQueryOnReopen // Pbff7
{
get => Settings.SelectAllQueryOnReopen;
set => Settings.SelectAllQueryOnReopen = value;
}
public List<SearchWindowScreenData> SearchWindowScreens { get; } = public List<SearchWindowScreenData> SearchWindowScreens { get; } =
DropdownDataGeneric<SearchWindowScreens>.GetValues<SearchWindowScreenData>("SearchWindowScreen"); DropdownDataGeneric<SearchWindowScreens>.GetValues<SearchWindowScreenData>("SearchWindowScreen");

View file

@ -1,4 +1,4 @@
<Window <Window
x:Class="Flow.Launcher.SettingWindow" x:Class="Flow.Launcher.SettingWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

View file

@ -41,6 +41,13 @@ public partial class SettingWindow
hwndTarget.RenderMode = RenderMode.Default; hwndTarget.RenderMode = RenderMode.Default;
InitializePosition(); InitializePosition();
// Initialize the new checkbox based on the settings
var selectAllQueryOnReopenCheckbox = (System.Windows.Controls.CheckBox)FindName("SelectAllQueryOnReopenCheckbox");
if (selectAllQueryOnReopenCheckbox != null)
{
selectAllQueryOnReopenCheckbox.IsChecked = _settings.SelectAllQueryOnReopen;
}
} }
private void OnClosed(object sender, EventArgs e) private void OnClosed(object sender, EventArgs e)