mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
ADD: Search in the options dialog (fixes #25)
This commit is contained in:
parent
5b532f960e
commit
7dde2b22f8
3 changed files with 714 additions and 1388 deletions
1990
src/foptions.lfm
1990
src/foptions.lfm
File diff suppressed because it is too large
Load diff
111
src/foptions.pas
111
src/foptions.pas
|
|
@ -30,8 +30,9 @@ unit fOptions;
|
|||
interface
|
||||
|
||||
uses
|
||||
ActnList, SysUtils, Classes, Controls, Forms, Dialogs, ExtCtrls, ComCtrls,
|
||||
Buttons, StdCtrls, KASButtonPanel, fgl, uGlobs, fOptionsFrame, uDCUtils;
|
||||
ActnList, SysUtils, Classes, Controls, Forms, Dialogs, ExtCtrls, ComCtrls,
|
||||
Buttons, StdCtrls, TreeFilterEdit, KASButtonPanel, fgl, uGlobs, fOptionsFrame,
|
||||
uDCUtils, EditBtn;
|
||||
|
||||
type
|
||||
|
||||
|
|
@ -58,6 +59,7 @@ type
|
|||
btnApply: TBitBtn;
|
||||
btnCancel: TBitBtn;
|
||||
sboxOptionsEditor: TScrollBox;
|
||||
TreeFilterEdit: TTreeFilterEdit;
|
||||
tvTreeView: TTreeView;
|
||||
splOptionsSplitter: TSplitter;
|
||||
alOptionsActionList: TActionList;
|
||||
|
|
@ -69,6 +71,9 @@ type
|
|||
procedure btnOKClick(Sender: TObject);
|
||||
procedure btnApplyClick(Sender: TObject);
|
||||
procedure FormDestroy(Sender: TObject);
|
||||
procedure splOptionsSplitterMoved(Sender: TObject);
|
||||
function TreeFilterEditFilterItem(ItemData: Pointer;
|
||||
out Done: Boolean): Boolean;
|
||||
procedure tvTreeViewChange(Sender: TObject; Node: TTreeNode);
|
||||
procedure actCloseWithEscapeExecute(Sender: TObject);
|
||||
private
|
||||
|
|
@ -101,18 +106,54 @@ implementation
|
|||
{$R *.lfm}
|
||||
|
||||
uses
|
||||
LCLProc, LCLVersion, uLng, fMain;
|
||||
LCLProc, LCLVersion, LazUTF8, LResources, Menus, Translations, Graphics,
|
||||
DCStrUtils, uTranslator, uLng, fMain;
|
||||
|
||||
var
|
||||
LastOpenedEditor: TOptionsEditorClass = nil;
|
||||
OptionsSearchCache: TList = nil;
|
||||
frmOptions: TfrmOptions = nil;
|
||||
|
||||
procedure CreateSearchCache;
|
||||
var
|
||||
POFile: TPOFile;
|
||||
|
||||
procedure FillCache(AList: TOptionsEditorClassList);
|
||||
var
|
||||
I, J: Integer;
|
||||
AClassName: String;
|
||||
PoFileItem: TPoFileItem;
|
||||
AEditor: TOptionsEditorRec;
|
||||
begin
|
||||
for I:= 0 to AList.Count - 1 do
|
||||
begin
|
||||
AEditor:= AList[I];
|
||||
AClassName:= LowerCase(AEditor.EditorClass.ClassName);
|
||||
|
||||
for J:= 0 to POFile.Count - 1 do
|
||||
begin
|
||||
PoFileItem:= POFile.PoItems[J];
|
||||
if StrBegins(PoFileItem.IdentifierLow, AClassName) then
|
||||
begin
|
||||
OptionsSearchCache.Add(PoFileItem);
|
||||
end;
|
||||
end;
|
||||
if AEditor.HasChildren then FillCache(AEditor.Children);
|
||||
end;
|
||||
end;
|
||||
|
||||
begin
|
||||
OptionsSearchCache:= TList.Create;
|
||||
POFile:= (LRSTranslator as TTranslator).POFile;
|
||||
FillCache(OptionsEditorClassList);
|
||||
end;
|
||||
|
||||
{ GetOptionsForm }
|
||||
// To get a point on the frmOptions.
|
||||
// Could have been simple to place "frmOptions" in the "interface" section but not sure why original author hide it under. Let's play safe.
|
||||
function GetOptionsForm: TfrmOptions;
|
||||
begin
|
||||
result := frmOptions;
|
||||
Result := frmOptions;
|
||||
end;
|
||||
|
||||
function ShowOptions(EditorClass: TOptionsEditorClass): IOptionsDialog;
|
||||
|
|
@ -122,6 +163,10 @@ end;
|
|||
|
||||
function ShowOptions(EditorClassName: String): IOptionsDialog;
|
||||
begin
|
||||
if (OptionsSearchCache = nil) then
|
||||
begin
|
||||
CreateSearchCache;
|
||||
end;
|
||||
if Assigned(frmOptions) then
|
||||
begin
|
||||
if frmOptions.WindowState = wsMinimized then
|
||||
|
|
@ -193,7 +238,59 @@ end;
|
|||
|
||||
procedure TfrmOptions.FormDestroy(Sender: TObject);
|
||||
begin
|
||||
FreeThenNil(FOptionsEditorList);
|
||||
FreeAndNil(FOptionsEditorList);
|
||||
end;
|
||||
|
||||
procedure TfrmOptions.splOptionsSplitterMoved(Sender: TObject);
|
||||
var
|
||||
ARight, ADelta: Integer;
|
||||
begin
|
||||
ADelta:= ScaleX(8, DesignTimePPI);
|
||||
ARight:= splOptionsSplitter.Left;
|
||||
if (ARight > (btnOK.Left - ADelta)) then
|
||||
begin
|
||||
ARight:= btnOK.Left - ADelta;
|
||||
end;
|
||||
TreeFilterEdit.Width:= (ARight - TreeFilterEdit.Left);
|
||||
end;
|
||||
|
||||
function TfrmOptions.TreeFilterEditFilterItem(ItemData: Pointer; out
|
||||
Done: Boolean): Boolean;
|
||||
var
|
||||
Index: Integer;
|
||||
AClassName: String;
|
||||
AFind, AText: String;
|
||||
POFileItem: TPOFileItem;
|
||||
aOptionsEditorView: TOptionsEditorView absolute ItemData;
|
||||
begin
|
||||
Done:= True;
|
||||
AFind:= TreeFilterEdit.Text;
|
||||
if Length(AFind) = 0 then Exit(True);
|
||||
|
||||
AFind:= UTF8LowerCase(AFind);
|
||||
AClassName:= LowerCase(aOptionsEditorView.EditorClass.ClassName);
|
||||
|
||||
for Index:= 0 to OptionsSearchCache.Count - 1 do
|
||||
begin
|
||||
POFileItem:= TPOFileItem(OptionsSearchCache[Index]);
|
||||
|
||||
if Length(POFileItem.Translation) = 0 then
|
||||
AText:= POFileItem.Original
|
||||
else begin
|
||||
AText:= POFileItem.Translation;
|
||||
end;
|
||||
AText:= UTF8LowerCase(StripHotkey(AText));
|
||||
|
||||
if Pos(AFind, AText) > 0 then
|
||||
begin
|
||||
if StrBegins(POFileItem.IdentifierLow, AClassName) then
|
||||
begin
|
||||
// DebugLn(AClassName + ': ' + AText);
|
||||
Exit(True);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
Result:= False;
|
||||
end;
|
||||
|
||||
function TfrmOptions.CompareTwoNodeOfConfigurationOptionTree(Node1, Node2: TTreeNode): integer;
|
||||
|
|
@ -337,6 +434,7 @@ procedure TfrmOptions.tvTreeViewChange(Sender: TObject; Node: TTreeNode);
|
|||
var
|
||||
SelectedEditorView: TOptionsEditorView;
|
||||
begin
|
||||
if (Node = nil) then Exit;
|
||||
SelectedEditorView := TOptionsEditorView(Node.Data);
|
||||
|
||||
if Assigned(SelectedEditorView) and (FOldEditor <> SelectedEditorView) then
|
||||
|
|
@ -457,4 +555,7 @@ begin
|
|||
close;
|
||||
end;
|
||||
|
||||
finalization
|
||||
FreeAndNil(OptionsSearchCache);
|
||||
|
||||
end.
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ type
|
|||
destructor Destroy; override;
|
||||
procedure TranslateStringProperty(Sender: TObject; const Instance: TPersistent;
|
||||
PropInfo: PPropInfo; var Content: String); override;
|
||||
property POFile: TPOFile read FPOFile;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue