diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 7db49bd79..93c6388b9 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -99,6 +99,15 @@ namespace Flow.Launcher.ViewModel }; _selectedResults = Results; + Results.PropertyChanged += (_, args) => + { + switch (args.PropertyName) + { + case nameof(Results.SelectedItem): + UpdatePreview(); + break; + } + }; RegisterViewUpdate(); RegisterResultsUpdatedEvent(); @@ -441,6 +450,7 @@ namespace Flow.Launcher.ViewModel { ResultAreaColumn = 1; PreviewVisible = true; + Results.SelectedItem?.LoadPreviewImage(); } private void HidePreview() @@ -461,6 +471,14 @@ namespace Flow.Launcher.ViewModel } } + private void UpdatePreview() + { + if (PreviewVisible) + { + Results.SelectedItem?.LoadPreviewImage(); + } + } + /// /// we need move cursor to end when we manually changed query /// but we don't want to move cursor to end when query is updated from TextBox diff --git a/Flow.Launcher/ViewModel/ResultViewModel.cs b/Flow.Launcher/ViewModel/ResultViewModel.cs index 0fadeccdf..aef336b1f 100644 --- a/Flow.Launcher/ViewModel/ResultViewModel.cs +++ b/Flow.Launcher/ViewModel/ResultViewModel.cs @@ -90,6 +90,14 @@ namespace Flow.Launcher.ViewModel } } + public bool UsePreviewImage + { + //todo binding + get => !ImgIconAvailable && !GlyphAvailable || + Settings.UseGlyphIcons && !GlyphAvailable && ImgIconAvailable || + !Settings.UseGlyphIcons && ImgIconAvailable; + } + public double IconRadius { get @@ -153,16 +161,7 @@ namespace Flow.Launcher.ViewModel public ImageSource PreviewImage { - get - { - if (!PreviewImageLoaded) - { - PreviewImageLoaded = true; - _ = LoadPreviewImageAsync(); - } - - return previewImage; - } + get => previewImage; private set => previewImage = value; } @@ -223,6 +222,15 @@ namespace Flow.Launcher.ViewModel } } + public void LoadPreviewImage() + { + if (!PreviewImageLoaded && UsePreviewImage) + { + PreviewImageLoaded = true; + _ = LoadPreviewImageAsync(); + } + } + public Result Result { get; } public int ResultProgress {