Put the QTC window's settings on its right-click menu
N1MM keeps them on a Setup tab inside the window; here they are a dialog behind a right-click, which suits a window this size better. Four of them, with N1MM's own defaults: how many QTCs a series carries, whether the RX Ready and Cfm steps are stopped at on the way through, and whether Hdr Agn and Agn clear what they are asking for again. Each one changes what the window does. The series count is passed to the search for contacts worth reporting, the two skip settings are the focus order, and the two clear settings are what the Agn buttons do. The Cfm buttons also disappear when a RTTY station is reading its own log out, which is what N1MM does with them. N1MM's remaining QTC settings are all about putting traffic on the air — the CW messages for Agn and TU, the field spacing, the four SSB recordings, the RTTY templates — and nothing here transmits, so they are left out rather than shown as settings that do nothing. The dialog says so where the operator will look. The right-click menu needed a background on the panel to come up anywhere but over a control: a panel with no background is not hit-tested. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -67,6 +67,20 @@ public sealed record Settings
|
||||
/// 100 ms, because an SO2R box works relays.
|
||||
public int AlternatingCqGapMs { get; init; } = 100;
|
||||
|
||||
/// How the WAE QTC window behaves. The names and the defaults are N1MM's:
|
||||
/// it skips the confirm and ready steps out of the box, clears the header
|
||||
/// when the header is asked for again, and leaves a line alone when the
|
||||
/// line is.
|
||||
public int QtcLinesPerSeries { get; init; } = 10;
|
||||
|
||||
public bool QtcSkipReady { get; init; } = true;
|
||||
|
||||
public bool QtcSkipConfirm { get; init; } = true;
|
||||
|
||||
public bool QtcHeaderAgainClears { get; init; } = true;
|
||||
|
||||
public bool QtcAgainClearsLine { get; init; }
|
||||
|
||||
/// Sub-band boundaries the operator has changed. Empty means the defaults
|
||||
/// in `BandPlan.Default`; an entry replaces one band's boundaries.
|
||||
public IReadOnlyList<StoredSubBand> SubBands { get; init; } = [];
|
||||
|
||||
28
src/Nonemm.App/Dialogs/QtcSetupDialog.axaml
Normal file
28
src/Nonemm.App/Dialogs/QtcSetupDialog.axaml
Normal file
@@ -0,0 +1,28 @@
|
||||
<Window xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
x:Class="Nonemm.App.Dialogs.QtcSetupDialog"
|
||||
Title="QTC setup" Width="420" SizeToContent="Height"
|
||||
WindowStartupLocation="CenterOwner" CanResize="False">
|
||||
<StackPanel Margin="14" Spacing="8">
|
||||
<StackPanel Orientation="Horizontal" Spacing="8">
|
||||
<TextBlock Text="QTCs in a series" VerticalAlignment="Center" />
|
||||
<TextBox Name="CountBox" Width="50" />
|
||||
</StackPanel>
|
||||
<TextBlock Text="1 to 10, and fewer when the station has already had some."
|
||||
FontSize="11" Opacity="0.7" TextWrapping="Wrap" Margin="0,-4,0,0" />
|
||||
<CheckBox Name="SkipReadyBox" Content="Skip the RX Ready step" />
|
||||
<TextBlock Text="Off puts the cursor on RX Ready when the window opens, so the other station is told to go ahead before anything is typed."
|
||||
FontSize="11" Opacity="0.7" TextWrapping="Wrap" Margin="24,-6,0,0" />
|
||||
<CheckBox Name="SkipConfirmBox" Content="Skip the Cfm step" />
|
||||
<TextBlock Text="Off stops at each line's Cfm button before moving to the next line."
|
||||
FontSize="11" Opacity="0.7" TextWrapping="Wrap" Margin="24,-6,0,0" />
|
||||
<CheckBox Name="HeaderAgainClearsBox" Content="Hdr Agn clears the header" />
|
||||
<CheckBox Name="AgainClearsBox" Content="Agn clears the line" />
|
||||
<TextBlock Name="MissingText" FontSize="11" Opacity="0.7" TextWrapping="Wrap" Margin="0,6,0,0"
|
||||
Text="N1MM's other QTC settings are for sending: the CW messages for Agn and TU, the field spacing, the SSB recordings and the RTTY message templates. Nothing here transmits, so they are left out rather than shown as settings that do nothing." />
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Spacing="6" Margin="0,8,0,0">
|
||||
<Button Content="Cancel" Click="OnCancel" />
|
||||
<Button Content="Save" Click="OnSave" IsDefault="True" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Window>
|
||||
36
src/Nonemm.App/Dialogs/QtcSetupDialog.axaml.cs
Normal file
36
src/Nonemm.App/Dialogs/QtcSetupDialog.axaml.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Nonemm.App.Configuration;
|
||||
|
||||
namespace Nonemm.App.Dialogs;
|
||||
|
||||
/// The QTC window's own settings, on its right-click menu as N1MM keeps them on
|
||||
/// the window's Setup tab.
|
||||
public sealed partial class QtcSetupDialog : Window
|
||||
{
|
||||
private readonly Settings settings;
|
||||
|
||||
public QtcSetupDialog(Settings settings)
|
||||
{
|
||||
this.settings = settings;
|
||||
InitializeComponent();
|
||||
CountBox.Text = settings.QtcLinesPerSeries.ToString();
|
||||
SkipReadyBox.IsChecked = settings.QtcSkipReady;
|
||||
SkipConfirmBox.IsChecked = settings.QtcSkipConfirm;
|
||||
HeaderAgainClearsBox.IsChecked = settings.QtcHeaderAgainClears;
|
||||
AgainClearsBox.IsChecked = settings.QtcAgainClearsLine;
|
||||
}
|
||||
|
||||
private void OnSave(object? sender, RoutedEventArgs e) => Close(settings with
|
||||
{
|
||||
QtcLinesPerSeries = int.TryParse(CountBox.Text, out int count)
|
||||
? Math.Clamp(count, 1, 10)
|
||||
: settings.QtcLinesPerSeries,
|
||||
QtcSkipReady = SkipReadyBox.IsChecked == true,
|
||||
QtcSkipConfirm = SkipConfirmBox.IsChecked == true,
|
||||
QtcHeaderAgainClears = HeaderAgainClearsBox.IsChecked == true,
|
||||
QtcAgainClearsLine = AgainClearsBox.IsChecked == true,
|
||||
});
|
||||
|
||||
private void OnCancel(object? sender, RoutedEventArgs e) => Close(null);
|
||||
}
|
||||
@@ -3,14 +3,21 @@
|
||||
x:Class="Nonemm.App.Windows.QtcWindow"
|
||||
Title="QTC" SizeToContent="WidthAndHeight" CanResize="False"
|
||||
WindowStartupLocation="CenterOwner">
|
||||
<StackPanel Margin="10" Spacing="4">
|
||||
<!-- the background is what makes the panel hit-testable, so the right-click
|
||||
menu comes up over the whole window rather than only over a control -->
|
||||
<StackPanel Margin="10" Spacing="4" Background="Transparent">
|
||||
<StackPanel.ContextMenu>
|
||||
<ContextMenu>
|
||||
<MenuItem Header="Setup…" Click="OnSetup" />
|
||||
</ContextMenu>
|
||||
</StackPanel.ContextMenu>
|
||||
<StackPanel Name="DirectionPanel" Orientation="Horizontal" Spacing="8" Margin="0,0,0,4">
|
||||
<RadioButton Name="ReceiveButton" Content="Receive" GroupName="direction" IsChecked="True" />
|
||||
<RadioButton Name="SendButton" Content="Send" GroupName="direction" />
|
||||
</StackPanel>
|
||||
<TextBlock Text="QTC Header :" FontSize="11" Opacity="0.7" />
|
||||
<StackPanel Orientation="Horizontal" Spacing="4">
|
||||
<TextBox Name="HeaderBox" Width="110" />
|
||||
<TextBox Name="HeaderBox" Width="170" />
|
||||
<Button Name="ReadyButton" Content="RX Ready" Click="OnReady" />
|
||||
<Button Name="HeaderAgainButton" Content="Hdr Agn" Click="OnHeaderAgain" />
|
||||
<Button Name="HeaderCfmButton" Content="Cfm" Click="OnHeaderConfirm" />
|
||||
|
||||
@@ -2,6 +2,8 @@ using Avalonia.Controls;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Media;
|
||||
using Nonemm.App.Configuration;
|
||||
using Nonemm.App.Dialogs;
|
||||
using Nonemm.Contests.Rules;
|
||||
using Nonemm.Core;
|
||||
using Nonemm.Session;
|
||||
@@ -53,9 +55,12 @@ public sealed partial class QtcWindow : Window
|
||||
Opened += (_, _) => FirstBox().Focus();
|
||||
}
|
||||
|
||||
/// Where the cursor goes: the header when it has to be typed, the first
|
||||
/// line when it is already filled in.
|
||||
private TextBox FirstBox() => isSending ? rows[0].Time : HeaderBox;
|
||||
/// Where the cursor goes: RX Ready when the operator wants that step, the
|
||||
/// header when it has to be typed, the first line when it is filled in.
|
||||
private Control FirstBox() =>
|
||||
isSending ? rows[0].Time
|
||||
: session.Settings.QtcSkipReady ? HeaderBox
|
||||
: ReadyButton;
|
||||
|
||||
private void SetDirection(bool sending)
|
||||
{
|
||||
@@ -105,6 +110,8 @@ public sealed partial class QtcWindow : Window
|
||||
int line = at;
|
||||
again.Click += (_, _) => OnLineAgain(line);
|
||||
confirm.Click += (_, _) => OnLineConfirm(line);
|
||||
// nothing to confirm when a RTTY station is reading its own log out
|
||||
confirm.IsVisible = !(isSending && position.Contest.Modes.Contains(ModeCategory.Digital));
|
||||
Grid.SetRow(again, at);
|
||||
Grid.SetColumn(again, 3);
|
||||
Grid.SetRow(confirm, at);
|
||||
@@ -145,7 +152,7 @@ public sealed partial class QtcWindow : Window
|
||||
Paint();
|
||||
return;
|
||||
}
|
||||
ready.AddRange(traffic.ToSend(station));
|
||||
ready.AddRange(traffic.ToSend(station, session.Settings.QtcLinesPerSeries));
|
||||
// the contest is what makes it RTTY, not whatever the radio is on now
|
||||
bool rtty = position.Contest.Modes.Contains(ModeCategory.Digital);
|
||||
HeaderBox.Text = ready.Count == 0
|
||||
@@ -225,7 +232,17 @@ public sealed partial class QtcWindow : Window
|
||||
|
||||
private void MoveOn()
|
||||
{
|
||||
List<TextBox> order = [HeaderBox, .. rows.SelectMany(r => new[] { r.Time, r.Call, r.Number })];
|
||||
List<Control> order = [HeaderBox];
|
||||
foreach (Row row in rows)
|
||||
{
|
||||
order.Add(row.Time);
|
||||
order.Add(row.Call);
|
||||
order.Add(row.Number);
|
||||
if (!session.Settings.QtcSkipConfirm && row.Confirm.IsVisible)
|
||||
{
|
||||
order.Add(row.Confirm);
|
||||
}
|
||||
}
|
||||
int at = order.FindIndex(b => b.IsFocused);
|
||||
if (at < 0)
|
||||
{
|
||||
@@ -248,7 +265,10 @@ public sealed partial class QtcWindow : Window
|
||||
|
||||
private void OnHeaderAgain(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
HeaderBox.Text = "";
|
||||
if (session.Settings.QtcHeaderAgainClears)
|
||||
{
|
||||
HeaderBox.Text = "";
|
||||
}
|
||||
HeaderBox.Focus();
|
||||
}
|
||||
|
||||
@@ -263,7 +283,10 @@ public sealed partial class QtcWindow : Window
|
||||
rows[at].Time.Focus();
|
||||
return;
|
||||
}
|
||||
rows[at].Clear();
|
||||
if (session.Settings.QtcAgainClearsLine)
|
||||
{
|
||||
rows[at].Clear();
|
||||
}
|
||||
rows[at].Time.Focus();
|
||||
Paint();
|
||||
}
|
||||
@@ -307,6 +330,17 @@ public sealed partial class QtcWindow : Window
|
||||
|
||||
private void OnCancel(object? sender, RoutedEventArgs e) => Close(false);
|
||||
|
||||
private async void OnSetup(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
QtcSetupDialog dialog = new(session.Settings);
|
||||
if (await dialog.ShowDialog<Settings?>(this) is { } updated)
|
||||
{
|
||||
session.Save(updated);
|
||||
Reset();
|
||||
FirstBox().Focus();
|
||||
}
|
||||
}
|
||||
|
||||
/// One row per line, a second apart, so they keep their order in the log.
|
||||
/// That is what N1MM does with them too.
|
||||
private void Save(IReadOnlyList<WaeQtc> lines)
|
||||
|
||||
@@ -100,11 +100,12 @@ public sealed class QtcTraffic
|
||||
}
|
||||
|
||||
/// The contacts to report to this station: the ones not reported to anybody
|
||||
/// yet, oldest first, and never the station itself. Ten at a time, fewer
|
||||
/// when it has already had some.
|
||||
public IReadOnlyList<WaeQtc> ToSend(Callsign other)
|
||||
/// yet, oldest first, and never the station itself. Ten at a time unless
|
||||
/// the operator asks for a shorter series, and fewer when the station has
|
||||
/// already had some.
|
||||
public IReadOnlyList<WaeQtc> ToSend(Callsign other, int mostPerSeries = WaeQtc.MostPerSeries)
|
||||
{
|
||||
int room = Math.Min(WaeQtc.MostPerSeries, Remaining(other));
|
||||
int room = Math.Min(Math.Clamp(mostPerSeries, 1, WaeQtc.MostPerSeries), Remaining(other));
|
||||
if (room <= 0)
|
||||
{
|
||||
return [];
|
||||
|
||||
Reference in New Issue
Block a user