diff --git a/i18n/en/Shell.resx b/i18n/en/Shell.resx
index a2ff72aa..af382003 100644
--- a/i18n/en/Shell.resx
+++ b/i18n/en/Shell.resx
@@ -6,7 +6,10 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Titanoinvariant
Ready
+ Pause job
Ready · {0} jobs queued
+ Ready · {0} job queued{0} count
+ Ready · {0} jobs queued{0} count
About
Archive
Import
@@ -37,4 +40,5 @@
Connect to a server
{0} on this network · {1}
Welcome to Titano
+ {0} — {1}{0} program name; {1} screen title
diff --git a/i18n/it/Shell.it.resx b/i18n/it/Shell.it.resx
index 6da87848..cea2f212 100644
--- a/i18n/it/Shell.it.resx
+++ b/i18n/it/Shell.it.resx
@@ -5,7 +5,10 @@
System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Pronto
+ Pausa attività
Pronto · {0} attività in coda
+ Pronto · {0} attività in coda
+ Pronto · {0} attività in coda
Informazioni
Archivio
Importa
@@ -36,4 +39,5 @@
Connettiti a un server
{0} in questa rete · {1}
Benvenuto in Titano
+ {0} — {1}
diff --git a/src/Titano.App/Infrastructure/UiLanguage.cs b/src/Titano.App/Infrastructure/UiLanguage.cs
index e2a5f783..e13df355 100644
--- a/src/Titano.App/Infrastructure/UiLanguage.cs
+++ b/src/Titano.App/Infrastructure/UiLanguage.cs
@@ -1,10 +1,13 @@
using System.Globalization;
-using System.Windows;
using Titano.Core.Localization;
namespace Titano.App.Infrastructure;
-/// Switches the UI language at run time without restart (BRIEF §16), mirroring right-to-left languages.
+///
+/// Switches the UI language at run time without restart (BRIEF §16). A takes
+/// the language's direction when it is created and follows each switch, so right-to-left languages mirror windows
+/// opened before and after this call alike.
+///
public static class UiLanguage
{
/// Applies (or the OS language when null) and returns the culture in use.
@@ -23,11 +26,6 @@ public static class UiLanguage
CultureInfo.DefaultThreadCurrentUICulture = culture;
CultureInfo.CurrentUICulture = culture;
Loc.SetCulture(culture);
- if (Application.Current is { } app)
- {
- foreach (Window window in app.Windows)
- window.FlowDirection = Loc.IsRightToLeft ? FlowDirection.RightToLeft : FlowDirection.LeftToRight;
- }
return culture;
}
}
diff --git a/src/Titano.App/Shell/AppStyles.xaml b/src/Titano.App/Shell/AppStyles.xaml
index 9538252a..82913741 100644
--- a/src/Titano.App/Shell/AppStyles.xaml
+++ b/src/Titano.App/Shell/AppStyles.xaml
@@ -43,8 +43,9 @@
-
+
-
-
-
-
-
diff --git a/src/Titano.App/Shell/ConfirmDialog.xaml b/src/Titano.App/Shell/ConfirmDialog.xaml
index 934a8896..3e05b8cf 100644
--- a/src/Titano.App/Shell/ConfirmDialog.xaml
+++ b/src/Titano.App/Shell/ConfirmDialog.xaml
@@ -5,14 +5,17 @@
xmlns:l="clr-namespace:Titano.Ui.Localization;assembly=Titano.Ui"
Title="{l:Loc Shell.AppName}"
IsDialog="True" ResizeMode="NoResize" SizeToContent="Height" Width="460"
- WindowStartupLocation="CenterOwner" ShowInTaskbar="False">
-
+ WindowStartupLocation="CenterOwner" ShowInTaskbar="False"
+ AutomationProperties.Name="{Binding Heading}" AutomationProperties.HelpText="{Binding Message}">
+
-
+
@@ -20,7 +23,7 @@
AutomationProperties.Name="{Binding TypedPrompt}" TextChanged="OnTyped" />
-
+
diff --git a/src/Titano.App/Shell/ConfirmDialog.xaml.cs b/src/Titano.App/Shell/ConfirmDialog.xaml.cs
index 025460db..72f55c6b 100644
--- a/src/Titano.App/Shell/ConfirmDialog.xaml.cs
+++ b/src/Titano.App/Shell/ConfirmDialog.xaml.cs
@@ -12,7 +12,11 @@ public sealed partial class ConfirmDialog : TitanoWindow
DataContext = request;
InitializeComponent();
Action.SetResourceReference(StyleProperty, request.IsDestructive ? "Button.Destructive" : "Button.Primary");
- if (request.TypedConfirmation is null) return;
+ if (request.TypedConfirmation is null)
+ {
+ Loaded += (_, _) => Safe.Focus();
+ return;
+ }
Typing.Visibility = Visibility.Visible;
Loaded += (_, _) => Typed.Focus();
EnableAction(false);
diff --git a/src/Titano.App/Shell/ErrorText.cs b/src/Titano.App/Shell/ErrorText.cs
new file mode 100644
index 00000000..5c9dd313
--- /dev/null
+++ b/src/Titano.App/Shell/ErrorText.cs
@@ -0,0 +1,37 @@
+using System.Reflection;
+using Titano.Core.Archiving;
+using Titano.Core.Import;
+using Titano.Core.Localization;
+using Titano.Core.Render;
+using Titano.Data.Archiving;
+using Titano.Data.Sync;
+using Titano.Protocol.Client;
+
+namespace Titano.App.Shell;
+
+///
+/// The sentence an error toast shows (BRIEF §0.2: one sentence saying what happened plus one action). Only failures
+/// that carry a catalog sentence say what happened; anything else (framework and OS messages, often technical
+/// English) reads "Something went wrong." and stays in the log.
+///
+public static class ErrorText
+{
+ public static string For(Exception ex) => Describe(Unwrap(ex)) ?? Loc.L("Errors.Unexpected");
+
+ private static string? Describe(Exception ex) => ex switch
+ {
+ LeaseUnavailableException or ArchiveOfflineException or NewerFormatException or ImportSourceUnavailableException
+ or CopyVerificationException or StaleRenamePlanException or SyncConflictChangedException => ex.Message,
+ // The server words its errors in the client's language (Accept-Language).
+ TitanoApiException api when !string.IsNullOrWhiteSpace(api.Error.Message) => api.Error.Message,
+ RenderException render => Loc.Get(render.ReasonKey, Loc.Culture) is null ? null : Loc.L(render.ReasonKey, [.. render.Args]),
+ _ => null,
+ };
+
+ /// Awaited tasks and reflection wrap the real failure in one layer or more.
+ private static Exception Unwrap(Exception ex)
+ {
+ while (ex is AggregateException { InnerExceptions.Count: 1 } or TargetInvocationException && ex.InnerException is { } inner) ex = inner;
+ return ex;
+ }
+}
diff --git a/src/Titano.App/Shell/LoginDialog.xaml b/src/Titano.App/Shell/LoginDialog.xaml
index 119b339c..0e4fc295 100644
--- a/src/Titano.App/Shell/LoginDialog.xaml
+++ b/src/Titano.App/Shell/LoginDialog.xaml
@@ -5,11 +5,11 @@
xmlns:l="clr-namespace:Titano.Ui.Localization;assembly=Titano.Ui"
Title="{l:Loc Shell.AppName}"
IsDialog="True" ResizeMode="NoResize" SizeToContent="Height" Width="440"
- WindowStartupLocation="CenterOwner" ShowInTaskbar="False">
+ WindowStartupLocation="CenterOwner" ShowInTaskbar="False" AutomationProperties.Name="{l:Loc Server.Login.Title}">
-
+
diff --git a/src/Titano.App/Shell/LoginDialog.xaml.cs b/src/Titano.App/Shell/LoginDialog.xaml.cs
index 85f4e999..2447e2c3 100644
--- a/src/Titano.App/Shell/LoginDialog.xaml.cs
+++ b/src/Titano.App/Shell/LoginDialog.xaml.cs
@@ -1,4 +1,6 @@
using System.Windows;
+using System.Windows.Automation;
+using System.Windows.Automation.Peers;
using Titano.Ui.Controls;
namespace Titano.App.Shell;
@@ -6,7 +8,7 @@ namespace Titano.App.Shell;
///
/// The login form (BRIEF §12.7). It calls back the connection with the credentials and stays open with the
/// error sentence until the sign-in succeeds or the user cancels. The password never leaves the PasswordBox
-/// except for that call.
+/// except for that call. A failed sign-in is announced to screen readers and stays as the password box's help text.
///
public sealed partial class LoginDialog : TitanoWindow
{
@@ -40,6 +42,7 @@ public sealed partial class LoginDialog : TitanoWindow
{
SignIn.IsEnabled = false;
Error.Visibility = Visibility.Collapsed;
+ AutomationProperties.SetHelpText(Password, string.Empty);
try
{
var error = await _signIn(User.Text, Password.Password);
@@ -50,8 +53,11 @@ public sealed partial class LoginDialog : TitanoWindow
}
Error.Text = error;
Error.Visibility = Visibility.Visible;
+ AutomationProperties.SetHelpText(Password, error);
Password.Clear();
Password.Focus();
+ UIElementAutomationPeer.CreatePeerForElement(this)?.RaiseNotificationEvent(
+ AutomationNotificationKind.ActionCompleted, AutomationNotificationProcessing.ImportantMostRecent, error, "Titano.SignIn");
}
finally
{
diff --git a/src/Titano.App/Shell/MainWindow.xaml b/src/Titano.App/Shell/MainWindow.xaml
index e2d5156e..a27115d2 100644
--- a/src/Titano.App/Shell/MainWindow.xaml
+++ b/src/Titano.App/Shell/MainWindow.xaml
@@ -14,8 +14,23 @@
-
-
+
+
+
+
+
-
+
@@ -50,7 +65,7 @@
@@ -65,14 +80,17 @@
-
-
-
-
+
+
-
+
+
+
+
diff --git a/src/Titano.App/Shell/MainWindow.xaml.cs b/src/Titano.App/Shell/MainWindow.xaml.cs
index bc7982ec..b5fc47f7 100644
--- a/src/Titano.App/Shell/MainWindow.xaml.cs
+++ b/src/Titano.App/Shell/MainWindow.xaml.cs
@@ -1,5 +1,9 @@
using System.Collections.Specialized;
using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Threading;
using Titano.App.Infrastructure;
using Titano.Ui.Controls;
@@ -14,21 +18,50 @@ public partial class MainWindow : TitanoWindow
_shell = shell;
DataContext = shell;
InitializeComponent();
- Rail.Width = shell.IsRailCollapsed ? 48 : 128;
UpdateConnection();
shell.PropertyChanged += (_, e) =>
{
- if (e.PropertyName is nameof(ShellViewModel.IsRailCollapsed) or "")
- Rail.Width = shell.IsRailCollapsed ? 48 : 128;
if (e.PropertyName is nameof(ShellViewModel.IsConnected) or "") UpdateConnection();
+ if (e.PropertyName is nameof(ShellViewModel.IsWelcomeOpen) or "") FocusWelcome();
};
shell.PendingToasts.CollectionChanged += OnToastRequested;
+ Loaded += (_, _) => FocusWelcome();
RestorePlacement();
Closing += (_, _) => SavePlacement();
}
+ /// F6 moves the keyboard to the newest notification (as in Windows apps), Esc there dismisses it.
+ protected override void OnKeyDown(KeyEventArgs e)
+ {
+ base.OnKeyDown(e);
+ if (!e.Handled && e.Key == Key.F6 && Keyboard.Modifiers == ModifierKeys.None) e.Handled = Toasts.FocusNewest();
+ }
+
private void UpdateConnection() =>
- Connection.SetResourceReference(System.Windows.Controls.TextBlock.ForegroundProperty, _shell.IsConnected ? "Brush.Accent" : "Brush.TextMuted");
+ Connection.SetResourceReference(TextBlock.ForegroundProperty, _shell.IsConnected ? "Brush.Accent" : "Brush.TextMuted");
+
+ /// The first-run dialog takes the keyboard on its chosen option once it is on screen.
+ private void FocusWelcome()
+ {
+ if (!_shell.IsWelcomeOpen) return;
+ Dispatcher.BeginInvoke(DispatcherPriority.Loaded, () =>
+ {
+ if (!_shell.IsWelcomeOpen || !IsLoaded) return;
+ if (FindChecked(WelcomeOverlay) is { } choice) choice.Focus();
+ else WelcomeOverlay.MoveFocus(new TraversalRequest(FocusNavigationDirection.First));
+ });
+ }
+
+ private static RadioButton? FindChecked(DependencyObject root)
+ {
+ for (var i = 0; i < VisualTreeHelper.GetChildrenCount(root); i++)
+ {
+ var child = VisualTreeHelper.GetChild(root, i);
+ if (child is RadioButton { IsChecked: true } radio) return radio;
+ if (FindChecked(child) is { } nested) return nested;
+ }
+ return null;
+ }
private void OnToastRequested(object? sender, NotifyCollectionChangedEventArgs e)
{
diff --git a/src/Titano.App/Shell/ShellViewModel.cs b/src/Titano.App/Shell/ShellViewModel.cs
index ad645906..de982d4a 100644
--- a/src/Titano.App/Shell/ShellViewModel.cs
+++ b/src/Titano.App/Shell/ShellViewModel.cs
@@ -85,12 +85,17 @@ public sealed class ShellViewModel : LocalizedViewModel
get => _welcome;
private set
{
- if (Set(ref _welcome, value)) OnPropertyChanged(nameof(IsWelcomeOpen));
+ if (!Set(ref _welcome, value)) return;
+ OnPropertyChanged(nameof(IsWelcomeOpen));
+ OnPropertyChanged(nameof(IsShellEnabled));
}
}
public bool IsWelcomeOpen => _welcome is not null;
+ /// The rail and the sections take input only while no first-run dialog covers them.
+ public bool IsShellEnabled => _welcome is null;
+
public SectionViewModel Current
{
get => _current;
@@ -105,7 +110,7 @@ public sealed class ShellViewModel : LocalizedViewModel
}
}
- public string WindowTitle => Current == Library ? "Titano" : "Titano — " + Current.Title;
+ public string WindowTitle => Current == Library ? Loc.L("Shell.AppName") : Loc.L("Shell.WindowTitle", Loc.L("Shell.AppName"), Current.Title);
public bool IsRailCollapsed
{
@@ -160,7 +165,7 @@ public sealed class ShellViewModel : LocalizedViewModel
// ---- Job bar ----
public string JobText => _jobActive && _jobText is not null
? _jobText
- : _queuedCount > 0 ? Loc.L("Shell.JobBar.Ready", _queuedCount) : Loc.L("Shell.JobBar.Idle");
+ : _queuedCount > 0 ? Loc.Plural("Shell.JobBar.Ready", _queuedCount) : Loc.L("Shell.JobBar.Idle");
public double JobProgress { get => _jobProgress; private set => Set(ref _jobProgress, value); }
public bool IsJobActive
@@ -250,14 +255,13 @@ public sealed class ShellViewModel : LocalizedViewModel
ActionCommand = action is null ? null : new RelayCommand(action),
});
- /// Errors are one sentence saying what happened plus one action (BRIEF §0.2 rule 6).
+ /// Errors are one sentence saying what happened plus one action (BRIEF §0.2 rule 6); the details go to the log.
public void ReportError(Exception ex)
{
Log.Error("ui", "Operation failed", ex);
ShowToast(new Toast
{
- Title = Loc.L("Errors.Unexpected"),
- Message = ex.Message,
+ Title = ErrorText.For(ex),
ActionText = Loc.L("Common.OpenLogs"),
ActionToolTip = Loc.L("Tooltips.Common.OpenLogs"),
ActionCommand = new RelayCommand(() => ShellActions.Reveal(Services.Environment.LogDirectory)),