mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 18:57:19 +02:00
[PTRun] Fix always show after executing context menu result (#21291)
* fix always show * add tests * remove workaround
This commit is contained in:
committed by
GitHub
parent
a3042b8435
commit
460f242967
@@ -0,0 +1,11 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
namespace PowerLauncher.ViewModel
|
||||
{
|
||||
public interface IMainViewModel
|
||||
{
|
||||
void Hide();
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,7 @@ using Wox.Plugin.Logger;
|
||||
namespace PowerLauncher.ViewModel
|
||||
{
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1309:Use ordinal string comparison", Justification = "Using CurrentCultureIgnoreCase for user facing strings. Each usage is attributed with a comment.")]
|
||||
public class MainViewModel : BaseModel, ISavable, IDisposable
|
||||
public class MainViewModel : BaseModel, IMainViewModel, ISavable, IDisposable
|
||||
{
|
||||
private string _currentQuery;
|
||||
private static string _emptyQuery = string.Empty;
|
||||
@@ -75,9 +75,9 @@ namespace PowerLauncher.ViewModel
|
||||
_history = _historyItemsStorage.Load();
|
||||
_userSelectedRecord = _userSelectedRecordStorage.Load();
|
||||
|
||||
ContextMenu = new ResultsViewModel(_settings);
|
||||
Results = new ResultsViewModel(_settings);
|
||||
History = new ResultsViewModel(_settings);
|
||||
ContextMenu = new ResultsViewModel(_settings, this);
|
||||
Results = new ResultsViewModel(_settings, this);
|
||||
History = new ResultsViewModel(_settings, this);
|
||||
_selectedResults = Results;
|
||||
|
||||
InitializeKeyCommands();
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace PowerLauncher.ViewModel
|
||||
|
||||
public const int NoSelectionIndex = -1;
|
||||
|
||||
public ResultViewModel(Result result)
|
||||
public ResultViewModel(Result result, IMainViewModel mainViewModel)
|
||||
{
|
||||
if (result != null)
|
||||
{
|
||||
@@ -77,6 +77,7 @@ namespace PowerLauncher.ViewModel
|
||||
|
||||
ActivateContextButtonsHoverCommand = new RelayCommand(ActivateContextButtonsHoverAction);
|
||||
DeactivateContextButtonsHoverCommand = new RelayCommand(DeactivateContextButtonsHoverAction);
|
||||
MainViewModel = mainViewModel;
|
||||
}
|
||||
|
||||
private void ActivateContextButtonsHoverAction(object sender)
|
||||
@@ -159,8 +160,7 @@ namespace PowerLauncher.ViewModel
|
||||
|
||||
if (hideWindow)
|
||||
{
|
||||
// TODO - Do we hide the window
|
||||
// MainWindowVisibility = Visibility.Collapsed;
|
||||
MainViewModel.Hide();
|
||||
}
|
||||
})));
|
||||
}
|
||||
@@ -258,6 +258,8 @@ namespace PowerLauncher.ViewModel
|
||||
|
||||
public Result Result { get; }
|
||||
|
||||
public IMainViewModel MainViewModel { get; }
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
var r = obj as ResultViewModel;
|
||||
|
||||
@@ -21,6 +21,7 @@ namespace PowerLauncher.ViewModel
|
||||
private readonly object _collectionLock = new object();
|
||||
|
||||
private readonly PowerToysRunSettings _settings;
|
||||
private readonly IMainViewModel _mainViewModel;
|
||||
|
||||
public ResultsViewModel()
|
||||
{
|
||||
@@ -28,10 +29,11 @@ namespace PowerLauncher.ViewModel
|
||||
BindingOperations.EnableCollectionSynchronization(Results, _collectionLock);
|
||||
}
|
||||
|
||||
public ResultsViewModel(PowerToysRunSettings settings)
|
||||
public ResultsViewModel(PowerToysRunSettings settings, IMainViewModel mainViewModel)
|
||||
: this()
|
||||
{
|
||||
_settings = settings ?? throw new ArgumentNullException(nameof(settings));
|
||||
_mainViewModel = mainViewModel;
|
||||
_settings.PropertyChanged += (s, e) =>
|
||||
{
|
||||
if (e.PropertyName == nameof(_settings.MaxResultsToShow))
|
||||
@@ -246,7 +248,7 @@ namespace PowerLauncher.ViewModel
|
||||
List<ResultViewModel> newResults = new List<ResultViewModel>(newRawResults.Count);
|
||||
foreach (Result r in newRawResults)
|
||||
{
|
||||
newResults.Add(new ResultViewModel(r));
|
||||
newResults.Add(new ResultViewModel(r, _mainViewModel));
|
||||
ct.ThrowIfCancellationRequested();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user