Give each operator his windows back

The program stored an operator's window positions but never used them at
startup: the entry window was not placed and no window was reopened. It
now restores the whole screen both at startup and on a change of
operator: the windows that operator had open, where he had them, and the
ones he did not have closed.

The second radio's entry window no longer saves the layout. It has none
of the other windows open, so saving from it dropped every window the
first one had.

Ctrl+O gets six buttons for the operators last at the radio, newest
first. One click changes to that operator.

The recordings folder is no longer asked for. It is `Wav/<callsign>`
under the data folder, which is where N1MM plays them from, so
`StoredOperator.WavPath` is gone.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0157i7PiZyqBkquxS9A6FTdQ
This commit is contained in:
2026-09-10 13:58:12 +00:00
co-authored by Claude Opus 5
parent 66e9a0ab65
commit f2d9e331b4
7 changed files with 114 additions and 53 deletions
+2 -7
View File
@@ -20,19 +20,14 @@
Click="OnCancel" IsCancel="True" />
</StackPanel>
<StackPanel Spacing="2">
<TextBlock TextWrapping="Wrap" FontSize="11" Opacity="0.75"
Text="Whoever is at the radio. The callsign goes against every contact logged from now on, and the windows, colours and recordings are this operator's own." />
<TextBlock Name="RecentLabel" Classes="label" Text="Recent" />
<UniformGrid Name="RecentPanel" Columns="3" />
<TextBlock Classes="label" Text="Operator callsign" />
<Grid ColumnDefinitions="*,6,150">
<TextBox Name="CallBox" />
<ComboBox Name="KnownBox" Grid.Column="2" HorizontalAlignment="Stretch"
SelectionChanged="OnPickedKnown" PlaceholderText="known" />
</Grid>
<TextBlock Classes="label" Text="Recordings folder (the voice keyer's wav files)" />
<Grid ColumnDefinitions="*,6,Auto">
<TextBox Name="WavBox" />
<Button Grid.Column="2" Content="Browse…" Click="OnBrowseWav" />
</Grid>
<TextBlock Name="AboutText" FontSize="11" Opacity="0.75" Margin="0,10,0,0"
TextWrapping="Wrap" />
</StackPanel>
+33 -19
View File
@@ -1,6 +1,7 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Platform.Storage;
using Avalonia.Layout;
using Nonemm.App.Configuration;
namespace Nonemm.App.Dialogs;
@@ -14,15 +15,19 @@ public sealed record OperatorChoice(StoredOperator Operator, bool IsRemoval);
/// callsign is not in the list yet is made by typing it.
public sealed partial class OperatorDialog : Window
{
private readonly IReadOnlyList<StoredOperator> known;
/// How many of the operators who were last at the radio get a button. Six
/// fits two rows of three, which covers a weekend's shift roster.
private const int RecentCount = 6;
private readonly Settings settings;
public OperatorDialog(Settings settings)
{
known = settings.Operators;
this.settings = settings;
InitializeComponent();
KnownBox.ItemsSource = known.Select(o => o.Callsign).ToList();
KnownBox.ItemsSource = settings.Operators.Select(o => o.Callsign).ToList();
CallBox.Text = settings.CurrentOperator;
WavBox.Text = Find(settings.CurrentOperator)?.WavPath ?? "";
ShowRecent();
ShowWhatIsKept();
// the callsign is all most operators type here, so the cursor starts in
// it and Enter closes the dialog
@@ -35,6 +40,26 @@ public sealed partial class OperatorDialog : Window
};
}
/// A button for each of the last few operators at the radio, newest first.
/// One click changes to that operator.
private void ShowRecent()
{
StoredOperator[] recent = [.. settings.RecentOperators(RecentCount)];
RecentLabel.IsVisible = recent.Length > 0;
foreach (StoredOperator stored in recent)
{
Button button = new()
{
Content = stored.Callsign,
Margin = new Thickness(0, 2, 4, 2),
HorizontalAlignment = HorizontalAlignment.Stretch,
HorizontalContentAlignment = HorizontalAlignment.Center,
};
button.Click += (_, _) => Close(new OperatorChoice(stored, IsRemoval: false));
RecentPanel.Children.Add(button);
}
}
/// The operator as the dialog leaves him: the callsign typed, keeping
/// whatever was stored for him before.
private StoredOperator Picked
@@ -43,12 +68,12 @@ public sealed partial class OperatorDialog : Window
{
string callsign = (CallBox.Text ?? "").Trim().ToUpperInvariant();
StoredOperator stored = Find(callsign) ?? new StoredOperator();
return stored with { Callsign = callsign, WavPath = (WavBox.Text ?? "").Trim() };
return stored with { Callsign = callsign };
}
}
private StoredOperator? Find(string callsign) =>
known.FirstOrDefault(o => string.Equals(o.Callsign, callsign.Trim(), StringComparison.OrdinalIgnoreCase));
settings.Operators.FirstOrDefault(o => string.Equals(o.Callsign, callsign.Trim(), StringComparison.OrdinalIgnoreCase));
private void OnPickedKnown(object? sender, SelectionChangedEventArgs e)
{
@@ -57,7 +82,6 @@ public sealed partial class OperatorDialog : Window
return;
}
CallBox.Text = callsign;
WavBox.Text = Find(callsign)?.WavPath ?? "";
ShowWhatIsKept();
}
@@ -65,21 +89,11 @@ public sealed partial class OperatorDialog : Window
{
StoredOperator? stored = Find(CallBox.Text ?? "");
AboutText.Text = stored is null
? "A new operator: the windows and colours on the screen now become his."
? "new operator"
: $"{stored.Windows.Count} window positions kept"
+ (stored.Theme.Length > 0 ? $", {stored.Theme} colours" : ", the colours as they are");
}
private async void OnBrowseWav(object? sender, RoutedEventArgs e)
{
IReadOnlyList<IStorageFolder> picked = await StorageProvider.OpenFolderPickerAsync(
new FolderPickerOpenOptions { Title = "The operator's recordings", AllowMultiple = false });
if (picked.Count > 0)
{
WavBox.Text = picked[0].Path.LocalPath;
}
}
private void OnOk(object? sender, RoutedEventArgs e)
{
if (Picked.Callsign.Length > 0)