app: give the app one icon for the executable, windows and tray

Windows showed the default executable icon, and the tray drew a plain "T" at
run time. A usage gauge in the provider colours now serves all three (D8).
tools/icon/make_icon.py renders it with Pillow, a development-only
dependency, into a multi-size ICO for Windows and a PNG for X11. Its test
checks every size and that a fresh run reproduces the committed files.

Refs #17
This commit is contained in:
Florian Schmidt
2026-11-04 19:35:17 +01:00
parent be9951f9ef
commit 52b67a6d1b
10 changed files with 119 additions and 8 deletions
+15
View File
@@ -0,0 +1,15 @@
using Avalonia.Controls;
using Avalonia.Platform;
namespace FinalToken.App;
public static class AppIcon
{
// Keep the ICO's multiple sizes on Windows; X11 uses the same artwork as a PNG (D8).
public static WindowIcon Load()
{
var extension = OperatingSystem.IsWindows() ? "ico" : "png";
using var stream = AssetLoader.Open(new Uri($"avares://FinalToken/Assets/FinalToken.{extension}"));
return new WindowIcon(stream);
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

+1 -8
View File
@@ -1,9 +1,6 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Media;
using Avalonia.Media.Imaging;
using Avalonia.Themes.Fluent;
using Avalonia.Threading;
using FinalToken.Core;
using FinalToken.Core.StreamDeck;
@@ -75,11 +72,7 @@ public sealed class DesktopApp : Application
var menu = new NativeMenu();
foreach (var (label, action) in new (string, Action)[] { ("Open", OpenPanel), ("Refresh now", () => Run(Refresh)), ("Settings", OpenSettings), ("Quit", () => Run(Quit)) })
{ var item = new NativeMenuItem(label); item.Click += (_, _) => action(); menu.Items.Add(item); }
using var bitmap = new RenderTargetBitmap(new PixelSize(32, 32));
using (var context = bitmap.CreateDrawingContext())
{ context.DrawRectangle(Brush.Parse("#3878D4"), null, new Rect(0, 0, 32, 32), 7, 7); context.DrawLine(new Pen(Brushes.White, 4), new(9, 9), new(23, 9)); context.DrawLine(new Pen(Brushes.White, 4), new(16, 9), new(16, 25)); }
using var stream = new MemoryStream(); bitmap.Save(stream, PngBitmapEncoderOptions.Default); stream.Position = 0;
tray = new TrayIcon { Icon = new WindowIcon(stream), ToolTipText = "FinalToken", Menu = menu, IsVisible = true };
tray = new TrayIcon { Icon = AppIcon.Load(), ToolTipText = "FinalToken", Menu = menu, IsVisible = true };
tray.Clicked += (_, _) => OpenPanel();
TrayIcon.SetIcons(this, [tray]);
}
+2
View File
@@ -5,8 +5,10 @@
<PublishAot>true</PublishAot>
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<ApplicationIcon>Assets/FinalToken.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup><ProjectReference Include="../FinalToken.Core/FinalToken.Core.csproj" /></ItemGroup>
<ItemGroup><AvaloniaResource Include="Assets/*" /></ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia.Desktop" />
<PackageReference Include="Avalonia.Themes.Fluent" />
+1
View File
@@ -29,6 +29,7 @@ public sealed class PanelWindow : Window
{
this.model = model;
this.clock = clock ?? TimeProvider.System;
Icon = AppIcon.Load();
Title = $"FinalToken {typeof(Program).Assembly.GetName().Version?.ToString(3)}";
Width = 1280; Height = 900; MinWidth = 960; MinHeight = 500; Ui.Theme(this);
var brand = new StackPanel { Orientation = Orientation.Horizontal, Spacing = 8, VerticalAlignment = VerticalAlignment.Center };
+1
View File
@@ -10,6 +10,7 @@ public sealed class SettingsWindow : Window
{
public SettingsWindow(Settings initial, PluginInstallStatus status, Func<Settings, Task> save, Action? quit = null, Action<string>? openFolder = null)
{
Icon = AppIcon.Load();
Title = "FinalToken settings"; Width = 760; Height = 900; MinWidth = 600; MinHeight = 500; Ui.Theme(this);
var body = new StackPanel { Spacing = 16, Margin = new Thickness(24) };
body.Children.Add(Ui.Text("Settings", 24));