feat(app): library, jobs, settings, server, welcome and about screens
Local-mode composition root (SQLite index, one JobEngine fed by a single handler registration list), keyset-paged library with thumbnail cache and hover scrub, live job list with throttled updates and the shell job bar, settings with live template validation and encoder self-test, server connection with trust-on-first-use and DPAPI token, first-run welcome, About with update check, and --capture screenshots with synthetic data. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
94 files changed
+10130
-374
No files matched your search
@@ -0,0 +1,179 @@
|
||||
using System.Windows.Media;
|
||||
using Titano.App.Infrastructure;
|
||||
using Titano.Core.Diagnostics;
|
||||
using Titano.Core.Localization;
|
||||
using Titano.Core.Model;
|
||||
using Titano.Core.Naming;
|
||||
using Titano.Ui.Controls;
|
||||
using Titano.Ui.Mvvm;
|
||||
using Titano.Ui.Visuals;
|
||||
|
||||
namespace Titano.App.Library;
|
||||
|
||||
/// <summary>One sequence of the Library grid and list (BRIEF §12.2).</summary>
|
||||
public sealed class SequenceItem : ObservableObject
|
||||
{
|
||||
private readonly ThumbnailService? _thumbnails;
|
||||
private Sequence _sequence;
|
||||
private ImageSource? _thumbnail;
|
||||
private IThumbnailSource? _scrub;
|
||||
private CancellationTokenSource? _loading;
|
||||
private int _requestedWidth;
|
||||
private bool _isSelected;
|
||||
private bool _isAnalysing;
|
||||
|
||||
public SequenceItem(Sequence sequence, ThumbnailService? thumbnails)
|
||||
{
|
||||
_sequence = sequence;
|
||||
_thumbnails = thumbnails;
|
||||
}
|
||||
|
||||
public Sequence Sequence => _sequence;
|
||||
public Guid Id => _sequence.Id;
|
||||
|
||||
/// <summary>User title or "{date} {camera}".</summary>
|
||||
public string Title => _sequence.DisplayTitle;
|
||||
|
||||
/// <summary>"Canon EOS R5" (brand not repeated).</summary>
|
||||
public string Camera => PathTemplate.CameraName(_sequence.CameraMake, _sequence.CameraModel);
|
||||
|
||||
/// <summary>Card line: count · camera · span.</summary>
|
||||
public string Subtitle => string.Join(" · ", new[] { FramesText, Camera, SpanText }.Where(s => s.Length > 0));
|
||||
|
||||
public string FramesText => Formatting.Count(_sequence.FrameCount);
|
||||
|
||||
/// <summary>First capture date (camera clock).</summary>
|
||||
public string DateText => _sequence.FirstCapture is { } first ? Formatting.Date(first) : string.Empty;
|
||||
|
||||
/// <summary>Time from first to last capture.</summary>
|
||||
public string SpanText => _sequence is { FirstCapture: { } a, LastCapture: { } b } && b > a ? Formatting.Duration(b - a) : string.Empty;
|
||||
|
||||
public string IntervalText => _sequence.MedianInterval is > 0 and var s ? Loc.L("Library.Interval", s.ToString(s < 10 ? "0.#" : "0", Loc.Culture)) : string.Empty;
|
||||
|
||||
public string SizeText => Formatting.Bytes(_sequence.TotalBytes);
|
||||
|
||||
public string TagsText => string.Join(", ", _sequence.Tags);
|
||||
|
||||
/// <summary>Status glyphs of the card and the list (DESIGN §4: glyph + word, never colour alone).</summary>
|
||||
public IReadOnlyList<CardStatus> Statuses => BuildStatuses(_sequence, _isAnalysing);
|
||||
|
||||
/// <summary>The single most relevant status for the list's State column.</summary>
|
||||
public CardStatus PrimaryStatus => Statuses.FirstOrDefault(s => s.Kind is StatusKind.Error or StatusKind.Warning or StatusKind.Analysing)
|
||||
?? Statuses[0];
|
||||
|
||||
public ImageSource? Thumbnail
|
||||
{
|
||||
get => _thumbnail;
|
||||
private set => Set(ref _thumbnail, value);
|
||||
}
|
||||
|
||||
/// <summary>Frames for hover scrubbing; created on first use.</summary>
|
||||
public IThumbnailSource? ScrubSource => _thumbnails is null || _sequence.FrameCount == 0 ? null : _scrub ??= _thumbnails.ScrubSource(_sequence);
|
||||
|
||||
public bool IsSelected
|
||||
{
|
||||
get => _isSelected;
|
||||
set => Set(ref _isSelected, value);
|
||||
}
|
||||
|
||||
/// <summary>An analysis job runs on this sequence ("◐ Analysing").</summary>
|
||||
public bool IsAnalysing
|
||||
{
|
||||
get => _isAnalysing;
|
||||
set
|
||||
{
|
||||
if (Set(ref _isAnalysing, value)) RaiseStatuses();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Replaces the row with a fresher copy of the same sequence.</summary>
|
||||
public void Update(Sequence sequence)
|
||||
{
|
||||
var heroChanged = sequence.HeroFrameId != _sequence.HeroFrameId || sequence.FrameCount != _sequence.FrameCount;
|
||||
_sequence = sequence;
|
||||
if (heroChanged)
|
||||
{
|
||||
_scrub = null;
|
||||
if (_requestedWidth > 0) RequestThumbnail(_requestedWidth, force: true);
|
||||
}
|
||||
OnAllPropertiesChanged();
|
||||
}
|
||||
|
||||
/// <summary>The card or row became visible: load the hero thumbnail (once per width).</summary>
|
||||
public void RequestThumbnail(int pixelWidth, bool force = false)
|
||||
{
|
||||
if (_thumbnails is null || pixelWidth <= 0) return;
|
||||
if (!force && _thumbnail is not null && pixelWidth <= _requestedWidth) return;
|
||||
if (!force && _loading is not null && pixelWidth <= _requestedWidth) return;
|
||||
_requestedWidth = pixelWidth;
|
||||
_loading?.Cancel();
|
||||
var cancellation = new CancellationTokenSource();
|
||||
_loading = cancellation;
|
||||
_ = LoadAsync(pixelWidth, cancellation);
|
||||
}
|
||||
|
||||
/// <summary>The card left the screen (recycled): stop its load.</summary>
|
||||
public void ReleaseThumbnail()
|
||||
{
|
||||
_loading?.Cancel();
|
||||
_loading = null;
|
||||
if (_thumbnail is null) _requestedWidth = 0;
|
||||
}
|
||||
|
||||
private async Task LoadAsync(int pixelWidth, CancellationTokenSource cancellation)
|
||||
{
|
||||
try
|
||||
{
|
||||
var image = await _thumbnails!.HeroAsync(_sequence, pixelWidth, cancellation.Token);
|
||||
if (!cancellation.IsCancellationRequested) Thumbnail = image;
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Warning("library", $"Thumbnail of {_sequence.Id} failed", ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (ReferenceEquals(_loading, cancellation)) _loading = null;
|
||||
cancellation.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
private void RaiseStatuses()
|
||||
{
|
||||
OnPropertyChanged(nameof(Statuses));
|
||||
OnPropertyChanged(nameof(PrimaryStatus));
|
||||
}
|
||||
|
||||
/// <summary>Card status row: analysed, proxies, renders, sync, warnings (Main.html).</summary>
|
||||
public static IReadOnlyList<CardStatus> BuildStatuses(Sequence s, bool analysing)
|
||||
{
|
||||
var list = new List<CardStatus>(5);
|
||||
if (analysing) list.Add(new CardStatus(StatusKind.Analysing, Loc.L("Library.Status.Analysing"), Loc.L("Tooltips.Library.Status.Analysing")));
|
||||
else if ((s.Status & SequenceStatus.AnalyzedLight) != 0) list.Add(new CardStatus(StatusKind.Analysed, Loc.L("Library.Status.Analysed"), Loc.L("Tooltips.Library.Status.Analysed")));
|
||||
else list.Add(new CardStatus(StatusKind.NotAnalysed, Loc.L("Library.Status.Analysed"), Loc.L("Tooltips.Library.Status.NotAnalysed")));
|
||||
|
||||
if (s.Origin == SequenceOrigin.Server && s.SyncState == SyncState.RemoteOnly)
|
||||
{
|
||||
list.Add(new CardStatus(StatusKind.Remote, Loc.L("Library.Status.Remote"), Loc.L("Tooltips.Library.Status.Remote")));
|
||||
}
|
||||
else
|
||||
{
|
||||
list.Add((s.Status & SequenceStatus.ProxiesBuilt) != 0
|
||||
? new CardStatus(StatusKind.Proxies, Loc.L("Library.Status.Proxies"), Loc.L("Tooltips.Library.Status.Proxies"))
|
||||
: new CardStatus(StatusKind.NoProxies, Loc.L("Library.Status.Proxies"), Loc.L("Tooltips.Library.Status.NoProxies")));
|
||||
}
|
||||
|
||||
if (s.RenderedCount > 0)
|
||||
list.Add(new CardStatus(StatusKind.Rendered, Formatting.Count(s.RenderedCount), Loc.Plural("Tooltips.Library.Status.Rendered", s.RenderedCount)));
|
||||
if (s.SyncState == SyncState.InSync)
|
||||
list.Add(new CardStatus(StatusKind.Synced, Loc.L("Library.Status.Synced"), Loc.L("Tooltips.Library.Status.Synced")));
|
||||
if ((s.Status & SequenceStatus.HasErrors) != 0)
|
||||
list.Add(new CardStatus(StatusKind.Error, Formatting.Count(Math.Max(1, s.WarningCount)), Loc.L("Tooltips.Library.Status.Errors")));
|
||||
else if (s.WarningCount > 0 || (s.Status & SequenceStatus.HasWarnings) != 0)
|
||||
list.Add(new CardStatus(StatusKind.Warning, Formatting.Count(Math.Max(1, s.WarningCount)), Loc.Plural("Tooltips.Library.Status.Warnings", Math.Max(1, s.WarningCount))));
|
||||
return list;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user