Let result provider determine should use big thumbnail

This commit is contained in:
Vic 2022-11-29 12:59:13 +08:00
parent 76f5c6c5ab
commit 5a7eb621ab
2 changed files with 26 additions and 25 deletions

View file

@ -82,9 +82,14 @@ namespace Flow.Launcher.Plugin
public bool RoundedIcon { get; set; } = false;
/// <summary>
/// Full image used for preview window
/// Full image used for preview panel
/// </summary>
public string PreviewImage { get; set; }
public string PreviewImage { get; set; } = null;
/// <summary>
/// Determines if the preview image should occupy the full width of the preveiw panel.
/// </summary>
public bool UseBigThumbnail { get; set; } = false;
/// <summary>
/// Delegate function, see <see cref="Icon"/>
@ -234,5 +239,23 @@ namespace Flow.Launcher.Plugin
/// </summary>
/// <default>#26a0da (blue)</default>
public string ProgressBarColor { get; set; } = "#26a0da";
/// <summary>
/// Suggests a result's file extension should use full width of the default preview panel.
/// </summary>
/// <param name="extension">File extension. Dot included.</param>
public static bool ShouldUseBigThumbnail(string extension)
{
return extension is ".jpg"
or ".png"
or ".avi"
or ".mkv"
or ".bmp"
or ".gif"
or ".wmv"
or ".mp3"
or ".flac"
or ".mp4";
}
}
}

View file

@ -9,7 +9,6 @@ using Flow.Launcher.Plugin;
using System.IO;
using System.Drawing.Text;
using System.Collections.Generic;
using System.Drawing;
namespace Flow.Launcher.ViewModel
{
@ -28,13 +27,6 @@ namespace Flow.Launcher.ViewModel
}
Result = result;
var extension = Path.GetExtension(result.PreviewImage);
if (!string.IsNullOrEmpty(extension))
{
// only when explicitly specified PreviewImage
UseBigThumbnail = IsMedia(extension.ToLowerInvariant());
}
if (Result.Glyph is { FontFamily: not null } glyph)
{
// Checks if it's a system installed font, which does not require path to be provided.
@ -177,21 +169,7 @@ namespace Flow.Launcher.ViewModel
/// <summary>
/// Determines if to use the full width of the preview panel
/// </summary>
public bool UseBigThumbnail { get; set; } = false;
public static bool IsMedia(string extension)
{
return extension is ".jpg"
or ".png"
or ".avi"
or ".mkv"
or ".bmp"
or ".gif"
or ".wmv"
or ".mp3"
or ".flac"
or ".mp4";
}
public bool UseBigThumbnail => Result.UseBigThumbnail;
public GlyphInfo Glyph { get; set; }