mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Only load preview when preview panel is open
This commit is contained in:
parent
7f0e735cb6
commit
2476e2d77d
2 changed files with 36 additions and 10 deletions
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue