mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Add glyph icon support for results
- Add Glyph and GlyphAvailable properties to ResultViewModel - Set Glyph from plugin Result when creating result items - Add resultGlyph style matching icon size (32x32) - Update ResultListBox to show glyph or image icon based on ShowGlyph property - ShowGlyph = true when UseGlyphIcons is enabled AND glyph is available
This commit is contained in:
parent
c68a03e193
commit
ed668f3716
4 changed files with 48 additions and 7 deletions
|
|
@ -148,6 +148,17 @@
|
|||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
</Style>
|
||||
|
||||
<!-- Result Glyph -->
|
||||
<Style Selector="TextBlock.resultGlyph">
|
||||
<Setter Property="Width" Value="32" />
|
||||
<Setter Property="Height" Value="32" />
|
||||
<Setter Property="Margin" Value="12,0,0,0" />
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
<Setter Property="HorizontalAlignment" Value="Center" />
|
||||
<Setter Property="TextAlignment" Value="Center" />
|
||||
<Setter Property="FontSize" Value="20" />
|
||||
</Style>
|
||||
|
||||
<!-- Result Title -->
|
||||
<Style Selector="TextBlock.resultTitle">
|
||||
<Setter Property="Foreground" Value="#FFFFF8" />
|
||||
|
|
|
|||
|
|
@ -265,7 +265,8 @@ public partial class MainViewModel : ObservableObject
|
|||
SubTitle = r.SubTitle ?? "",
|
||||
IconPath = r.IcoPath ?? plugin.Metadata.IcoPath ?? "",
|
||||
Score = r.Score,
|
||||
PluginResult = r
|
||||
PluginResult = r,
|
||||
Glyph = r.Glyph
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -340,7 +341,8 @@ public partial class MainViewModel : ObservableObject
|
|||
SubTitle = r.SubTitle ?? "",
|
||||
IconPath = r.IcoPath ?? "",
|
||||
Score = r.Score,
|
||||
PluginResult = r
|
||||
PluginResult = r,
|
||||
Glyph = r.Glyph
|
||||
}).ToList();
|
||||
|
||||
ContextMenu.ReplaceResults(contextMenuItems);
|
||||
|
|
|
|||
|
|
@ -53,4 +53,25 @@ public partial class ResultViewModel : ObservableObject
|
|||
/// Returns a cached task to avoid re-loading on every property access.
|
||||
/// </summary>
|
||||
public Task<IImage?> Image => _imageTask ??= ImageLoader.LoadAsync(IconPath);
|
||||
|
||||
// Glyph support
|
||||
private GlyphInfo? _glyph;
|
||||
|
||||
public GlyphInfo? Glyph
|
||||
{
|
||||
get => _glyph;
|
||||
set
|
||||
{
|
||||
if (SetProperty(ref _glyph, value))
|
||||
{
|
||||
OnPropertyChanged(nameof(GlyphAvailable));
|
||||
OnPropertyChanged(nameof(ShowGlyph));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool GlyphAvailable => Glyph != null;
|
||||
|
||||
public bool ShowGlyph =>
|
||||
Settings?.UseGlyphIcons == true && GlyphAvailable;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
mc:Ignorable="d" d:DesignWidth="580" d:DesignHeight="300"
|
||||
x:Class="Flow.Launcher.Avalonia.Views.ResultListBox"
|
||||
x:DataType="vm:ResultsViewModel">
|
||||
|
||||
|
||||
<ListBox Name="ResultsList"
|
||||
Classes="resultListBox"
|
||||
ItemsSource="{Binding Results}"
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
SelectionMode="Single"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Auto">
|
||||
|
||||
|
||||
<!-- Enable virtualization for better performance -->
|
||||
<ListBox.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
|
|
@ -37,13 +37,20 @@
|
|||
<!-- Icon and Text -->
|
||||
<Grid Grid.Column="1" ColumnDefinitions="Auto,*" Margin="6,0,0,0">
|
||||
|
||||
<!-- Icon (async loaded via ^ stream operator) -->
|
||||
<!-- Glyph Icon (shown when UseGlyphIcons is enabled and glyph is available) -->
|
||||
<TextBlock Grid.Column="0"
|
||||
Classes="resultGlyph"
|
||||
Text="{Binding Glyph.Glyph}"
|
||||
IsVisible="{Binding ShowGlyph}"
|
||||
FontFamily="{Binding Glyph.FontFamily}" />
|
||||
|
||||
<!-- Image Icon (shown when no glyph or UseGlyphIcons is disabled) -->
|
||||
<Image Grid.Column="0"
|
||||
Classes="resultIcon"
|
||||
Source="{Binding Image^, FallbackValue={x:Static helper:ImageLoader.DefaultImage}}"
|
||||
IsVisible="{Binding ShowIcon}"
|
||||
IsVisible="{Binding !ShowGlyph}"
|
||||
RenderOptions.BitmapInterpolationMode="HighQuality" />
|
||||
|
||||
|
||||
<!-- Title and SubTitle -->
|
||||
<Grid Grid.Column="1"
|
||||
RowDefinitions="Auto,Auto"
|
||||
|
|
|
|||
Loading…
Reference in a new issue