Skip to content

Commit fd39b60

Browse files
committed
Add Glyph Support
1 parent 309ee29 commit fd39b60

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

Flow.Launcher.Plugin/Result.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,15 @@ public string IcoPath
4747

4848
public delegate ImageSource IconDelegate();
4949

50-
public IconDelegate Icon;
50+
/// <summary>
51+
/// Delegate to Get Image Source
52+
/// </summary>
53+
public IconDelegate Icon { get; set; }
54+
55+
/// <summary>
56+
/// Information for Glyph Icon
57+
/// </summary>
58+
public GlyphInfo Glyph { get; init; }
5159

5260

5361
/// <summary>

Flow.Launcher/ResultListBox.xaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@
4242
<ColumnDefinition Width="0" />
4343
</Grid.ColumnDefinitions>
4444
<Image x:Name="ImageIcon" Width="32" Height="32" HorizontalAlignment="Left"
45-
Source="{Binding Image.Value}" />
45+
Source="{Binding Image.Value}" Visibility="{Binding ShowImage}" />
46+
<TextBlock Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Center"
47+
Text="{Binding Glyph.Glyph}" FontFamily="{Binding Glyph.FontFamily}" FontSize="24"
48+
Visibility="{Binding ShowGlyph}"/>
4649
<Grid Margin="5 0 5 0" Grid.Column="1" HorizontalAlignment="Stretch">
4750
<Grid.RowDefinitions>
4851
<RowDefinition />

Flow.Launcher/ViewModel/ResultViewModel.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,18 @@ public ResultViewModel(Result result, Settings settings)
6666
{
6767
OnPropertyChanged(nameof(Image));
6868
});
69-
}
69+
70+
Glyph = Result.Glyph;
71+
}
7072

7173
Settings = settings;
7274
}
7375

7476
public Settings Settings { get; private set; }
7577

7678
public Visibility ShowOpenResultHotkey => Settings.ShowOpenResultHotkey ? Visibility.Visible : Visibility.Hidden;
77-
79+
public Visibility ShowIcon => Result.IcoPath != null || Result.Icon is not null || Glyph == null ? Visibility.Visible : Visibility.Hidden;
80+
public Visibility ShowGlyph => Glyph is not null ? Visibility.Visible : Visibility.Hidden;
7881
public string OpenResultModifiers => Settings.OpenResultModifiers;
7982

8083
public string ShowTitleToolTip => string.IsNullOrEmpty(Result.TitleToolTip)
@@ -87,6 +90,8 @@ public ResultViewModel(Result result, Settings settings)
8790

8891
public LazyAsync<ImageSource> Image { get; set; }
8992

93+
public GlyphInfo Glyph { get; set; }
94+
9095
private async ValueTask<ImageSource> SetImage()
9196
{
9297
var imagePath = Result.IcoPath;
@@ -106,7 +111,7 @@ private async ValueTask<ImageSource> SetImage()
106111
if (ImageLoader.CacheContainImage(imagePath))
107112
// will get here either when icoPath has value\icon delegate is null\when had exception in delegate
108113
return ImageLoader.Load(imagePath);
109-
114+
110115
return await Task.Run(() => ImageLoader.Load(imagePath));
111116
}
112117

0 commit comments

Comments
 (0)