Skip to content

Commit 5a7eb62

Browse files
Let result provider determine should use big thumbnail
1 parent 76f5c6c commit 5a7eb62

File tree

2 files changed

+26
-25
lines changed

2 files changed

+26
-25
lines changed

Flow.Launcher.Plugin/Result.cs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,14 @@ public string IcoPath
8282
public bool RoundedIcon { get; set; } = false;
8383

8484
/// <summary>
85-
/// Full image used for preview window
85+
/// Full image used for preview panel
8686
/// </summary>
87-
public string PreviewImage { get; set; }
87+
public string PreviewImage { get; set; } = null;
88+
89+
/// <summary>
90+
/// Determines if the preview image should occupy the full width of the preveiw panel.
91+
/// </summary>
92+
public bool UseBigThumbnail { get; set; } = false;
8893

8994
/// <summary>
9095
/// Delegate function, see <see cref="Icon"/>
@@ -234,5 +239,23 @@ public ValueTask<bool> ExecuteAsync(ActionContext context)
234239
/// </summary>
235240
/// <default>#26a0da (blue)</default>
236241
public string ProgressBarColor { get; set; } = "#26a0da";
242+
243+
/// <summary>
244+
/// Suggests a result's file extension should use full width of the default preview panel.
245+
/// </summary>
246+
/// <param name="extension">File extension. Dot included.</param>
247+
public static bool ShouldUseBigThumbnail(string extension)
248+
{
249+
return extension is ".jpg"
250+
or ".png"
251+
or ".avi"
252+
or ".mkv"
253+
or ".bmp"
254+
or ".gif"
255+
or ".wmv"
256+
or ".mp3"
257+
or ".flac"
258+
or ".mp4";
259+
}
237260
}
238261
}

Flow.Launcher/ViewModel/ResultViewModel.cs

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
using System.IO;
1010
using System.Drawing.Text;
1111
using System.Collections.Generic;
12-
using System.Drawing;
1312

1413
namespace Flow.Launcher.ViewModel
1514
{
@@ -28,13 +27,6 @@ public ResultViewModel(Result result, Settings settings)
2827
}
2928
Result = result;
3029

31-
var extension = Path.GetExtension(result.PreviewImage);
32-
if (!string.IsNullOrEmpty(extension))
33-
{
34-
// only when explicitly specified PreviewImage
35-
UseBigThumbnail = IsMedia(extension.ToLowerInvariant());
36-
}
37-
3830
if (Result.Glyph is { FontFamily: not null } glyph)
3931
{
4032
// Checks if it's a system installed font, which does not require path to be provided.
@@ -177,21 +169,7 @@ public ImageSource PreviewImage
177169
/// <summary>
178170
/// Determines if to use the full width of the preview panel
179171
/// </summary>
180-
public bool UseBigThumbnail { get; set; } = false;
181-
182-
public static bool IsMedia(string extension)
183-
{
184-
return extension is ".jpg"
185-
or ".png"
186-
or ".avi"
187-
or ".mkv"
188-
or ".bmp"
189-
or ".gif"
190-
or ".wmv"
191-
or ".mp3"
192-
or ".flac"
193-
or ".mp4";
194-
}
172+
public bool UseBigThumbnail => Result.UseBigThumbnail;
195173

196174
public GlyphInfo Glyph { get; set; }
197175

0 commit comments

Comments
 (0)