FIX: Main window loses focus after confirming file/folder deletion (fixes #2160) (#2760)

This commit is contained in:
Raman Sinclair 2026-02-21 10:38:55 +01:00 committed by GitHub
commit 3f9e3d35a4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 11 additions and 7 deletions

1
.gitignore vendored
View file

@ -16,6 +16,7 @@
*.w?x
units/
/doublecmd
tools/extractdwrflnfo
# Lazarus autogenerated files (duplicated info)
*.rst

View file

@ -21,17 +21,17 @@ type
{ public declarations }
end;
function ShowDeleteDialog(const Message: String; FileSource: IFileSource; out QueueId: TOperationsManagerQueueIdentifier): Boolean;
function ShowDeleteDialog(TheOwner: TComponent; const Message: String; FileSource: IFileSource; out QueueId: TOperationsManagerQueueIdentifier): Boolean;
implementation
uses
LCLType;
function ShowDeleteDialog(const Message: String; FileSource: IFileSource;
function ShowDeleteDialog(TheOwner: TComponent; const Message: String; FileSource: IFileSource;
out QueueId: TOperationsManagerQueueIdentifier): Boolean;
begin
with TfrmDeleteDlg.Create(Application, FileSource) do
with TfrmDeleteDlg.Create(TheOwner, FileSource) do
begin
Caption:= Application.Title;
lblMessage.Caption:= Message;

View file

@ -1411,7 +1411,7 @@ begin
bConfirmation := focTestArchive in gFileOperationsConfirmations;
end;
if (bConfirmation = False) or (ShowDeleteDialog(rsMsgTestArchive, ActiveFrame.FileSource, QueueId)) then
if (bConfirmation = False) or (ShowDeleteDialog(frmMain, rsMsgTestArchive, ActiveFrame.FileSource, QueueId)) then
begin
SelectedFiles := ActiveFrame.CloneSelectedOrActiveFiles;
try
@ -1709,7 +1709,7 @@ begin
Exit;
Message:= frmMain.GetFileDlgStr(rsMsgWipeSel, rsMsgWipeFlDr, theFilesToWipe);
if not ShowDeleteDialog(Message, FileSource, QueueId) then
if not ShowDeleteDialog(frmMain, Message, FileSource, QueueId) then
Exit;
Operation := FileSource.CreateWipeOperation(theFilesToWipe);
@ -2683,8 +2683,11 @@ begin
end;
if theFilesToDelete.Count > 5 then Message+= LineEnding + '...';
end;
if (bConfirmation = False) or (ShowDeleteDialog(Message, FileSource, QueueId)) then
if (bConfirmation = False) or (ShowDeleteDialog(frmMain, Message, FileSource, QueueId)) then
begin
// Restore focus to main window after confirmation dialog closes
if frmMain.ActiveFrame.CanFocus then
frmMain.ActiveFrame.SetFocus;
if FileSource.IsClass(TFileSystemFileSource) then
begin
if frmMain.NotActiveFrame.FileSource.IsClass(TFileSystemFileSource) then
@ -2882,7 +2885,7 @@ begin
end;
end;
if (bConfirmation = False) or (ShowDeleteDialog(rsMsgVerifyChecksum, ActiveFrame.FileSource, QueueId)) then
if (bConfirmation = False) or (ShowDeleteDialog(frmMain, rsMsgVerifyChecksum, ActiveFrame.FileSource, QueueId)) then
begin
Operation := ActiveFrame.FileSource.CreateCalcChecksumOperation(
SelectedFiles, Hash, '') as TFileSourceCalcChecksumOperation;