Skip to content

Commit 57d781e

Browse files
committed
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
1 parent 50c00f3 commit 57d781e

File tree

5 files changed

+26
-2
lines changed

5 files changed

+26
-2
lines changed

Flow.Launcher/MainWindow.xaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,8 @@
244244
Style="{DynamicResource QueryBoxStyle}"
245245
Text="{Binding QueryText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
246246
Visibility="Visible"
247-
WindowChrome.IsHitTestVisibleInChrome="True">
247+
WindowChrome.IsHitTestVisibleInChrome="True"
248+
Loaded="SelectAllQueryText">
248249
<TextBox.CommandBindings>
249250
<CommandBinding Command="ApplicationCommands.Copy" Executed="OnCopy" />
250251
</TextBox.CommandBindings>

Flow.Launcher/MainWindow.xaml.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,11 @@ private void OnLoaded(object sender, RoutedEventArgs _)
298298
break;
299299
}
300300
};
301+
302+
if (_settings.SelectAllQueryOnReopen)
303+
{
304+
SelectAllQueryText();
305+
}
301306
}
302307

303308
private void InitializePosition()
@@ -857,5 +862,10 @@ private void QueryTextBox_KeyUp(object sender, KeyEventArgs e)
857862
be.UpdateSource();
858863
}
859864
}
865+
866+
private void SelectAllQueryText()
867+
{
868+
QueryTextBox.SelectAll();
869+
}
860870
}
861871
}

Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public SettingsPaneGeneralViewModel(Settings settings, Updater updater, IPortabl
2525
_updater = updater;
2626
_portable = portable;
2727
UpdateEnumDropdownLocalizations();
28+
SelectAllQueryOnReopen = settings.SelectAllQueryOnReopen; // Pfa33
2829
}
2930

3031
public class SearchWindowScreenData : DropdownDataGeneric<SearchWindowScreens> { }
@@ -54,6 +55,11 @@ public bool StartFlowLauncherOnSystemStartup
5455
}
5556
}
5657

58+
public bool SelectAllQueryOnReopen // Pbff7
59+
{
60+
get => Settings.SelectAllQueryOnReopen;
61+
set => Settings.SelectAllQueryOnReopen = value;
62+
}
5763

5864
public List<SearchWindowScreenData> SearchWindowScreens { get; } =
5965
DropdownDataGeneric<SearchWindowScreens>.GetValues<SearchWindowScreenData>("SearchWindowScreen");

Flow.Launcher/SettingWindow.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Window
1+
<Window
22
x:Class="Flow.Launcher.SettingWindow"
33
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
44
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

Flow.Launcher/SettingWindow.xaml.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ private void OnLoaded(object sender, RoutedEventArgs e)
4242
hwndTarget.RenderMode = RenderMode.Default;
4343

4444
InitializePosition();
45+
46+
// Initialize the new checkbox based on the settings
47+
var selectAllQueryOnReopenCheckbox = (System.Windows.Controls.CheckBox)FindName("SelectAllQueryOnReopenCheckbox");
48+
if (selectAllQueryOnReopenCheckbox != null)
49+
{
50+
selectAllQueryOnReopenCheckbox.IsChecked = _settings.SelectAllQueryOnReopen;
51+
}
4552
}
4653

4754
private void OnClosed(object sender, EventArgs e)

0 commit comments

Comments
 (0)