feat: export panel and Render menu, playback options, videos library (owner review 1 phase 5) (#27)
CI / Build and test (push) Successful in 9m41s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 9s
Release / Build, test and publish (push) Successful in 14m49s
CI / PostgreSQL 16 integration (push) Successful in 8m51s
CI / PostgreSQL 17 integration (push) Successful in 9m48s
CI / Docker image (push) Successful in 54s
Release / Server image (push) Successful in 1m39s

Owner review 1 R3, R8, R9. A grouped Export step and Render menu; encoding, playback (reverse, boomerang, loops, fades, hold) and still frames; one videos library on the desktop and the server with a verified trash and copies to a videos folder.

Closes #21

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
This commit was merged in pull request #27.
This commit is contained in:
Alby96andClaude Opus 5.5 authored and Alby96 committed 2026-11-05 09:18:40 +01:00
1 parent 188b2c2e55
commit 728ffa35cb
729 files changed
+26954 -1652

No files matched your search

+275
View File
@@ -0,0 +1,275 @@
using System.Globalization;
using System.Windows.Media;
using Chronos.App.Archiving;
using Chronos.App.Infrastructure;
using Chronos.Core.Localization;
using Chronos.Core.Model;
using Chronos.Data.Videos;
using Chronos.Protocol;
using Chronos.Ui.Controls;
using Chronos.Ui.Mvvm;
using Chronos.Ui.Visuals;
namespace Chronos.App.Videos;
/// <summary>The words of the Videos section: kinds, states, details and the errors of the videos library.</summary>
public static class VideoText
{
/// <summary>"Videos", "Stills", "Image sequences"; a newer kind as it is.</summary>
public static string Kind(string kind) => kind switch
{
RenderKind.Video => Loc.L("Videos.Kind.Video"),
RenderKind.Still => Loc.L("Videos.Kind.Still"),
RenderKind.Sequence => Loc.L("Videos.Kind.Sequence"),
_ => kind,
};
/// <summary>"0:42" for a video; empty for a still, which has no duration.</summary>
public static string Duration(VideoEntry entry)
{
ArgumentNullException.ThrowIfNull(entry);
return entry.Kind == RenderKind.Still || entry.DurationSeconds <= 0 ? string.Empty : Formatting.Elapsed(TimeSpan.FromSeconds(entry.DurationSeconds));
}
/// <summary>"3840×2160 · HEVC" (the size and codec, left to right in every language).</summary>
public static string Format(VideoEntry entry)
{
ArgumentNullException.ThrowIfNull(entry);
var size = entry.Width > 0 && entry.Height > 0
? entry.Width.ToString(CultureInfo.InvariantCulture) + "×" + entry.Height.ToString(CultureInfo.InvariantCulture)
: string.Empty;
var codec = VideoSources.CodecText(entry.Codec);
return size.Length == 0 ? codec : codec.Length == 0 ? size : size + Loc.Separator + codec;
}
/// <summary>"3840×2160 · HEVC · 0:42 · 1.2 GB": the parts a render has (a still has no duration), joined by the separator.</summary>
public static string Details(VideoEntry entry)
{
ArgumentNullException.ThrowIfNull(entry);
return string.Join(Loc.Separator, new[] { Format(entry), Duration(entry), Formatting.Bytes(entry.Bytes) }.Where(p => p.Length > 0));
}
/// <summary>The state chips of a render: where its file is, whether it was copied, and a missing file.</summary>
public static IReadOnlyList<CardStatus> States(VideoEntry entry)
{
ArgumentNullException.ThrowIfNull(entry);
var states = new List<CardStatus>();
if (entry.Missing) states.Add(new CardStatus(StatusKind.Warning, Loc.L("Videos.State.Missing"), Loc.L("Tooltips.Videos.Missing")));
if (entry.IsUnsent) states.Add(new CardStatus(StatusKind.Queued, Loc.L("Videos.State.NotSent"), Loc.L("Tooltips.Videos.NotSent")));
else if (entry.IsLocal && entry.IsOnServer) states.Add(new CardStatus(StatusKind.Synced, Loc.L("Videos.State.HereAndServer"), Loc.L("Tooltips.Videos.HereAndServer")));
else if (entry.IsLocal) states.Add(new CardStatus(StatusKind.Done, Loc.L("Videos.State.Here"), Loc.L("Tooltips.Videos.Here")));
else if (entry.IsOnServer) states.Add(new CardStatus(StatusKind.Remote, Loc.L("Videos.State.OnServer"), Loc.L("Tooltips.Videos.OnServer")));
if (entry.Copies.Count > 0)
{
states.Add(new CardStatus(StatusKind.Rendered, Loc.L("Videos.State.Copied"),
Loc.L("Tooltips.Videos.Copied", string.Join(Environment.NewLine, entry.Copies.Select(Formatting.LeftToRight)))));
}
return states;
}
/// <summary>The sentence of a videos library error (<see cref="VideoErrors"/>); <paramref name="name"/> is the file or sequence it is about.</summary>
public static string Error(VideoLibraryException ex, string? name = null)
{
ArgumentNullException.ThrowIfNull(ex);
return ex.Code switch
{
VideoErrors.FolderUnset => Loc.L("Errors.Videos.FolderUnset"),
VideoErrors.FolderInvalid => Loc.L("Errors.Videos.FolderInsideArchive"),
VideoErrors.PlanChanged => Loc.L("Errors.Videos.Fingerprint"),
VideoErrors.HashMismatch => Loc.L("Errors.Videos.TrashMismatch"),
VideoErrors.NoSpace => Loc.L("Errors.Videos.NoSpace", name ?? string.Empty),
VideoErrors.SequenceGone => Loc.L("Errors.Videos.SequenceGone", name ?? string.Empty),
VideoErrors.Busy => Loc.L("Errors.Videos.Busy", name ?? string.Empty),
_ => ex.Message,
};
}
/// <summary>Why a copy into <paramref name="problem"/>'s folder is refused (a tooltip), from <see cref="VideosFolders.Problem"/>.</summary>
public static string FolderReason(string problem) =>
problem == VideoErrors.FolderUnset ? Loc.L("Tooltips.Videos.FolderUnset") : Loc.L("Errors.Videos.FolderInsideArchive");
/// <summary>
/// Play's tooltip for <paramref name="entry"/>: what Play does for a file on this PC; for a video only the server holds,
/// that it plays here once copied to this PC; for a file that is gone, that it is missing.
/// </summary>
public static string PlayToolTip(VideoEntry entry)
{
ArgumentNullException.ThrowIfNull(entry);
if (entry.HasLocalFile) return Loc.L("Tooltips.Videos.Play");
if (entry.Missing) return Loc.L("Tooltips.Videos.Missing");
return entry.IsOnServer ? Loc.L("Tooltips.Videos.PlayServer") : Loc.L("Tooltips.Videos.Play");
}
/// <summary>"In use by a job", "Not found".</summary>
public static string BlockReason(string reason) =>
reason == VideoBlockReasons.Busy ? Loc.L("Videos.Blocked.Busy") : Loc.L("Videos.Blocked.NotFound");
}
/// <summary>One render of the Videos section, as a card of the grid or a row of the list.</summary>
public sealed class VideoRowViewModel(VideoEntry entry) : ObservableObject
{
private bool _isSelected;
private ImageSource? _poster;
private bool _posterRequested;
public VideoEntry Entry { get; } = entry;
public string Title => Entry.Title;
/// <summary>The preset name (and the project's, when a project was rendered).</summary>
public string Subtitle => Entry.ProjectName is { Length: > 0 } project ? Entry.PresetName + Loc.Separator + project : Entry.PresetName;
public string DetailsText => VideoText.Details(Entry);
public string FormatText => VideoText.Format(Entry);
public string DurationText => VideoText.Duration(Entry);
public string SizeText => Formatting.Bytes(Entry.Bytes);
public string DateText => Formatting.Date(Entry.Created) + " " + Formatting.TimeOfDay(Entry.Created);
public string KindText => VideoText.Kind(Entry.Kind);
public IReadOnlyList<CardStatus> States { get; } = VideoText.States(entry);
/// <summary>The card's and the row's tooltip: what it is, then how to select it.</summary>
public string ToolTip => Entry.IsUnsent ? Loc.L("Tooltips.Videos.WorkspaceRow") : Loc.L("Tooltips.Videos.Select");
/// <summary>
/// Play's tooltip: what it does, or why it waits (a server's video plays here once it is copied to this PC, a file
/// that is gone plays nowhere).
/// </summary>
public string PlayToolTip => VideoText.PlayToolTip(Entry);
/// <summary>The section listing the row: its menu's words are those of the commands it runs, on what they act on.</summary>
internal Sections.VideosViewModel? Section { get; set; }
private IReadOnlyList<VideoRowViewModel> MenuTargets => Section?.TargetsOf(this) ?? [this];
/// <summary>The menu's Play tooltip: why it waits, else what it does.</summary>
public string MenuPlayToolTip => Sections.VideosViewModel.PlayToolTipOf(MenuTargets);
public string MenuShowInFolderToolTip => Sections.VideosViewModel.ShowInFolderToolTipOf(MenuTargets);
/// <summary>Copy to folder, or Download for the server's videos alone.</summary>
public string MenuCopyText => Sections.VideosViewModel.CopyTextOf(MenuTargets);
public string MenuCopyToolTip => Section?.CopyToolTipOf(MenuTargets) ?? Loc.L("Tooltips.Videos.Copy");
public string MenuCopyOnServerToolTip => Section?.CopyOnServerToolTipOf(MenuTargets) ?? Loc.L("Tooltips.Videos.CopyOnServer");
public string MenuOpenInEditToolTip => Sections.VideosViewModel.OpenInEditToolTipOf(MenuTargets);
public string MenuDeleteToolTip => Section?.DeleteToolTipOf(MenuTargets) ?? Loc.L("Tooltips.Videos.Delete");
/// <summary>The selection or the section's state changed: the menu's words are read again.</summary>
internal void RefreshMenu()
{
OnPropertyChanged(nameof(MenuPlayToolTip));
OnPropertyChanged(nameof(MenuShowInFolderToolTip));
OnPropertyChanged(nameof(MenuCopyText));
OnPropertyChanged(nameof(MenuCopyToolTip));
OnPropertyChanged(nameof(MenuCopyOnServerToolTip));
OnPropertyChanged(nameof(MenuOpenInEditToolTip));
OnPropertyChanged(nameof(MenuDeleteToolTip));
}
/// <summary>The file name, left to right in every language.</summary>
public string FileNameText => Formatting.LeftToRight(Entry.FileName);
public bool IsSelected
{
get => _isSelected;
set
{
if (Set(ref _isSelected, value)) SelectionChanged?.Invoke(this);
}
}
/// <summary>The sequence's cover, or the still itself; null until loaded (<see cref="RequestPoster"/>).</summary>
public ImageSource? Poster
{
get => _poster;
internal set => Set(ref _poster, value);
}
/// <summary>The card came on screen: its poster is loaded once by <see cref="PosterRequested"/>.</summary>
public void RequestPoster()
{
if (_posterRequested || _poster is not null) return;
_posterRequested = true;
PosterRequested?.Invoke(this);
}
internal event Action<VideoRowViewModel>? SelectionChanged;
internal event Action<VideoRowViewModel>? PosterRequested;
}
/// <summary>
/// The dry run of a delete of videos (decision 17) in the words of its confirmation: what goes into the trash (and how
/// many bytes), the renders whose file is missing (only their entry goes), the renders left where they are and why, and
/// that copies in the videos folder stay. This PC's renders and the server's are planned apart and confirmed together.
/// </summary>
/// <param name="Names">What the section shows of each selected render ("title · file"), which names a render that stays
/// (the server's plan gives only its id); a render not among them is named by its id.</param>
public sealed record VideoDeletePlans(VideoDeletePlan? Local, VideoDeletePlanDto? Server, IReadOnlyDictionary<Guid, string>? Names = null)
{
/// <summary>"Harbour sunset · harbour-4k.mp4": how a render that stays is named in the confirmation.</summary>
public static string NameOf(VideoEntry entry)
{
ArgumentNullException.ThrowIfNull(entry);
return entry.Title + Loc.Separator + Formatting.LeftToRight(entry.FileName);
}
/// <summary>The renders that go.</summary>
public int Count => (Local?.Items.Count ?? 0) + (Server?.Items.Count ?? 0);
/// <summary>The bytes that move into the trash.</summary>
public long Bytes => (Local?.Bytes ?? 0) + (Server?.Bytes ?? 0);
/// <summary>The renders left where they are.</summary>
public int Blocked => (Local?.Blocked.Count ?? 0) + (Server?.Blocked.Count ?? 0);
/// <summary>The renders whose file is missing: only their entry goes.</summary>
public int Missing => (Local?.Items.Count(i => i.Missing) ?? 0) + (Server?.Items.Count(i => i.Missing) ?? 0);
/// <summary>The lines of what goes, then of what stays and why (<see cref="DeletePlans.ListedLines"/> each, the rest counted).</summary>
public IReadOnlyList<string> Lines()
{
var goes = (Local?.Items.Select(i => (i.SequenceTitle, i.FileName, i.Render.Bytes, i.Missing)) ?? [])
.Concat(Server?.Items.Select(i => (i.SequenceTitle, FileName: i.FileName ?? string.Empty, i.Bytes, i.Missing)) ?? []).ToList();
var lines = new List<string>();
foreach (var (title, file, bytes, missing) in goes.Take(DeletePlans.ListedLines))
{
lines.Add(Loc.L("Archive.Delete.Line", title, Formatting.LeftToRight(file),
missing ? Loc.L("Videos.State.Missing") : Formatting.Bytes(bytes)));
}
if (goes.Count > DeletePlans.ListedLines) lines.Add(Loc.Plural("Archive.Delete.More", goes.Count - DeletePlans.ListedLines));
var stays = (Local?.Blocked.Select(b => (Named(b.RenderId, b.Video is { } video ? video.SequenceTitle + Loc.Separator + Formatting.LeftToRight(video.FileName) : null), b.Reason)) ?? [])
.Concat(Server?.Blocked.Select(b => (Named(b.Id, null), b.Reason)) ?? []).ToList();
if (stays.Count > 0) lines.Add(Loc.L("Videos.Delete.Blocked", Formatting.Count(stays.Count)));
foreach (var (name, reason) in stays.Take(DeletePlans.ListedLines)) lines.Add(name + Loc.Separator + VideoText.BlockReason(reason));
if (stays.Count > DeletePlans.ListedLines) lines.Add(Loc.Plural("Archive.Delete.More", stays.Count - DeletePlans.ListedLines));
return lines;
}
/// <summary>The render's name in the section, else <paramref name="fallback"/>, else its id.</summary>
private string Named(Guid id, string? fallback) => Names?.GetValueOrDefault(id) ?? fallback ?? id.ToString("D");
/// <summary>The confirmation of moving the planned renders into the trash; null when nothing would go.</summary>
public ConfirmRequest? Request()
{
if (Count == 0) return null;
var message = Loc.L("Videos.Delete.Summary", Formatting.Count(Count), Formatting.Bytes(Bytes)) + Environment.NewLine + Loc.L("Videos.Delete.CopiesStay");
if (Missing > 0) message += Environment.NewLine + Loc.L("Videos.Delete.Missing");
return new ConfirmRequest
{
Heading = Loc.L("Videos.Delete.Title"),
Message = message,
Detail = string.Join(Environment.NewLine, Lines()),
IsDetailMonospaced = false,
DetailToolTip = Loc.L("Tooltips.Videos.Delete"),
SafeText = Loc.L("Archive.Delete.Keep"),
SafeToolTip = Loc.L("Tooltips.Archive.DeleteKeep"),
ActionText = Loc.L("Videos.Delete.Confirm"),
ActionToolTip = Loc.L("Tooltips.Videos.DeleteConfirm"),
IsDestructive = true,
};
}
}