mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Merge pull request #3538 from Flow-Launcher/results_context_menu_display
Fix results context menu display issue
This commit is contained in:
commit
86a3b0b3b0
3 changed files with 24 additions and 7 deletions
|
|
@ -479,7 +479,8 @@ public partial class SettingsPaneThemeViewModel : BaseModel
|
|||
)
|
||||
}
|
||||
};
|
||||
var vm = new ResultsViewModel(Settings);
|
||||
// Set main view model to null because the results are for preview only
|
||||
var vm = new ResultsViewModel(Settings, null);
|
||||
vm.AddResults(results, "PREVIEW");
|
||||
PreviewResults = vm;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -148,19 +148,19 @@ namespace Flow.Launcher.ViewModel
|
|||
_userSelectedRecord = _userSelectedRecordStorage.Load();
|
||||
_topMostRecord = _topMostRecordStorage.Load();
|
||||
|
||||
ContextMenu = new ResultsViewModel(Settings)
|
||||
ContextMenu = new ResultsViewModel(Settings, this)
|
||||
{
|
||||
LeftClickResultCommand = OpenResultCommand,
|
||||
RightClickResultCommand = LoadContextMenuCommand,
|
||||
IsPreviewOn = Settings.AlwaysPreview
|
||||
};
|
||||
Results = new ResultsViewModel(Settings)
|
||||
Results = new ResultsViewModel(Settings, this)
|
||||
{
|
||||
LeftClickResultCommand = OpenResultCommand,
|
||||
RightClickResultCommand = LoadContextMenuCommand,
|
||||
IsPreviewOn = Settings.AlwaysPreview
|
||||
};
|
||||
History = new ResultsViewModel(Settings)
|
||||
History = new ResultsViewModel(Settings, this)
|
||||
{
|
||||
LeftClickResultCommand = OpenResultCommand,
|
||||
RightClickResultCommand = LoadContextMenuCommand,
|
||||
|
|
@ -1662,6 +1662,12 @@ namespace Flow.Launcher.ViewModel
|
|||
return selected;
|
||||
}
|
||||
|
||||
internal bool ResultsSelected(ResultsViewModel results)
|
||||
{
|
||||
var selected = SelectedResults == results;
|
||||
return selected;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Hotkey
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ namespace Flow.Launcher.ViewModel
|
|||
|
||||
private readonly object _collectionLock = new();
|
||||
private readonly Settings _settings;
|
||||
private readonly MainViewModel _mainVM;
|
||||
private int MaxResults => _settings?.MaxResultsToShow ?? 6;
|
||||
|
||||
public ResultsViewModel()
|
||||
|
|
@ -29,9 +30,10 @@ namespace Flow.Launcher.ViewModel
|
|||
BindingOperations.EnableCollectionSynchronization(Results, _collectionLock);
|
||||
}
|
||||
|
||||
public ResultsViewModel(Settings settings) : this()
|
||||
public ResultsViewModel(Settings settings, MainViewModel mainVM) : this()
|
||||
{
|
||||
_settings = settings;
|
||||
_mainVM = mainVM;
|
||||
_settings.PropertyChanged += (s, e) =>
|
||||
{
|
||||
switch (e.PropertyName)
|
||||
|
|
@ -179,6 +181,7 @@ namespace Flow.Launcher.ViewModel
|
|||
|
||||
UpdateResults(newResults);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// To avoid deadlock, this method should not called from main thread
|
||||
/// </summary>
|
||||
|
|
@ -202,11 +205,18 @@ namespace Flow.Launcher.ViewModel
|
|||
SelectedItem = Results[0];
|
||||
}
|
||||
|
||||
if (token.IsCancellationRequested)
|
||||
return;
|
||||
|
||||
switch (Visibility)
|
||||
{
|
||||
case Visibility.Collapsed when Results.Count > 0:
|
||||
SelectedIndex = 0;
|
||||
Visibility = Visibility.Visible;
|
||||
if (_mainVM == null || // The results are for preview only in appearance page
|
||||
_mainVM.ResultsSelected(this)) // The results are selected
|
||||
{
|
||||
SelectedIndex = 0;
|
||||
Visibility = Visibility.Visible;
|
||||
}
|
||||
break;
|
||||
case Visibility.Visible when Results.Count == 0:
|
||||
Visibility = Visibility.Collapsed;
|
||||
|
|
|
|||
Loading…
Reference in a new issue