From 8c87a9f47f7d17930eb659f1079b9bfbf4e52ad8 Mon Sep 17 00:00:00 2001 From: Alberto Balbo Date: Thu, 5 Nov 2026 02:28:37 +0100 Subject: [PATCH] feat(P7): desktop Videos section with player, copy, delete and videos folder Adds the Videos rail section (Ctrl+4; Archive, Jobs and Server move to Ctrl+5..7) that lists every render of this PC's archive, the signed-in server and the workspace (not sent yet) in one list merged by render id, with search, kind, codec, year, source and order filters, cards or a list, and a player pane that plays in-process and falls back to "Cannot play here". Copy to folder queues a hash-verified VideoCopy job into the new Settings > Archive > Videos folder (never inside the archive or the workspace, the reason given when unset); Delete... runs the dry run first, shows its bytes and what stays, and deletes with the plan's fingerprint. An older server, or one out of reach, leaves this PC's videos with the reason. The trash dialog restores videos entries through the videos library, and a finished VideoCopy job raises its toast. Refs #21 Co-Authored-By: Claude Opus 5.5 --- .../Archive/TrashDialogViewModel.cs | 41 +- src/Chronos.App/Infrastructure/AppSettings.cs | 6 + src/Chronos.App/Jobs/JobNotices.cs | 2 +- src/Chronos.App/Sections/SettingsView.xaml | 16 + src/Chronos.App/Sections/SettingsViewModel.cs | 44 +- src/Chronos.App/Sections/VideosView.xaml | 247 ++++++ src/Chronos.App/Sections/VideosView.xaml.cs | 28 + src/Chronos.App/Sections/VideosViewModel.cs | 801 ++++++++++++++++++ src/Chronos.App/Shell/MainWindow.xaml | 16 +- src/Chronos.App/Shell/SectionTemplates.xaml | 2 + src/Chronos.App/Shell/SectionViewModel.cs | 3 + src/Chronos.App/Shell/ShellViewModel.cs | 21 +- src/Chronos.App/Videos/VideoPlayerPane.xaml | 40 + .../Videos/VideoPlayerPane.xaml.cs | 43 + .../Videos/VideoPlayerViewModel.cs | 132 +++ src/Chronos.App/Videos/VideoRows.cs | 213 +++++ src/Chronos.App/Videos/VideoSources.cs | 474 +++++++++++ .../Videos/VideosSectionTests.cs | 551 ++++++++++++ 18 files changed, 2665 insertions(+), 15 deletions(-) create mode 100644 src/Chronos.App/Sections/VideosView.xaml create mode 100644 src/Chronos.App/Sections/VideosView.xaml.cs create mode 100644 src/Chronos.App/Sections/VideosViewModel.cs create mode 100644 src/Chronos.App/Videos/VideoPlayerPane.xaml create mode 100644 src/Chronos.App/Videos/VideoPlayerPane.xaml.cs create mode 100644 src/Chronos.App/Videos/VideoPlayerViewModel.cs create mode 100644 src/Chronos.App/Videos/VideoRows.cs create mode 100644 src/Chronos.App/Videos/VideoSources.cs create mode 100644 tests/Chronos.App.Tests/Videos/VideosSectionTests.cs diff --git a/src/Chronos.App/Archive/TrashDialogViewModel.cs b/src/Chronos.App/Archive/TrashDialogViewModel.cs index 0962c9e3..6cc735ca 100644 --- a/src/Chronos.App/Archive/TrashDialogViewModel.cs +++ b/src/Chronos.App/Archive/TrashDialogViewModel.cs @@ -2,6 +2,7 @@ using System.Globalization; using System.IO; using System.Windows.Input; using Chronos.App.Infrastructure; +using Chronos.App.Videos; using Chronos.Core.Archiving; using Chronos.Core.Diagnostics; using Chronos.Core.Localization; @@ -9,6 +10,7 @@ using Chronos.Data; using Chronos.Data.Archiving; using Chronos.Data.Archiving.Jobs; using Chronos.Data.Jobs; +using Chronos.Data.Videos; using Chronos.Ui.Mvvm; namespace Chronos.App.Archiving; @@ -22,9 +24,16 @@ public sealed class TrashRowViewModel(TrashEntry entry, ICommand restore) /// "Photos", "Sequence": what the entry holds. public string KindText => TrashEmptyPlans.KindText(Entry.Kind); - /// "Photos · 12 photos · 340 MB · 2026/2026-09-28 Canon EOS R5" (the folder left to right in every language). - public string Detail => string.Join(Loc.Separator, KindText, Loc.Plural("Shell.Status.Photos", Entry.Frames), Formatting.Bytes(Entry.Bytes), - Formatting.LeftToRight(Entry.Folder)); + /// + /// "Photos · 12 photos · 340 MB · 2026/2026-09-28 Canon EOS R5" (the folder left to right in every language); a videos + /// entry has no photos: "Videos · 1.2 GB · …". + /// + public string Detail => Entry.Kind == TrashKind.Videos + ? string.Join(Loc.Separator, KindText, Formatting.Bytes(Entry.Bytes), Formatting.LeftToRight(Entry.Folder)) + : string.Join(Loc.Separator, KindText, Loc.Plural("Shell.Status.Photos", Entry.Frames), Formatting.Bytes(Entry.Bytes), Formatting.LeftToRight(Entry.Folder)); + + /// What Restore brings back: the render into its sequence's renders, or the sequence or photos. + public string RestoreToolTip => Entry.Kind == TrashKind.Videos ? Loc.L("Tooltips.Archive.TrashRestoreVideo") : Loc.L("Tooltips.Archive.TrashRestore"); /// "Deleted 02/10/2026 18:04". public string DeletedText => Loc.L("Archive.Trash.Deleted", Formatting.Date(Entry.DeletedAt) + " " + Formatting.TimeOfDay(Entry.DeletedAt)); @@ -175,6 +184,11 @@ public sealed class TrashDialogViewModel : ArchiveDialogViewModel BusyText = Loc.L("Archive.Trash.Restoring", entry.Title); try { + if (entry.Kind == TrashKind.Videos) + { + await RestoreVideoAsync(entry); + return; + } var result = await Task.Run(() => _archives.RestoreEntryAsync(entry.ArchiveId, entry.Name, _followUps)); Log.Info("archive", $"{entry.Title} restored from the trash ({entry.Kind}, {result.Photos} photo(s), {result.Kept.Count} kept)"); BusyText = null; @@ -205,6 +219,27 @@ public sealed class TrashDialogViewModel : ArchiveDialogViewModel } } + /// + /// A render deleted from Videos goes back among its sequence's renders after its hash is checked (the videos library + /// refuses a file that changed in the trash, or a sequence that is gone, and says why). + /// + private async Task RestoreVideoAsync(TrashEntry entry) + { + try + { + var render = await Task.Run(() => _archives.Videos.RestoreAsync(entry.ArchiveId, entry.Name)); + Log.Info("archive", $"{entry.Title} restored from the trash (render {render.Id})"); + Rows = [.. _rows.Where(r => r.Entry != entry)]; + await _restored(); + } + catch (VideoLibraryException ex) + { + Log.Warning("archive", $"Restoring {entry.Title} failed: {ex.Code}", ex); + var text = VideoText.Error(ex, entry.Title); + ShowMessage(text, text); + } + } + /// /// The line of what a restore kept in the trash, and its tooltip: one reason's sentence ("2 photos stayed in the trash: /// they could not be moved back."), or how many stayed when they stayed for different reasons. The tooltip holds that diff --git a/src/Chronos.App/Infrastructure/AppSettings.cs b/src/Chronos.App/Infrastructure/AppSettings.cs index 1a385bad..ad8dbec5 100644 --- a/src/Chronos.App/Infrastructure/AppSettings.cs +++ b/src/Chronos.App/Infrastructure/AppSettings.cs @@ -110,6 +110,12 @@ public sealed class AppSettings public string FolderTemplate { get; set; } = TemplateDefaults.Folder; public string FileTemplate { get; set; } = TemplateDefaults.File; + /// + /// Where Videos › Copy to folder puts copies of renders (owner review 1, R9): Videos\Chronos by default, null or empty + /// when unset (Copy then says why it cannot run). Never inside the archive or the workspace. + /// + public string? VideosFolder { get; set; } = Videos.VideosFolders.Default(); + /// Proxy long edge of new archives (also written into the open archive); 0 = full size, -1 = no proxies. public int ProxyLongEdge { get; set; } = 1920; diff --git a/src/Chronos.App/Jobs/JobNotices.cs b/src/Chronos.App/Jobs/JobNotices.cs index 62a02834..b0bb6966 100644 --- a/src/Chronos.App/Jobs/JobNotices.cs +++ b/src/Chronos.App/Jobs/JobNotices.cs @@ -41,7 +41,7 @@ public static class JobNotices private static bool Announces(JobKind kind) => kind is JobKind.Render or JobKind.DeepAnalyse or JobKind.Verify or JobKind.Rebuild or JobKind.Maintenance or JobKind.UploadCommit or JobKind.Move or JobKind.Adopt or JobKind.EmptyTrash or JobKind.Convert or JobKind.WorkspaceRender or JobKind.WorkspaceSend - or JobKind.WorkspaceMove; + or JobKind.WorkspaceMove or JobKind.VideoCopy; /// /// Work that keeps the index and its previews current: the next run repeats it, the Archive screen shows what is missing. diff --git a/src/Chronos.App/Sections/SettingsView.xaml b/src/Chronos.App/Sections/SettingsView.xaml index bdc4980f..69d859cf 100644 --- a/src/Chronos.App/Sections/SettingsView.xaml +++ b/src/Chronos.App/Sections/SettingsView.xaml @@ -192,6 +192,22 @@ + + + + + + + + + + internal void KeepSequence(Guid? sequenceId) => CurrentSequenceId = sequenceId; + /// + /// Opens Videos, narrowed to the renders of (the Export footer's "Videos (n)" and the Render + /// menu's "Videos"), or to every render with null; names the sequence in its filter chip. + /// + public void OpenVideos(Guid? sequenceId = null, string? title = null) + { + Videos.ShowSequence(sequenceId, title); + Navigate(SectionKey.Videos); + } + /// Closes the first-run overlay for good. public void CompleteWelcome() { @@ -362,6 +378,7 @@ public sealed class ShellViewModel : LocalizedViewModel Jobs.Dispose(); Library.Dispose(); Import.Dispose(); + Videos.Dispose(); Archive.Dispose(); Server.Dispose(); Settings.Dispose(); diff --git a/src/Chronos.App/Videos/VideoPlayerPane.xaml b/src/Chronos.App/Videos/VideoPlayerPane.xaml new file mode 100644 index 00000000..59cc7721 --- /dev/null +++ b/src/Chronos.App/Videos/VideoPlayerPane.xaml @@ -0,0 +1,40 @@ + + + + + +