mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-02-23 19:49:43 +01:00
CmdPal: Add a setting to retain search when going home
This allows CmdPal to retain the last thing typed when you go back to the home page after running a command. This affects anything that returns a `GoHome` or a `Dismiss`. Closes #39929 Closes #44826 It does not retain the last ran thing as like, the top result. It's too wacky to try to persist that `ICommand` and bring it to the top-level.
This commit is contained in:
@@ -66,6 +66,8 @@ public partial class SettingsModel : ObservableObject
|
||||
|
||||
public EscapeKeyBehavior EscapeKeyBehaviorSetting { get; set; } = EscapeKeyBehavior.ClearSearchFirstThenGoBack;
|
||||
|
||||
public bool ClearSearchOnGoHome { get; set; } = true;
|
||||
|
||||
public UserTheme Theme { get; set; } = UserTheme.Default;
|
||||
|
||||
public ColorizationMode ColorizationMode { get; set; }
|
||||
|
||||
@@ -144,6 +144,16 @@ public partial class SettingsViewModel : INotifyPropertyChanged
|
||||
}
|
||||
}
|
||||
|
||||
public bool ClearSearchOnGoHome
|
||||
{
|
||||
get => _settings.ClearSearchOnGoHome;
|
||||
set
|
||||
{
|
||||
_settings.ClearSearchOnGoHome = value;
|
||||
Save();
|
||||
}
|
||||
}
|
||||
|
||||
public int AutoGoBackIntervalIndex
|
||||
{
|
||||
get
|
||||
|
||||
@@ -421,7 +421,13 @@ public sealed partial class SearchBar : UserControl,
|
||||
}
|
||||
}
|
||||
|
||||
public void Receive(GoHomeMessage message) => ClearSearch();
|
||||
public void Receive(GoHomeMessage message)
|
||||
{
|
||||
if (Settings.ClearSearchOnGoHome)
|
||||
{
|
||||
ClearSearch();
|
||||
}
|
||||
}
|
||||
|
||||
public void Receive(FocusSearchBoxMessage message) => FilterBox.Focus(Microsoft.UI.Xaml.FocusState.Programmatic);
|
||||
|
||||
|
||||
@@ -290,6 +290,10 @@
|
||||
<controls:SettingsCard x:Uid="Settings_GeneralPage_DisableAnimations_SettingsCard" HeaderIcon="{ui:FontIcon Glyph=}">
|
||||
<ToggleSwitch IsOn="{x:Bind ViewModel.DisableAnimations, Mode=TwoWay}" />
|
||||
</controls:SettingsCard>
|
||||
|
||||
<controls:SettingsCard x:Uid="Settings_GeneralPage_ClearSearchOnGoHome_SettingsCard" HeaderIcon="{ui:FontIcon Glyph=}">
|
||||
<ToggleSwitch IsOn="{x:Bind ViewModel.ClearSearchOnGoHome, Mode=TwoWay}" />
|
||||
</controls:SettingsCard>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</ScrollViewer>
|
||||
|
||||
@@ -413,6 +413,12 @@ Right-click to remove the key combination, thereby deactivating the shortcut.</v
|
||||
<data name="Settings_GeneralPage_DisableAnimations_SettingsCard.Description" xml:space="preserve">
|
||||
<value>Disable animations when switching between pages</value>
|
||||
</data>
|
||||
<data name="Settings_GeneralPage_ClearSearchOnGoHome_SettingsCard.Header" xml:space="preserve">
|
||||
<value>Clear search on go home</value>
|
||||
</data>
|
||||
<data name="Settings_GeneralPage_ClearSearchOnGoHome_SettingsCard.Description" xml:space="preserve">
|
||||
<value>Clear the search box when navigating back to the home page</value>
|
||||
</data>
|
||||
<data name="BackButton.[using:Microsoft.UI.Xaml.Automation]AutomationProperties.Name" xml:space="preserve">
|
||||
<value>Back</value>
|
||||
</data>
|
||||
|
||||
Reference in New Issue
Block a user