ADD: Find files - select drives button

This commit is contained in:
Alexander Koblov 2026-03-24 20:14:19 +03:00
commit 56dea7477d
5 changed files with 94 additions and 8 deletions

View file

@ -87,7 +87,7 @@ object frmFindDlg: TfrmFindDlg
Width = 104
Anchors = [akTop, akRight]
Caption = 'Follow s&ymlinks'
TabOrder = 0
TabOrder = 2
end
object cmbFindPathStart: TComboBoxWithDelItems
AnchorSideLeft.Control = lblFindPathStart
@ -101,12 +101,12 @@ object frmFindDlg: TfrmFindDlg
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Right = 2
ItemHeight = 15
TabOrder = 1
TabOrder = 3
end
object btnChooseFolder: TSpeedButton
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = cmbFindPathStart
AnchorSideRight.Side = asrBottom
AnchorSideRight.Control = btnDrives
AnchorSideBottom.Control = cmbFindPathStart
AnchorSideBottom.Side = asrBottom
Left = 714
@ -114,8 +114,25 @@ object frmFindDlg: TfrmFindDlg
Top = 19
Width = 23
Anchors = [akTop, akRight, akBottom]
BorderSpacing.Right = 6
OnClick = btnSelDirClick
end
object btnDrives: TButton
AnchorSideTop.Control = cmbFindPathStart
AnchorSideRight.Control = gbDirectories
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = cmbFindPathStart
AnchorSideBottom.Side = asrBottom
Left = 786
Height = 26
Top = 24
Width = 52
Anchors = [akTop, akRight, akBottom]
AutoSize = True
Caption = 'Drives'
TabOrder = 4
OnClick = btnDrivesClick
end
object lblExcludeDirectories: TLabel
AnchorSideLeft.Control = cmbFindPathStart
AnchorSideTop.Control = cmbFindPathStart
@ -145,7 +162,7 @@ object frmFindDlg: TfrmFindDlg
ItemHeight = 15
ParentShowHint = False
ShowHint = True
TabOrder = 2
TabOrder = 5
end
object pnlDirectoriesDepth: TPanel
AnchorSideTop.Control = lblExcludeDirectories
@ -162,7 +179,7 @@ object frmFindDlg: TfrmFindDlg
ChildSizing.ControlsPerLine = 1
ClientHeight = 51
ClientWidth = 200
TabOrder = 3
TabOrder = 6
object lblSearchDepth: TLabel
Left = 0
Height = 15
@ -195,7 +212,7 @@ object frmFindDlg: TfrmFindDlg
BorderSpacing.Right = 6
Caption = 'Selected directories and files'
OnChange = cbSelectedFilesChange
TabOrder = 4
TabOrder = 1
end
object cbOpenedTabs: TCheckBox
AnchorSideRight.Control = cbSelectedFiles
@ -209,7 +226,7 @@ object frmFindDlg: TfrmFindDlg
BorderSpacing.Right = 6
Caption = 'Opened tabs'
OnChange = cbOpenedTabsChange
TabOrder = 5
TabOrder = 0
end
end
object gbFiles: TGroupBox

View file

@ -9,6 +9,7 @@
{"hash":201746570,"name":"tfrmfinddlg.lblsearchdepth.caption","sourcebytes":[83,101,97,114,99,104,32,115,117,38,98,100,105,114,101,99,116,111,114,105,101,115,58],"value":"Search su&bdirectories:"},
{"hash":238646947,"name":"tfrmfinddlg.cbselectedfiles.caption","sourcebytes":[83,101,108,101,99,116,101,100,32,100,105,114,101,99,116,111,114,105,101,115,32,97,110,100,32,102,105,108,101,115],"value":"Selected directories and files"},
{"hash":187812819,"name":"tfrmfinddlg.cbopenedtabs.caption","sourcebytes":[79,112,101,110,101,100,32,116,97,98,115],"value":"Opened tabs"},
{"hash":79236291,"name":"tfrmfinddlg.btndrives.caption","sourcebytes":[68,114,105,118,101,115],"value":"Drives"},
{"hash":5046979,"name":"tfrmfinddlg.gbfiles.caption","sourcebytes":[70,105,108,101,115],"value":"Files"},
{"hash":41260443,"name":"tfrmfinddlg.lblfindfilemask.caption","sourcebytes":[38,70,105,108,101,32,109,97,115,107],"value":"&File mask"},
{"hash":181442290,"name":"tfrmfinddlg.cmbfindfilemask.hint","sourcebytes":[69,110,116,101,114,32,102,105,108,101,115,32,110,97,109,101,115,32,115,101,112,97,114,97,116,101,100,32,119,105,116,104,32,34,59,34],"value":"Enter files names separated with \";\""},

View file

@ -83,6 +83,7 @@ type
btnView: TButton;
btnEdit: TButton;
btnWorkWithFound: TButton;
btnDrives: TButton;
cbFindText: TCheckBox;
cbNotContainingText: TCheckBox;
cbDateFrom: TCheckBox;
@ -204,6 +205,7 @@ type
procedure actExecute(Sender: TObject);
procedure btnAddAttributeClick(Sender: TObject);
procedure btnAttrsHelpClick(Sender: TObject);
procedure btnDrivesClick(Sender: TObject);
procedure btnEncodingClick(Sender: TObject);
procedure btnNewSearchKeyDown(Sender: TObject; var Key: word;
{%H-}Shift: TShiftState);
@ -407,7 +409,7 @@ uses
uColumns, uFileFunctions, uFileSorting,
DCConvertEncoding, WcxPlugin, fChooseEncoding, dmCommonData,
uLocalFileSource, uWcxArchiveFileSource, uSearchResultFileSource,
uFileSourceUtil, uArchiveFileSourceUtil
uFileSourceUtil, uArchiveFileSourceUtil, uDriveWatcher
{$IFDEF DARkWIN}
, uDarkStyle
{$ENDIF}
@ -807,6 +809,7 @@ begin
cbFollowSymLinks.Visible := False;
cbSelectedFiles.Visible := False;
cbOpenedTabs.Visible := False;
btnDrives.Visible := False;
btnStart.Visible := False;
btnStop.Visible := False;
btnNewSearch.Visible := False;
@ -968,6 +971,24 @@ begin
ShowHelpOrErrorForKeyword('', edtAttrib.HelpKeyword);
end;
procedure TfrmFindDlg.btnDrivesClick(Sender: TObject);
var
Drives, Selected: TStringList;
begin
Selected:= TStringList.Create;
Drives:= TDriveWatcher.GetUniquePaths;
if ShowInputMultiSelectListBox(rsFindSelectDrives, EmptyStr, Drives, Selected) then
begin
if (Selected.Count > 0) then
begin
Selected.Delimiter:= ';';
cmbFindPathStart.Text:= Selected.DelimitedText;
end;
end;
Selected.Free;
Drives.Free;
end;
procedure TfrmFindDlg.btnEncodingClick(Sender: TObject);
var
I, Index, ACount: Integer;
@ -1078,6 +1099,7 @@ begin
cbSelectedFiles.Enabled := not cbOpenedTabs.Checked AND (FSelectedFiles.Count > 0);
cbFollowSymLinks.Enabled := not cbOpenedTabs.Checked;
cmbFindPathStart.Enabled := not cbOpenedTabs.Checked;
btnDrives.Enabled := cmbFindPathStart.Enabled;
end;
{ TfrmFindDlg.cbPartialNameSearchChange }
@ -1102,6 +1124,7 @@ end;
procedure TfrmFindDlg.cbSelectedFilesChange(Sender: TObject);
begin
cmbFindPathStart.Enabled := not cbSelectedFiles.Checked;
btnDrives.Enabled := cmbFindPathStart.Enabled;
end;
procedure TfrmFindDlg.chkDuplicateContentChange(Sender: TObject);
@ -1505,6 +1528,7 @@ begin
cbFindInArchive.Enabled:= not AEnabled;
cbReplaceText.Enabled:= (not AEnabled) and (cbFindText.Checked);
cmbFindPathStart.Enabled:= not AEnabled;
btnDrives.Enabled := not AEnabled;
btnChooseFolder.Enabled:= not AEnabled;
chkDuplicates.Enabled:= not AEnabled;
cmbSearchDepth.Enabled:= not AEnabled;

View file

@ -45,12 +45,15 @@ type
TDriveWatcherObserverList = specialize TFPGList<TDriveWatcherEventNotify>;
{ TDriveWatcher }
TDriveWatcher = class
class procedure Initialize(Handle: HWND);
class procedure Finalize;
class procedure AddObserver(Func: TDriveWatcherEventNotify);
class procedure RemoveObserver(Func: TDriveWatcherEventNotify);
class function GetDrivesList: TDrivesList;
class function GetUniquePaths: TStringList;
end;
implementation
@ -1521,6 +1524,46 @@ begin
end;
{$ENDIF}
class function TDriveWatcher.GetUniquePaths: TStringList;
var
I: Integer;
{$IFDEF UNIX}
J: Integer;
APath: String;
{$ENDIF}
ADrive: PDrive;
Drives: TDrivesList;
begin
Drives:= GetDrivesList;
Result:= TStringList.Create;
for I:= 0 to Drives.Count - 1 do
begin
ADrive:= Drives[I];
if (ADrive^.IsMounted) and (ADrive^.DriveType <> dtSpecial) and
(Length(ADrive^.Path) > 0) and (ADrive^.Path <> PathDelim) then
begin
Result.Add(ADrive^.Path);
end;
end;
Drives.Free;
{$IF DEFINED(UNIX)}
// Remove a sub-drives
for I:= Result.Count - 1 downto 0 do
begin
APath:= Result[I];
for J:= Result.Count - 1 downto 0 do
begin
if IsInPath(Result[J], APath, True, False) then
begin
Result.Delete(I);
Break;
end;
end;
end;
{$ENDIF}
end;
{$IFDEF LINUX}
procedure TFakeClass.OnMountWatcherNotify(Sender: TObject);
var

View file

@ -620,6 +620,7 @@ resourcestring
rsFindDepthAll = 'all (unlimited depth)';
rsFindDepthCurDir = 'current dir only';
rsFindDepth = '%s level(s)';
rsFindSelectDrives = 'Select drives';
rsFindSaveTemplateCaption = 'Save search template';
rsFindSaveTemplateTitle = 'Template name:';
rsSearchTemplateUnnamed = '<unnamed template>';