mirror of
https://git.vladimir.cc/vladimir/ewsdr.git
synced 2026-08-25 20:37:33 +00:00
fix connect
This commit is contained in:
+9
-1
@@ -105,7 +105,8 @@ type
|
|||||||
function GetAutoStartBoardType: Integer;
|
function GetAutoStartBoardType: Integer;
|
||||||
function GetSavedBoardType(Idx: Integer): Integer;
|
function GetSavedBoardType(Idx: Integer): Integer;
|
||||||
|
|
||||||
// Получить результат
|
// Получить/сбросить результат
|
||||||
|
procedure ClearResult;
|
||||||
property DialogResult: TDeviceDialogResult read FResult;
|
property DialogResult: TDeviceDialogResult read FResult;
|
||||||
property OnDiscover: TNotifyEvent read FOnDiscover write FOnDiscover;
|
property OnDiscover: TNotifyEvent read FOnDiscover write FOnDiscover;
|
||||||
property SavedCount: Integer read FSavedCount;
|
property SavedCount: Integer read FSavedCount;
|
||||||
@@ -596,6 +597,13 @@ begin
|
|||||||
ModalResult := mrCancel;
|
ModalResult := mrCancel;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TDeviceDialog.ClearResult;
|
||||||
|
begin
|
||||||
|
FResult.Accepted := False;
|
||||||
|
FResult.IPAddress := '';
|
||||||
|
FResult.SavedIdx := -1;
|
||||||
|
end;
|
||||||
|
|
||||||
function TDeviceDialog.GetAutoStartIP: string;
|
function TDeviceDialog.GetAutoStartIP: string;
|
||||||
var
|
var
|
||||||
I: Integer;
|
I: Integer;
|
||||||
|
|||||||
+16
-1
@@ -3285,8 +3285,10 @@ begin
|
|||||||
FDeviceDialog.OnDiscover := BtnDiscoverFromDialog;
|
FDeviceDialog.OnDiscover := BtnDiscoverFromDialog;
|
||||||
if FLightTheme then FDeviceDialog.SetTheme(LightTheme)
|
if FLightTheme then FDeviceDialog.SetTheme(LightTheme)
|
||||||
else FDeviceDialog.SetTheme(DarkTheme);
|
else FDeviceDialog.SetTheme(DarkTheme);
|
||||||
|
FDeviceDialog.ClearResult; // сбрасываем старый выбор перед открытием
|
||||||
FDeviceDialog.ShowModal;
|
FDeviceDialog.ShowModal;
|
||||||
// Результат диалога не обрабатываем здесь — START сам спросит если нужно
|
// Если пользователь нажал CONNECT — результат хранится в DialogResult,
|
||||||
|
// START его заберёт и использует с приоритетом над autostart
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TMainForm.BtnDiscoverFromDialog(Sender: TObject);
|
procedure TMainForm.BtnDiscoverFromDialog(Sender: TObject);
|
||||||
@@ -3350,6 +3352,17 @@ begin
|
|||||||
// --- START ---
|
// --- START ---
|
||||||
AutoIP := '';
|
AutoIP := '';
|
||||||
FPendingBoardType := 0;
|
FPendingBoardType := 0;
|
||||||
|
|
||||||
|
// Явный выбор через CONNECT в диалоге имеет приоритет над autostart
|
||||||
|
if Assigned(FDeviceDialog) and FDeviceDialog.DialogResult.Accepted then
|
||||||
|
begin
|
||||||
|
FPendingIP := FDeviceDialog.DialogResult.IPAddress;
|
||||||
|
FPendingBoardType := FDeviceDialog.GetSavedBoardType(
|
||||||
|
FDeviceDialog.DialogResult.SavedIdx);
|
||||||
|
FDeviceDialog.ClearResult; // consumed — следующий START снова спросит
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
if Assigned(FDeviceDialog) then
|
if Assigned(FDeviceDialog) then
|
||||||
AutoIP := FDeviceDialog.GetAutoStartIP;
|
AutoIP := FDeviceDialog.GetAutoStartIP;
|
||||||
|
|
||||||
@@ -3370,6 +3383,8 @@ begin
|
|||||||
FPendingIP := FDeviceDialog.DialogResult.IPAddress;
|
FPendingIP := FDeviceDialog.DialogResult.IPAddress;
|
||||||
FPendingBoardType := FDeviceDialog.GetSavedBoardType(
|
FPendingBoardType := FDeviceDialog.GetSavedBoardType(
|
||||||
FDeviceDialog.DialogResult.SavedIdx);
|
FDeviceDialog.DialogResult.SavedIdx);
|
||||||
|
FDeviceDialog.ClearResult;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// Создаём запись устройства из IP + BoardType из диалога если есть
|
// Создаём запись устройства из IP + BoardType из диалога если есть
|
||||||
|
|||||||
Reference in New Issue
Block a user