Skip to content

Commit 77d2cd8

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 a9d77d8 commit 77d2cd8

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
@@ -293,6 +293,11 @@ private void OnLoaded(object sender, RoutedEventArgs _)
293293
break;
294294
}
295295
};
296+
297+
if (_settings.SelectAllQueryOnReopen)
298+
{
299+
SelectAllQueryText();
300+
}
296301
}
297302

298303
private void InitializePosition()
@@ -852,5 +857,10 @@ private void QueryTextBox_KeyUp(object sender, KeyEventArgs e)
852857
be.UpdateSource();
853858
}
854859
}
860+
861+
private void SelectAllQueryText()
862+
{
863+
QueryTextBox.SelectAll();
864+
}
855865
}
856866
}

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
@@ -41,6 +41,13 @@ private void OnLoaded(object sender, RoutedEventArgs e)
4141
hwndTarget.RenderMode = RenderMode.Default;
4242

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

4653
private void OnClosed(object sender, EventArgs e)

0 commit comments

Comments
 (0)