mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 02:36:19 +02:00
[PowerToys Run] Implemented Setting to Clear Search Query when PowerToys Run is Launched (#4995)
* Implemented Clear Input On Launch * Move logic to seperate command on viewmodel * Added Settings Sync Moved logic from OnDeactivated to OnActivated * Complete after testing Co-authored-by: Roy <royvou@hotmailcom>
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
Closing="OnClosing"
|
||||
Background="Transparent"
|
||||
LocationChanged="OnLocationChanged"
|
||||
Activated="OnActivated"
|
||||
Deactivated="OnDeactivated"
|
||||
IsVisibleChanged="OnVisibilityChanged"
|
||||
Visibility="{Binding MainWindowVisibility, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
|
||||
@@ -151,9 +151,17 @@ namespace PowerLauncher
|
||||
_settings.WindowLeft = Left;
|
||||
}
|
||||
|
||||
private void OnActivated(object sender, EventArgs e)
|
||||
{
|
||||
if (_settings.ClearInputOnLaunch)
|
||||
{
|
||||
_viewModel.ClearQueryCommand.Execute(null);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDeactivated(object sender, EventArgs e)
|
||||
{
|
||||
if (_settings.HideWhenDeactivated)
|
||||
if (_settings.HideWhenDeactivated)
|
||||
{
|
||||
//(this.FindResource("OutroStoryboard") as Storyboard).Begin();
|
||||
Hide();
|
||||
|
||||
@@ -65,6 +65,11 @@ namespace PowerLauncher
|
||||
{
|
||||
_settings.IgnoreHotkeysOnFullscreen = overloadSettings.properties.ignore_hotkeys_in_fullscreen;
|
||||
}
|
||||
|
||||
if (_settings.ClearInputOnLaunch != overloadSettings.properties.clear_input_on_launch)
|
||||
{
|
||||
_settings.ClearInputOnLaunch = overloadSettings.properties.clear_input_on_launch;
|
||||
}
|
||||
}
|
||||
// the settings application can hold a lock on the settings.json file which will result in a IOException.
|
||||
// This should be changed to properly synch with the settings app instead of retrying.
|
||||
|
||||
@@ -129,6 +129,8 @@ namespace Wox.Infrastructure.UserSettings
|
||||
}
|
||||
public bool LeaveCmdOpen { get; set; }
|
||||
public bool HideWhenDeactivated { get; set; } = true;
|
||||
public bool ClearInputOnLaunch { get; set; } = false;
|
||||
|
||||
public bool RememberLastLaunchLocation { get; set; }
|
||||
public bool IgnoreHotkeysOnFullscreen { get; set; }
|
||||
|
||||
|
||||
@@ -234,6 +234,16 @@ namespace Wox.ViewModel
|
||||
SelectedResults = Results;
|
||||
}
|
||||
});
|
||||
|
||||
ClearQueryCommand = new RelayCommand(_ =>
|
||||
{
|
||||
if(!string.IsNullOrEmpty(QueryText))
|
||||
{
|
||||
ChangeQueryText(string.Empty,true);
|
||||
//Push Event to UI SystemQuery has changed
|
||||
OnPropertyChanged(nameof(SystemQueryText));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -342,6 +352,8 @@ namespace Wox.ViewModel
|
||||
public ICommand LoadContextMenuCommand { get; set; }
|
||||
public ICommand LoadHistoryCommand { get; set; }
|
||||
public ICommand OpenResultCommand { get; set; }
|
||||
public ICommand ClearQueryCommand { get; set; }
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
Reference in New Issue
Block a user