Phase 3 (batch 9): route FM repeater shift through controller commands

FM Rpt is the first FM-Rpt heavy-class item (XvtrTranslate/ActiveTXFreqHz
blocker already lifted in d895800). Following the established pattern:

- TRadioController.SetFMRpt(Dir): explicit direction, clears auto-active,
  pushes network state; rendered via OnControllerState(rfFMRpt).
- SetFMRptOffset(Hz): updates offset, re-pushes when RPT engaged.
- UpdateRptAutoState: 2 m auto-MINUS logic moved into controller, fires
  Changed(rfFMRpt) instead of inline StyleButton.
- Extracted private PushNetworkState helper (full HP frame); SetCTun now
  reuses it (dedupes the UpdateState+SendFullHP block).

MainForm: Btn/EdFMRpt handlers are thin wrappers (toggle decision +
SaveCurrentBand stay in UI); UpdateRptAutoState delegates to controller;
ApplyFMRpt removed. OnControllerState(rfFMRpt) restyles both buttons and
sets the offset edit text only when unfocused (avoids disrupting typing).
Direct FFMRptDir writes in band/channel/xvtr restore paths left as-is
(migrate with their own commands later). Builds clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Uladzimir Karpenka
2026-06-04 19:56:56 +03:00
co-authored by Claude Opus 4.8
parent f12d2a69ad
commit 967e7cb7b1
2 changed files with 83 additions and 71 deletions
+28 -63
View File
@@ -433,7 +433,6 @@ type
procedure BtnFMRptMinusClick(Sender: TObject);
procedure BtnFMRptPlusClick(Sender: TObject);
procedure EdFMRptOffsetChange(Sender: TObject);
procedure ApplyFMRpt;
procedure UpdateRptAutoState;
procedure SetFMStep(Idx: Integer);
procedure CloseFMStepPopup;
@@ -1468,6 +1467,22 @@ begin
end;
rfFMCTCSSTone:
if FCTCSSDropDown <> nil then FCTCSSDropDown.SetItemIndex(FController.FFMCTCSSToneIdx);
rfFMRpt:
begin
if BtnFMRptMinus <> nil then
begin
StyleButton(BtnFMRptMinus, FController.FFMRptDir = RPT_MINUS);
BtnFMRptMinus.Repaint;
end;
if BtnFMRptPlus <> nil then
begin
StyleButton(BtnFMRptPlus, FController.FFMRptDir = RPT_PLUS);
BtnFMRptPlus.Repaint;
end;
// Текст оффсета не трогаем, пока пользователь печатает в поле.
if (EdFMRptOffset <> nil) and not EdFMRptOffset.Focused then
EdFMRptOffset.Text := RptFormatOffset(FController.FFMRptOffsetHz);
end;
end;
finally
FSyncingFromController := False;
@@ -5241,91 +5256,41 @@ end;
procedure TMainForm.BtnFMRptMinusClick(Sender: TObject);
begin
if FSyncingFromController then Exit;
// Toggle решает UI; команда несёт сетевой сдвиг + рендер кнопок (OnControllerState).
if FController.FFMRptDir = RPT_MINUS then
FController.FFMRptDir := RPT_NONE
FController.SetFMRpt(RPT_NONE)
else
FController.FFMRptDir := RPT_MINUS;
FController.FFMRptAutoActive := False; // ручное действие снимает авто-флаг
StyleButton(BtnFMRptMinus, FController.FFMRptDir = RPT_MINUS);
StyleButton(BtnFMRptPlus, FController.FFMRptDir = RPT_PLUS);
BtnFMRptMinus.Repaint;
BtnFMRptPlus.Repaint;
ApplyFMRpt;
FController.SetFMRpt(RPT_MINUS);
SaveCurrentBand;
end;
procedure TMainForm.BtnFMRptPlusClick(Sender: TObject);
begin
if FSyncingFromController then Exit;
if FController.FFMRptDir = RPT_PLUS then
FController.FFMRptDir := RPT_NONE
FController.SetFMRpt(RPT_NONE)
else
FController.FFMRptDir := RPT_PLUS;
FController.FFMRptAutoActive := False; // ручное действие снимает авто-флаг
StyleButton(BtnFMRptMinus, FController.FFMRptDir = RPT_MINUS);
StyleButton(BtnFMRptPlus, FController.FFMRptDir = RPT_PLUS);
BtnFMRptMinus.Repaint;
BtnFMRptPlus.Repaint;
ApplyFMRpt;
FController.SetFMRpt(RPT_PLUS);
SaveCurrentBand;
end;
procedure TMainForm.EdFMRptOffsetChange(Sender: TObject);
var Hz: Double;
begin
if FSyncingFromController then Exit;
Hz := RptParseOffset(EdFMRptOffset.Text);
if Hz > 0.0 then
begin
FController.FFMRptOffsetHz := Hz;
if FController.FFMRptDir <> RPT_NONE then
begin
ApplyFMRpt;
SaveCurrentBand;
end;
end;
end;
procedure TMainForm.ApplyFMRpt;
begin
if FController.FNetwork.Connected and FController.FNetwork.Running then
begin
FController.FNetwork.UpdateState(XvtrTranslate(FController.FCenterFreq), XvtrTranslate(ActiveTXFreqHz),
FController.FDriveLevel, FController.FTransmitting, True, True);
FController.FNetwork.SendFullHP;
FController.SetFMRptOffset(Hz); // применяет, если RPT вкл; OnControllerState
if FController.FFMRptDir <> RPT_NONE then SaveCurrentBand;
end;
end;
procedure TMainForm.UpdateRptAutoState;
var InRange: Boolean;
begin
InRange := RptAutoDir(FController.FVfoA) = RPT_MINUS;
if InRange then
begin
// Auto-enable minus only when currently off.
if FController.FFMRptDir = RPT_NONE then
begin
FController.FFMRptDir := RPT_MINUS;
FController.FFMRptAutoActive := True;
if BtnFMRptMinus <> nil then
begin
StyleButton(BtnFMRptMinus, True);
BtnFMRptMinus.Repaint;
end;
end;
end
else
begin
// Auto-disable only if this minus was set automatically.
if (FController.FFMRptDir = RPT_MINUS) and FController.FFMRptAutoActive then
begin
FController.FFMRptDir := RPT_NONE;
FController.FFMRptAutoActive := False;
if BtnFMRptMinus <> nil then
begin
StyleButton(BtnFMRptMinus, False);
BtnFMRptMinus.Repaint;
end;
end;
end;
// Логика авто-MINUS — в контроллере; рендер кнопок — OnControllerState(rfFMRpt).
FController.UpdateRptAutoState;
end;
procedure TMainForm.CloseFMStepPopup;