fix(ui): show DMR status without replacing PLL

This commit is contained in:
2026-07-14 21:05:59 +03:00
parent 9f828f747f
commit 8b28986fec
2 changed files with 49 additions and 16 deletions
+35 -11
View File
@@ -13,8 +13,8 @@ uses
type
TMainStatusBar = class(TPanel)
private
FCells: array[0..7] of TPanel;
FLabels: array[0..7] of TLabel;
FCells: array[0..8] of TPanel;
FLabels: array[0..8] of TLabel;
procedure CreateStatusCell(Index: Integer; const Cap: string);
procedure LayoutCells;
protected
@@ -22,6 +22,7 @@ type
public
constructor Create(AOwner: TComponent); override;
procedure SetStatusText(Index: Integer; const Text: string);
procedure SetStatusVisible(Index: Integer; Visible: Boolean);
procedure ApplyTheme(const T: TAppTheme);
end;
@@ -32,11 +33,12 @@ const
GAP = 1;
PAD_X = 8;
SEQ_MIN_W = 90;
STATUS_ORDER: array[0..7] of Integer = (2, 0, 1, 3, 7, 4, 5, 6);
STATUS_ORDER: array[0..8] of Integer = (2, 0, 1, 3, 7, 8, 4, 5, 6);
// поле 7: PLL (openHPSDR) ИЛИ статус QO-100 beacon lock (Pluto) — шире под "BCN LOCK …".
// поле 8: динамический статус DMR; скрыт во всех остальных режимах.
// поле 3: Supply (HPSDR) ИЛИ две температуры Pluto "Temp 37/53C RSSI -89dB" — шире.
BASE_W: array[0..7] of Integer = (280, 160, 170, 190, 190, 180, 130, 200);
INITIAL_TEXT: array[0..7] of string = (
BASE_W: array[0..8] of Integer = (280, 160, 170, 190, 190, 180, 130, 200, 280);
INITIAL_TEXT: array[0..8] of string = (
'Board --',
'IP --',
'Disconnected',
@@ -44,7 +46,8 @@ const
'RX idle',
'TX idle',
'SEQ --',
'PLL --'
'PLL --',
''
);
constructor TMainStatusBar.Create(AOwner: TComponent);
@@ -58,6 +61,7 @@ begin
for I := Low(STATUS_ORDER) to High(STATUS_ORDER) do
CreateStatusCell(STATUS_ORDER[I], INITIAL_TEXT[STATUS_ORDER[I]]);
FCells[8].Visible := False;
LayoutCells;
end;
@@ -87,6 +91,7 @@ end;
procedure TMainStatusBar.LayoutCells;
var
PPI, X, I, Idx, W, H, G, Pad, FixedNatural, FixedAvail: Integer;
VisibleCount, FixedCount: Integer;
function S(Value: Integer): Integer;
begin
@@ -103,7 +108,7 @@ var
else if FixedAvail < FixedNatural then
begin
Result := (Int64(Result) * FixedAvail + FixedNatural div 2) div FixedNatural;
if FixedAvail >= S(48) * 7 then
if FixedAvail >= S(48) * FixedCount then
Result := Max(S(48), Result);
end;
end;
@@ -119,15 +124,26 @@ begin
H := Max(1, ClientHeight - G * 2);
FixedNatural := 0;
for I := Low(STATUS_ORDER) to High(STATUS_ORDER) - 1 do
Inc(FixedNatural, S(BASE_W[STATUS_ORDER[I]]));
FixedAvail := ClientWidth - S(SEQ_MIN_W) - G * 8;
FixedCount := 0;
VisibleCount := 0;
for I := Low(STATUS_ORDER) to High(STATUS_ORDER) do
begin
Idx := STATUS_ORDER[I];
if (FCells[Idx] = nil) or (not FCells[Idx].Visible) then Continue;
Inc(VisibleCount);
if Idx <> 6 then
begin
Inc(FixedNatural, S(BASE_W[Idx]));
Inc(FixedCount);
end;
end;
FixedAvail := ClientWidth - S(SEQ_MIN_W) - G * VisibleCount;
X := 0;
for I := Low(STATUS_ORDER) to High(STATUS_ORDER) do
begin
Idx := STATUS_ORDER[I];
if FCells[Idx] = nil then Continue;
if (FCells[Idx] = nil) or (not FCells[Idx].Visible) then Continue;
Inc(X, G);
if Idx = 6 then
@@ -159,6 +175,14 @@ begin
FLabels[Index].Caption := Text;
end;
procedure TMainStatusBar.SetStatusVisible(Index: Integer; Visible: Boolean);
begin
if (Index < Low(FCells)) or (Index > High(FCells)) then Exit;
if (FCells[Index] = nil) or (FCells[Index].Visible = Visible) then Exit;
FCells[Index].Visible := Visible;
LayoutCells;
end;
procedure TMainStatusBar.ApplyTheme(const T: TAppTheme);
var
I: Integer;