Skip to content

Commit 617d2f5

Browse files
Use separate variable for preview image
1 parent 95aaa9f commit 617d2f5

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

Flow.Launcher/MainWindow.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@
438438
HorizontalAlignment="Center"
439439
Source="{Binding PreviewImage}"
440440
StretchDirection="DownOnly"
441-
Visibility="{Binding ShowIcon}">
441+
Visibility="{Binding ShowPreviewImage, Converter={StaticResource BoolToVisibilityConverter}}">
442442
<Image.Style>
443443
<Style TargetType="{x:Type Image}">
444444
<Setter Property="MaxWidth" Value="96" />

Flow.Launcher/ViewModel/ResultViewModel.cs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,30 @@ public Visibility ShowIcon
9090
}
9191
}
9292

93+
public bool ShowPreviewImage
94+
{
95+
get
96+
{
97+
if (!string.IsNullOrEmpty(Result.Preview.PreviewImagePath) || Result.Preview.PreviewDelegate != null)
98+
{
99+
return true;
100+
}
101+
else
102+
{
103+
// Fall back to Icon
104+
if (!ImgIconAvailable && !GlyphAvailable)
105+
return true;
106+
107+
// Although user can choose to use glyph icons, plugins may choose to supply only image icons.
108+
// In this case we ignore the setting because otherwise icons will not display as intended
109+
if (Settings.UseGlyphIcons && !GlyphAvailable && ImgIconAvailable)
110+
return true;
111+
112+
return !Settings.UseGlyphIcons && ImgIconAvailable;
113+
}
114+
}
115+
}
116+
93117
public double IconRadius
94118
{
95119
get
@@ -120,6 +144,8 @@ public Visibility ShowGlyph
120144

121145
private bool ImgIconAvailable => !string.IsNullOrEmpty(Result.IcoPath) || Result.Icon is not null;
122146

147+
private bool PreviewImageAvailable => !string.IsNullOrEmpty(Result.Preview.PreviewImagePath) || Result.Preview.PreviewDelegate != null;
148+
123149
public string OpenResultModifiers => Settings.OpenResultModifiers;
124150

125151
public string ShowTitleToolTip => string.IsNullOrEmpty(Result.TitleToolTip)
@@ -218,7 +244,7 @@ public void LoadPreviewImage()
218244
{
219245
if (ShowDefaultPreview == Visibility.Visible)
220246
{
221-
if (!PreviewImageLoaded && ShowIcon == Visibility.Visible)
247+
if (!PreviewImageLoaded && ShowPreviewImage)
222248
{
223249
PreviewImageLoaded = true;
224250
_ = LoadPreviewImageAsync();

0 commit comments

Comments
 (0)