Change the operator of the contacts picked in the log

A multi-operator station logs a whole shift under whoever was at the
radio, so a shift logged under the wrong callsign had to be put right a
contact at a time. "Change Operator…" in the log's right-click menu asks
for one callsign and writes it against every contact picked in the grid.

The dialog offers the operators the program already knows in a drop-down
and takes any other callsign typed.

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 16:56:04 +00:00
co-authored by Claude Opus 5
parent 56c7bcef21
commit 836624376e
2 changed files with 70 additions and 0 deletions
@@ -0,0 +1,21 @@
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="Nonemm.App.Dialogs.ChangeOperatorDialog"
Title="Change Operator" Width="380" SizeToContent="Height"
WindowStartupLocation="CenterOwner" CanResize="False">
<DockPanel Margin="14">
<StackPanel DockPanel.Dock="Bottom" Orientation="Horizontal" HorizontalAlignment="Right"
Spacing="6" Margin="0,12,0,0">
<Button Content="Cancel" Click="OnCancel" IsCancel="True" />
<Button Content="Ok" Click="OnOk" IsDefault="True" />
</StackPanel>
<StackPanel Spacing="6">
<TextBlock Name="AboutText" TextWrapping="Wrap" />
<Grid ColumnDefinitions="*,6,150">
<TextBox Name="CallBox" />
<ComboBox Name="KnownBox" Grid.Column="2" HorizontalAlignment="Stretch"
SelectionChanged="OnPickedKnown" PlaceholderText="known" />
</Grid>
</StackPanel>
</DockPanel>
</Window>
@@ -0,0 +1,49 @@
using Avalonia.Controls;
using Avalonia.Interactivity;
namespace Nonemm.App.Dialogs;
/// Which callsign to write against the contacts picked in the log. It closes
/// with the callsign, or with null when nothing is to change. The operators
/// already known to the program are in the drop-down; any other callsign is
/// typed.
public sealed partial class ChangeOperatorDialog : Window
{
public ChangeOperatorDialog(int contacts, string callsign, IReadOnlyList<string> known)
{
InitializeComponent();
AboutText.Text = contacts == 1
? "Operator callsign for the contact picked in the log"
: $"Operator callsign for the {contacts} contacts picked in the log";
CallBox.Text = callsign;
KnownBox.ItemsSource = known;
// the callsign is all this dialog asks for, so the cursor starts in it
// and the operator types over what is there
Opened += (_, _) =>
{
CallBox.Focus();
CallBox.SelectAll();
};
}
private void OnPickedKnown(object? sender, SelectionChangedEventArgs e)
{
if (KnownBox.SelectedItem is string callsign)
{
CallBox.Text = callsign;
}
}
/// An empty box leaves the dialog open: clearing the operator of a contact
/// is not what this dialog is for.
private void OnOk(object? sender, RoutedEventArgs e)
{
string callsign = (CallBox.Text ?? "").Trim().ToUpperInvariant();
if (callsign.Length > 0)
{
Close(callsign);
}
}
private void OnCancel(object? sender, RoutedEventArgs e) => Close(null);
}