- Keyboard: Tab follows the visual order (toolbars, section list, dialog buttons), reaches every Jobs row button, stays inside the Welcome dialog (which opens focused); the Settings section list shows a focus ring. - Screen readers: sync and job rows read as their sequence or job with the state as item status; row buttons name their row; filter chips are radio buttons; the connection state, errors, sync retries, update checks and self-test results are announced; Auto values are text, not dead buttons. - Right to left: paths, addresses, templates, fingerprints, the job log, sizes and the logo stay left to right; numbers stay right-aligned. - Layout: Jobs and sync headers line up with their rows (shared padding, shared actions column, constant scroll-bar gutter); toolbars wrap before anything is cut; Settings labels share a column as wide as the longest one; path rows give way instead of wrapping; conflict rows use the warning tint. - Behaviour: Settings reloads the archive folder and default server set elsewhere; forgetting a certificate in Settings asks first and disconnects the session on it; transfers count in the Local only and Remote chips; the Workers readout counts this PC's workers; badge, status strip and Running chip agree; the admin link shows for administrators only; Reset section is gone from Advanced; empty states carry one action; shorter labels; the encoders a render node offers and the presets each encoder serves. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
131 lines
4.9 KiB
C#
131 lines
4.9 KiB
C#
using System.Windows.Input;
|
||
using Titano.App.Infrastructure;
|
||
using Titano.Core.Localization;
|
||
using Titano.Ui.Controls;
|
||
using Titano.Ui.Mvvm;
|
||
|
||
namespace Titano.App.Settings;
|
||
|
||
/// <summary>Sections of the Settings screen (BRIEF §12.8).</summary>
|
||
public enum SettingsPage
|
||
{
|
||
General,
|
||
Archive,
|
||
Rendering,
|
||
Storage,
|
||
Server,
|
||
Updates,
|
||
Advanced,
|
||
}
|
||
|
||
/// <summary>An entry of the section list: name, tooltip (what is inside) and the words the search matches.</summary>
|
||
public sealed class SettingsPageItem(SettingsPage page, string[] keywordKeys) : ObservableObject
|
||
{
|
||
public SettingsPage Page { get; } = page;
|
||
|
||
public string Label => Loc.L("Settings.Page." + Page);
|
||
|
||
public string ToolTip => Loc.L("Tooltips.Settings.Page." + Page);
|
||
|
||
/// <summary>True when <paramref name="text"/> appears in the page name, its tooltip or one of its labels.</summary>
|
||
public bool Matches(string text) =>
|
||
Label.Contains(text, StringComparison.CurrentCultureIgnoreCase)
|
||
|| ToolTip.Contains(text, StringComparison.CurrentCultureIgnoreCase)
|
||
|| keywordKeys.Any(k => Loc.L(k).Contains(text, StringComparison.CurrentCultureIgnoreCase));
|
||
|
||
internal void Refresh() => OnAllPropertiesChanged();
|
||
}
|
||
|
||
/// <summary>A choice of a settings dropdown.</summary>
|
||
public sealed record SettingsOption<T>(T Value, string Label)
|
||
{
|
||
public override string ToString() => Label;
|
||
}
|
||
|
||
/// <summary>One row of the encoder table with its self-test state.</summary>
|
||
public sealed class EncoderRowViewModel(EncoderRow row) : ObservableObject
|
||
{
|
||
private SelfTestResult? _result;
|
||
private bool _isTesting;
|
||
|
||
public EncoderRow Row { get; } = row;
|
||
|
||
public string Codec => Row.Codec;
|
||
|
||
/// <summary>"NVIDIA NVENC (hardware)".</summary>
|
||
public string Name => Row.Source switch
|
||
{
|
||
EncoderSource.MediaFoundation => Loc.L(Row.Hardware ? "Settings.Rendering.Encoder.Hardware" : "Settings.Rendering.Encoder.Software", Row.DisplayName),
|
||
_ => Loc.L("Settings.Rendering.Encoder.BuiltIn", Row.DisplayName),
|
||
};
|
||
|
||
/// <summary>"Main10", "10-bit" or "—".</summary>
|
||
public string TenBitText => !Row.TenBit ? "—" : Row.VideoCodec == Core.Video.VideoCodec.Hevc ? "Main10" : Loc.L("Settings.Rendering.TenBit");
|
||
|
||
public bool HasTenBit => Row.TenBit;
|
||
|
||
/// <summary>"8192×8192" (width first in every language) or "no limit".</summary>
|
||
public string MaxText => Row.MaxWidth > 0 ? Formatting.LeftToRight($"{Row.MaxWidth}×{Row.MaxHeight}") : Loc.L("Settings.Rendering.NoLimit");
|
||
|
||
/// <summary>The built-in presets this encoder serves (Settings.html "Used for").</summary>
|
||
public string UsedForText => EncoderUse.Text(Row);
|
||
|
||
public bool IsTesting
|
||
{
|
||
get => _isTesting;
|
||
set
|
||
{
|
||
if (Set(ref _isTesting, value)) RaiseResult();
|
||
}
|
||
}
|
||
|
||
public SelfTestResult? Result
|
||
{
|
||
get => _result;
|
||
set
|
||
{
|
||
if (Set(ref _result, value)) RaiseResult();
|
||
}
|
||
}
|
||
|
||
public bool HasResult => _result is not null || _isTesting;
|
||
|
||
public StatusKind ResultKind => _isTesting ? StatusKind.Running : _result is { Passed: true } ? StatusKind.Done : StatusKind.Failed;
|
||
|
||
/// <summary>"142 fps · ok", "failed", "testing".</summary>
|
||
public string ResultText => _isTesting ? Loc.L("Settings.Rendering.Testing")
|
||
: _result is not { } r ? "—"
|
||
: r.Passed ? Loc.L("Settings.Rendering.Passed", Formatting.Rate(r.FramesPerSecond))
|
||
: Loc.L("Settings.Rendering.Failed");
|
||
|
||
public string ResultToolTip => _result is { Passed: false, Error: { } error } ? error : Loc.L("Tooltips.Settings.SelfTestResult");
|
||
|
||
/// <summary>What a screen reader announces when the self-test of this row moves on: "HEVC NVIDIA NVENC (hardware): 142 fps · ok".</summary>
|
||
public string ResultAnnouncement => Loc.L("Settings.Rendering.ResultFor", Codec, Name, ResultText);
|
||
|
||
internal void Refresh() => OnAllPropertiesChanged();
|
||
|
||
private void RaiseResult()
|
||
{
|
||
OnPropertyChanged(nameof(HasResult));
|
||
OnPropertyChanged(nameof(ResultKind));
|
||
OnPropertyChanged(nameof(ResultText));
|
||
OnPropertyChanged(nameof(ResultToolTip));
|
||
OnPropertyChanged(nameof(ResultAnnouncement));
|
||
}
|
||
}
|
||
|
||
/// <summary>A trusted server certificate in Settings › Server.</summary>
|
||
public sealed class TrustedCertificateRow(TrustedCertificate certificate, ICommand forget)
|
||
{
|
||
public TrustedCertificate Certificate { get; } = certificate;
|
||
public string Server => Certificate.Server ?? "—";
|
||
public string Fingerprint => Titano.App.Server.ServerSession.ShortFingerprint(Certificate.Fingerprint);
|
||
public string FullFingerprint => Certificate.Fingerprint;
|
||
public string TrustedText => Formatting.Date(Certificate.TrustedAt);
|
||
public ICommand ForgetCommand { get; } = forget;
|
||
|
||
/// <summary>"Forget: https://nas.local:8443": the button names its server for screen readers.</summary>
|
||
public string ForgetName => Loc.L("Settings.Server.ForgetName", Server);
|
||
}
|