fix(app): retag stops on Cancel between sequences; menu tooltips show while disabled
Rename and retag log what they changed; the set filter has its own test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
5 files changed
+81
-20
No files matched your search
@@ -74,6 +74,7 @@
|
||||
<data name="Tooltips.Archive.SetRetag" xml:space="preserve"><value>Add or remove tags on the whole set</value></data>
|
||||
<data name="Tooltips.Archive.SetThumbnails" xml:space="preserve"><value>Generate or refresh thumbnails</value></data>
|
||||
<data name="Tooltips.Archive.SetVerify" xml:space="preserve"><value>Re-hash the originals of the set</value></data>
|
||||
<data name="Tooltips.Archive.StopApply" xml:space="preserve"><value>Stop after the current sequence; the changes made so far stay</value></data>
|
||||
<data name="Tooltips.Archive.Storage" xml:space="preserve"><value>Bytes of originals per capture year</value></data>
|
||||
<data name="Tooltips.Archive.TagsAdd" xml:space="preserve"><value>Tags to add, separated by commas</value></data>
|
||||
<data name="Tooltips.Archive.TagsRemove" xml:space="preserve"><value>Tags to remove, separated by commas</value></data>
|
||||
|
||||
@@ -74,6 +74,7 @@
|
||||
<data name="Tooltips.Archive.SetRetag" xml:space="preserve"><value>Aggiungi o rimuovi tag su tutta la selezione</value></data>
|
||||
<data name="Tooltips.Archive.SetThumbnails" xml:space="preserve"><value>Crea o aggiorna le miniature</value></data>
|
||||
<data name="Tooltips.Archive.SetVerify" xml:space="preserve"><value>Ricalcola l'hash degli originali della selezione</value></data>
|
||||
<data name="Tooltips.Archive.StopApply" xml:space="preserve"><value>Fermati dopo la sequenza in corso; le modifiche già fatte restano</value></data>
|
||||
<data name="Tooltips.Archive.Storage" xml:space="preserve"><value>Spazio degli originali per anno di scatto</value></data>
|
||||
<data name="Tooltips.Archive.TagsAdd" xml:space="preserve"><value>Tag da aggiungere, separati da virgole</value></data>
|
||||
<data name="Tooltips.Archive.TagsRemove" xml:space="preserve"><value>Tag da rimuovere, separati da virgole</value></data>
|
||||
|
||||
@@ -14,19 +14,39 @@ using Titano.Ui.Mvvm;
|
||||
namespace Titano.App.Archiving;
|
||||
|
||||
/// <summary>
|
||||
/// An in-window dialog of the Archive screen: one primary action, one way out. While its action runs it cannot be
|
||||
/// closed; <paramref name="close"/> receives the dialog, so a late close never closes another one.
|
||||
/// An in-window dialog of the Archive screen: one primary action, one way out. While its action runs, the way out
|
||||
/// stops it when it can be stopped, and is disabled otherwise; the close callback receives the dialog, so a late close
|
||||
/// never closes another one.
|
||||
/// </summary>
|
||||
public abstract class ArchiveDialogViewModel : LocalizedViewModel
|
||||
{
|
||||
private readonly Action<ArchiveDialogViewModel> _close;
|
||||
private bool _isBusy;
|
||||
private string? _busyText;
|
||||
|
||||
protected ArchiveDialogViewModel(Action<ArchiveDialogViewModel> close) => CloseCommand = new RelayCommand(() => close(this), () => !IsBusy);
|
||||
protected ArchiveDialogViewModel(Action<ArchiveDialogViewModel> close)
|
||||
{
|
||||
_close = close;
|
||||
CloseCommand = new RelayCommand(() =>
|
||||
{
|
||||
if (IsBusy) Stop();
|
||||
else Close();
|
||||
}, () => !IsBusy || CanStop);
|
||||
}
|
||||
|
||||
/// <summary>Cancel: closes the dialog, or stops its running action.</summary>
|
||||
public ICommand CloseCommand { get; }
|
||||
|
||||
public string CloseToolTip => IsBusy ? Loc.L("Archive.Blocked.Applying") : Loc.L("Tooltips.Archive.CloseDialog");
|
||||
public string CloseToolTip => !IsBusy ? Loc.L("Tooltips.Archive.CloseDialog")
|
||||
: CanStop ? Loc.L("Tooltips.Archive.StopApply")
|
||||
: Loc.L("Archive.Blocked.Applying");
|
||||
|
||||
/// <summary>The running action can stop between two steps.</summary>
|
||||
protected virtual bool CanStop => false;
|
||||
|
||||
protected virtual void Stop()
|
||||
{
|
||||
}
|
||||
|
||||
public bool IsBusy
|
||||
{
|
||||
@@ -41,7 +61,7 @@ public abstract class ArchiveDialogViewModel : LocalizedViewModel
|
||||
|
||||
public string? BusyText { get => _busyText; protected set => Set(ref _busyText, value); }
|
||||
|
||||
protected void Close() => CloseCommand.Execute(null);
|
||||
protected void Close() => _close(this);
|
||||
}
|
||||
|
||||
/// <summary>A fact of the rebuild dialog ("Sidecars · 412").</summary>
|
||||
@@ -242,6 +262,7 @@ public sealed class RenameDialogViewModel : ArchiveDialogViewModel
|
||||
try
|
||||
{
|
||||
await Task.Run(() => _archives.ApplyRenameAsync(plan, progress));
|
||||
Log.Info("archive", $"{Mode} applied to {plan.Steps.Count} sequence(s)");
|
||||
await _applied(plan.Steps.Count);
|
||||
Close();
|
||||
}
|
||||
@@ -263,6 +284,7 @@ public sealed class RetagDialogViewModel : ArchiveDialogViewModel
|
||||
private readonly ArchiveService _archives;
|
||||
private readonly IReadOnlyList<Sequence> _set;
|
||||
private readonly Func<int, Task> _applied;
|
||||
private CancellationTokenSource? _run;
|
||||
|
||||
public RetagDialogViewModel(ArchiveService archives, IReadOnlyList<Sequence> set, Func<int, Task> applied, Action<ArchiveDialogViewModel> close)
|
||||
: base(close)
|
||||
@@ -306,19 +328,27 @@ public sealed class RetagDialogViewModel : ArchiveDialogViewModel
|
||||
private IReadOnlyList<(Sequence Sequence, IReadOnlyList<string> Tags)> Changes() =>
|
||||
Add.HasErrors || Remove.HasErrors ? [] : Retag.Changes(_set, Retag.Parse(Add.Text), Retag.Parse(Remove.Text));
|
||||
|
||||
protected override bool CanStop => _run is not null;
|
||||
|
||||
/// <summary>Stops after the sequence being written; each sequence is changed completely or not at all.</summary>
|
||||
protected override void Stop() => _run?.Cancel();
|
||||
|
||||
private async Task ApplyAsync()
|
||||
{
|
||||
var changes = Changes();
|
||||
var run = _run = new CancellationTokenSource();
|
||||
var done = 0;
|
||||
IsBusy = true;
|
||||
try
|
||||
{
|
||||
for (var i = 0; i < changes.Count; i++)
|
||||
for (; done < changes.Count && !run.IsCancellationRequested; done++)
|
||||
{
|
||||
var (s, tags) = changes[i];
|
||||
BusyText = Loc.L("Archive.Rename.Applying", Formatting.Count(i + 1), Formatting.Count(changes.Count));
|
||||
var (s, tags) = changes[done];
|
||||
BusyText = Loc.L("Archive.Rename.Applying", Formatting.Count(done + 1), Formatting.Count(changes.Count));
|
||||
await Task.Run(() => _archives.SetSequenceInfoAsync(s.Id, s.Title, tags, s.Rating, s.Notes));
|
||||
}
|
||||
await _applied(changes.Count);
|
||||
Log.Info("archive", $"Retag: {done} of {changes.Count} sequence(s) changed");
|
||||
await _applied(done);
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or ArgumentException or DatabaseException or ArchiveOfflineException)
|
||||
@@ -328,6 +358,8 @@ public sealed class RetagDialogViewModel : ArchiveDialogViewModel
|
||||
}
|
||||
finally
|
||||
{
|
||||
_run = null;
|
||||
run.Dispose();
|
||||
IsBusy = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,9 +18,6 @@
|
||||
<Style x:Key="Button.Tool" TargetType="Button" BasedOn="{StaticResource {x:Type Button}}">
|
||||
<Setter Property="Margin" Value="0,0,8,8" />
|
||||
</Style>
|
||||
<Style TargetType="MenuItem" BasedOn="{StaticResource {x:Type MenuItem}}">
|
||||
<Setter Property="ToolTipService.ShowOnDisabled" Value="True" />
|
||||
</Style>
|
||||
<!-- Rows that only show text: focusable, so the arrow keys move through a long list. -->
|
||||
<Style x:Key="ListBoxItem.Preview" TargetType="ListBoxItem" BasedOn="{StaticResource ListBoxItem.Row}">
|
||||
<Setter Property="Padding" Value="0" />
|
||||
@@ -36,6 +33,7 @@
|
||||
<Setter Property="IsChecked" Value="{Binding IsChecked, Mode=OneWay}" />
|
||||
<Setter Property="Command" Value="{Binding Command}" />
|
||||
<Setter Property="ToolTip" Value="{l:Loc Tooltips.Archive.FilterChoice}" />
|
||||
<Setter Property="ToolTipService.ShowOnDisabled" Value="True" />
|
||||
</Style>
|
||||
|
||||
<!-- Dialog card (DESIGN §4: Surface, Stroke, radius 12, 24 px shadow, two buttons). -->
|
||||
@@ -189,8 +187,8 @@
|
||||
</StackPanel>
|
||||
<Button.ContextMenu>
|
||||
<ContextMenu>
|
||||
<MenuItem Header="{l:Loc Archive.Adopt.InPlace}" Command="{Binding AdoptCommand}" ToolTip="{l:Loc Tooltips.Archive.AdoptInPlace}" />
|
||||
<MenuItem Header="{l:Loc Archive.Adopt.Copy}" Command="{Binding CopyFolderCommand}" ToolTip="{l:Loc Tooltips.Archive.AdoptCopy}" />
|
||||
<MenuItem Header="{l:Loc Archive.Adopt.InPlace}" Command="{Binding AdoptCommand}" ToolTip="{l:Loc Tooltips.Archive.AdoptInPlace}" ToolTipService.ShowOnDisabled="True" />
|
||||
<MenuItem Header="{l:Loc Archive.Adopt.Copy}" Command="{Binding CopyFolderCommand}" ToolTip="{l:Loc Tooltips.Archive.AdoptCopy}" ToolTipService.ShowOnDisabled="True" />
|
||||
</ContextMenu>
|
||||
</Button.ContextMenu>
|
||||
</Button>
|
||||
@@ -201,12 +199,12 @@
|
||||
</StackPanel>
|
||||
<Button.ContextMenu>
|
||||
<ContextMenu>
|
||||
<MenuItem Header="{l:Loc Archive.Maintenance.Run}" Command="{Binding MaintenanceCommand}" ToolTip="{Binding MaintenanceRunToolTip}" />
|
||||
<MenuItem Header="{l:Loc Archive.Maintenance.DryRun}" Command="{Binding MaintenanceDryRunCommand}" ToolTip="{l:Loc Tooltips.Archive.MaintenanceDryRun}" />
|
||||
<MenuItem Header="{l:Loc Archive.Maintenance.Proxies}" Command="{Binding RebuildProxiesCommand}" ToolTip="{Binding RebuildProxiesToolTip}" />
|
||||
<MenuItem Header="{l:Loc Archive.Maintenance.Backup}" Command="{Binding BackupCommand}" ToolTip="{l:Loc Tooltips.Archive.Backup}" />
|
||||
<MenuItem Header="{l:Loc Archive.Maintenance.Run}" Command="{Binding MaintenanceCommand}" ToolTip="{Binding MaintenanceRunToolTip}" ToolTipService.ShowOnDisabled="True" />
|
||||
<MenuItem Header="{l:Loc Archive.Maintenance.DryRun}" Command="{Binding MaintenanceDryRunCommand}" ToolTip="{l:Loc Tooltips.Archive.MaintenanceDryRun}" ToolTipService.ShowOnDisabled="True" />
|
||||
<MenuItem Header="{l:Loc Archive.Maintenance.Proxies}" Command="{Binding RebuildProxiesCommand}" ToolTip="{Binding RebuildProxiesToolTip}" ToolTipService.ShowOnDisabled="True" />
|
||||
<MenuItem Header="{l:Loc Archive.Maintenance.Backup}" Command="{Binding BackupCommand}" ToolTip="{l:Loc Tooltips.Archive.Backup}" ToolTipService.ShowOnDisabled="True" />
|
||||
<Separator />
|
||||
<MenuItem Header="{l:Loc Archive.Maintenance.Relink}" Command="{Binding RelinkCommand}" ToolTip="{l:Loc Tooltips.Archive.Relink}" />
|
||||
<MenuItem Header="{l:Loc Archive.Maintenance.Relink}" Command="{Binding RelinkCommand}" ToolTip="{l:Loc Tooltips.Archive.Relink}" ToolTipService.ShowOnDisabled="True" />
|
||||
</ContextMenu>
|
||||
</Button.ContextMenu>
|
||||
</Button>
|
||||
@@ -501,7 +499,7 @@
|
||||
<MenuItem Header="{l:Loc Library.Filter.Tags}" ItemsSource="{Binding TagChoices}" ItemContainerStyle="{StaticResource MenuItem.Choice}"
|
||||
ToolTip="{l:Loc Tooltips.Archive.FilterTag}" />
|
||||
<Separator />
|
||||
<MenuItem Header="{l:Loc Archive.Set.ClearFilter}" Command="{Binding ClearFilterCommand}" ToolTip="{l:Loc Tooltips.Archive.ClearFilter}" />
|
||||
<MenuItem Header="{l:Loc Archive.Set.ClearFilter}" Command="{Binding ClearFilterCommand}" ToolTip="{l:Loc Tooltips.Archive.ClearFilter}" ToolTipService.ShowOnDisabled="True" />
|
||||
</ContextMenu>
|
||||
</Button.ContextMenu>
|
||||
</Button>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Globalization;
|
||||
using Titano.App.Archiving;
|
||||
using Titano.App.Library;
|
||||
using Titano.Core.Archiving;
|
||||
using Titano.Core.Imaging;
|
||||
using Titano.Core.Localization;
|
||||
@@ -98,6 +99,34 @@ public sealed class ArchiveLogicTests
|
||||
],
|
||||
Health: new ArchiveHealth(Unverified: 3, WithWarnings: 1, WithErrors: 0, NotAnalyzed: 2, MissingFrames: 0, CorruptFrames: 0, DuplicateFrames: 5));
|
||||
|
||||
[Test]
|
||||
public void TheSetFilterNarrowsByCameraStatusAndTag()
|
||||
{
|
||||
var canon = Seq("Harbour", new DateTime(2026, 9, 28), tags: "sunset") with
|
||||
{
|
||||
CameraMake = "Canon",
|
||||
CameraModel = "Canon EOS R5",
|
||||
Status = SequenceStatus.AnalyzedLight | SequenceStatus.ProxiesBuilt,
|
||||
};
|
||||
var sony = Seq("Comet", new DateTime(2026, 8, 13), tags: "night") with { CameraMake = "SONY", CameraModel = "ILCE-7M4" };
|
||||
var unknown = Seq("Old", null);
|
||||
|
||||
Assert.True(new ArchiveSetFilter().IsEmpty);
|
||||
Assert.True(new ArchiveSetFilter().Matches(unknown), "no filter keeps everything");
|
||||
var byCamera = new ArchiveSetFilter(Camera: ArchiveSetFilter.CameraOf(canon));
|
||||
Assert.True(byCamera.Matches(canon));
|
||||
Assert.False(byCamera.Matches(sony));
|
||||
Assert.Equal(Loc.L("Archive.Chart.UnknownCamera"), ArchiveSetFilter.CameraOf(unknown));
|
||||
Assert.True(new ArchiveSetFilter(Status: StatusFilter.NotAnalysed).Matches(sony));
|
||||
Assert.False(new ArchiveSetFilter(Status: StatusFilter.NotAnalysed).Matches(canon));
|
||||
Assert.True(new ArchiveSetFilter(Status: StatusFilter.Proxies).Matches(canon));
|
||||
Assert.True(new ArchiveSetFilter(Tag: "SUNSET").Matches(canon), "tags compare without case");
|
||||
Assert.False(new ArchiveSetFilter(Tag: "sunset").Matches(sony));
|
||||
Assert.Equal(ArchiveSetFilter.CameraOf(canon) + " · Not analysed · sunset",
|
||||
new ArchiveSetFilter(ArchiveSetFilter.CameraOf(canon), StatusFilter.NotAnalysed, "sunset").Describe());
|
||||
Assert.Equal(string.Empty, new ArchiveSetFilter().Describe());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ChartsAggregateYearsCamerasAndFormats()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user