Skip to content

Commit

Permalink
Add setting to select all query text on window reopen
Browse files Browse the repository at this point in the history
* **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
  • Loading branch information
1208nn committed Jan 11, 2025
1 parent a9d77d8 commit 77d2cd8
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Flow.Launcher/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,8 @@
Style="{DynamicResource QueryBoxStyle}"
Text="{Binding QueryText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Visibility="Visible"
WindowChrome.IsHitTestVisibleInChrome="True">
WindowChrome.IsHitTestVisibleInChrome="True"
Loaded="SelectAllQueryText">
<TextBox.CommandBindings>
<CommandBinding Command="ApplicationCommands.Copy" Executed="OnCopy" />
</TextBox.CommandBindings>
Expand Down
10 changes: 10 additions & 0 deletions Flow.Launcher/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,11 @@ private void OnLoaded(object sender, RoutedEventArgs _)
break;
}
};

if (_settings.SelectAllQueryOnReopen)
{
SelectAllQueryText();
}
}

private void InitializePosition()
Expand Down Expand Up @@ -852,5 +857,10 @@ private void QueryTextBox_KeyUp(object sender, KeyEventArgs e)
be.UpdateSource();
}
}

private void SelectAllQueryText()
{
QueryTextBox.SelectAll();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public SettingsPaneGeneralViewModel(Settings settings, Updater updater, IPortabl
_updater = updater;
_portable = portable;
UpdateEnumDropdownLocalizations();
SelectAllQueryOnReopen = settings.SelectAllQueryOnReopen; // Pfa33
}

public class SearchWindowScreenData : DropdownDataGeneric<SearchWindowScreens> { }
Expand Down Expand Up @@ -54,6 +55,11 @@ public bool StartFlowLauncherOnSystemStartup
}
}

public bool SelectAllQueryOnReopen // Pbff7
{
get => Settings.SelectAllQueryOnReopen;
set => Settings.SelectAllQueryOnReopen = value;
}

public List<SearchWindowScreenData> SearchWindowScreens { get; } =
DropdownDataGeneric<SearchWindowScreens>.GetValues<SearchWindowScreenData>("SearchWindowScreen");
Expand Down
2 changes: 1 addition & 1 deletion Flow.Launcher/SettingWindow.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Window
<Window
x:Class="Flow.Launcher.SettingWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Expand Down
7 changes: 7 additions & 0 deletions Flow.Launcher/SettingWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ private void OnLoaded(object sender, RoutedEventArgs e)
hwndTarget.RenderMode = RenderMode.Default;

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)
Expand Down

0 comments on commit 77d2cd8

Please sign in to comment.