Qt: qtdialogs - return focus to last active window, fixes #16535

git-svn-id: trunk@25613 -
This commit is contained in:
zeljko 2010-05-24 16:34:13 +00:00
parent f31baf8b4e
commit 8f5c37c13b

View File

@ -110,7 +110,7 @@ type
implementation
uses qtint;
const
QtDialogCodeToModalResultMap: array[QDialogDialogCode] of TModalResult =
(
@ -125,6 +125,9 @@ begin
if ACommonDialog.Owner is TWinControl then
Result := TQtWidget(TWinControl(ACommonDialog.Owner).Handle).Widget
else
if (QtWidgetSet.GetActiveWindow <> 0) then
Result := TQtWidget(QtWidgetSet.GetActiveWindow).Widget
else
if Assigned(Application.MainForm) and Application.MainForm.Visible then
Result := TQtWidget(Application.MainForm.Handle).Widget
else
@ -350,6 +353,7 @@ var
selectedFilter, saveFileName, saveFilter, saveTitle: WideString;
Flags: Cardinal;
{$endif}
ActiveWin: HWND;
begin
{------------------------------------------------------------------------------
Initialization of variables
@ -373,6 +377,7 @@ begin
if ACommonDialog is TSelectDirectoryDialog then
QtFileDialog.setFileMode(QFileDialogDirectoryOnly);
ActiveWin := QtWidgetSet.GetActiveWindow;
if ACommonDialog is TSaveDialog then
begin
{$ifdef QT_NATIVE_DIALOGS}
@ -482,6 +487,11 @@ begin
end;
{$endif}
end;
if ActiveWin <> 0 then
begin
if QtWidgetSet.IsValidHandle(ActiveWin) then
QtWidgetSet.SetActiveWindow(ActiveWin);
end;
end;
{ TQtWSSelectDirectoryDialog }