fix connect

This commit is contained in:
2026-05-11 18:57:26 +03:00
parent 604fd836ba
commit ec596bb0c8
2 changed files with 40 additions and 17 deletions
+31 -16
View File
@@ -3285,8 +3285,10 @@ begin
FDeviceDialog.OnDiscover := BtnDiscoverFromDialog;
if FLightTheme then FDeviceDialog.SetTheme(LightTheme)
else FDeviceDialog.SetTheme(DarkTheme);
FDeviceDialog.ClearResult; // сбрасываем старый выбор перед открытием
FDeviceDialog.ShowModal;
// Результат диалога не обрабатываем здесь — START сам спросит если нужно
// Если пользователь нажал CONNECT — результат хранится в DialogResult,
// START его заберёт и использует с приоритетом над autostart
end;
procedure TMainForm.BtnDiscoverFromDialog(Sender: TObject);
@@ -3350,26 +3352,39 @@ begin
// --- START ---
AutoIP := '';
FPendingBoardType := 0;
if Assigned(FDeviceDialog) then
AutoIP := FDeviceDialog.GetAutoStartIP;
if AutoIP <> '' then
// Явный выбор через CONNECT в диалоге имеет приоритет над autostart
if Assigned(FDeviceDialog) and FDeviceDialog.DialogResult.Accepted then
begin
FPendingIP := AutoIP;
FPendingBoardType := FDeviceDialog.GetAutoStartBoardType;
FPendingIP := FDeviceDialog.DialogResult.IPAddress;
FPendingBoardType := FDeviceDialog.GetSavedBoardType(
FDeviceDialog.DialogResult.SavedIdx);
FDeviceDialog.ClearResult; // consumed — следующий START снова спросит
end
else
begin
if not Assigned(FDeviceDialog) then
FDeviceDialog := TDeviceDialog.Create(Self);
FDeviceDialog.OnDiscover := BtnDiscoverFromDialog;
if FLightTheme then FDeviceDialog.SetTheme(LightTheme)
else FDeviceDialog.SetTheme(DarkTheme);
if FDeviceDialog.ShowModal <> mrOk then Exit;
if not FDeviceDialog.DialogResult.Accepted then Exit;
FPendingIP := FDeviceDialog.DialogResult.IPAddress;
FPendingBoardType := FDeviceDialog.GetSavedBoardType(
FDeviceDialog.DialogResult.SavedIdx);
if Assigned(FDeviceDialog) then
AutoIP := FDeviceDialog.GetAutoStartIP;
if AutoIP <> '' then
begin
FPendingIP := AutoIP;
FPendingBoardType := FDeviceDialog.GetAutoStartBoardType;
end
else
begin
if not Assigned(FDeviceDialog) then
FDeviceDialog := TDeviceDialog.Create(Self);
FDeviceDialog.OnDiscover := BtnDiscoverFromDialog;
if FLightTheme then FDeviceDialog.SetTheme(LightTheme)
else FDeviceDialog.SetTheme(DarkTheme);
if FDeviceDialog.ShowModal <> mrOk then Exit;
if not FDeviceDialog.DialogResult.Accepted then Exit;
FPendingIP := FDeviceDialog.DialogResult.IPAddress;
FPendingBoardType := FDeviceDialog.GetSavedBoardType(
FDeviceDialog.DialogResult.SavedIdx);
FDeviceDialog.ClearResult;
end;
end;
// Создаём запись устройства из IP + BoardType из диалога если есть