1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
|
unit fraconfigfilebrowser;
{$mode objfpc}{$H+}
interface
uses
// IdeIntf
Classes, SysUtils, Forms, Controls, StdCtrls,
Dialogs, FileCtrl, ComCtrls, ExtCtrls, EditBtn,
IDEOptionsIntf, IDEOptEditorIntf, IDEUtils, IDEDialogs;
type
{ TFileBrowserOptionsFrame }
TFileBrowserOptionsFrame = class(TAbstractIDEOptionsEditor)
CBShowDirectoriesBeforeFiles: TCheckBox;
CBShowFilesInline: TCheckBox;
CBSyncCurrentEditor: TCheckBox;
CBMatchOnlyFilename: TCheckBox;
CBUseAbsoluteFilenames: TCheckBox;
CBUseLetters: TCheckBox;
DEStartDir: TDirectoryEdit;
DERootDir: TDirectoryEdit;
GBStartDir: TGroupBox;
GBStartDir1: TGroupBox;
GBSearch: TGroupBox;
GBFileTree: TGroupBox;
RBLastDir: TRadioButton;
RBRootFileSystemRoot: TRadioButton;
RBRootUserDir: TRadioButton;
RBThisDir: TRadioButton;
RBRootThisDir: TRadioButton;
RBUseProjectDir: TRadioButton;
RBRootUseProjectDir: TRadioButton;
procedure CBShowFilesInlineChange(Sender: TObject);
private
procedure CheckDirsBeforeFiles;
public
function GetTitle: String; override;
procedure Setup({%H-}ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings({%H-}AOptions: TAbstractIDEOptions); override;
procedure WriteSettings({%H-}AOptions: TAbstractIDEOptions); override;
class function SupportedOptionsClass: TAbstractIDEOptionsClass; override;
end;
implementation
uses lazIDEIntf, filebrowsertypes, ctrlfilebrowser;
{$R *.lfm}
{ TFileBrowserOptionsFrame }
procedure TFileBrowserOptionsFrame.CheckDirsBeforeFiles;
begin
CBShowDirectoriesBeforeFiles.Enabled:=CBShowFilesInline.Checked;
if Not CBShowDirectoriesBeforeFiles.Enabled then
CBShowDirectoriesBeforeFiles.Checked:=False;
end;
procedure TFileBrowserOptionsFrame.CBShowFilesInlineChange(Sender: TObject);
begin
CheckDirsBeforeFiles;
end;
function TFileBrowserOptionsFrame.GetTitle: String;
begin
Result:='File browser options';
end;
procedure TFileBrowserOptionsFrame.Setup(ADialog: TAbstractOptionsEditorDialog);
begin
//
end;
procedure TFileBrowserOptionsFrame.ReadSettings(AOptions: TAbstractIDEOptions);
var
C : TFileBrowserController;
RB: TRadioButton;
begin
C:=LazarusIDE.OwningComponent.FindComponent('IDEFileBrowserController') as TFileBrowserController;
if not Assigned(C) then
exit;
case C.StartDir of
sdProjectDir: RB := RBUseProjectDir;
sdLastOpened: RB := RBLastDir;
sdCustomDir: RB := RBThisDir;
end;
RB.Checked := True;
if C.StartDir=sdCustomDir then
DEStartDir.Directory:=C.CustomStartDir;
case C.RootDir of
rdProjectDir: RB := RBUseProjectDir;
rdRootDir: RB := RBRootFileSystemRoot;
rdUserDir : RB := RBRootUserDir;
rdCustomDir: RB := RBRootThisDir;
end;
RB.Checked := True;
if C.RootDir=rdCustomDir then
DERootDir.Directory:=C.CustomRootDir;
CBShowFilesInline.Checked:=C.FilesInTree;
CBShowDirectoriesBeforeFiles.Checked:=C.DirectoriesBeforeFiles;
CBSyncCurrentEditor.Checked:=C.SyncCurrentEditor;
CBUseAbsoluteFilenames.Checked:=fsoAbsolutePaths in C.SearchOptions;
CBMatchOnlyFilename.Checked:=fsoMatchOnlyFileName in C.SearchOptions;
CBUseLetters.Checked:=fsoUseLetters in C.SearchOptions;
CheckDirsBeforeFiles;
end;
procedure TFileBrowserOptionsFrame.WriteSettings(AOptions: TAbstractIDEOptions);
var
C : TFileBrowserController;
SD : TStartDir;
RD : TRootDir;
SO : TFileSearchOptions;
lRootDir: String;
begin
C:=LazarusIDE.OwningComponent.FindComponent('IDEFileBrowserController') as TFileBrowserController;
if not Assigned(C) then
exit;
lRootDir:=C.GetResolvedRootDir;
if RBUseProjectDir.Checked then
SD:=sdProjectDir
else if RBLastDir.Checked then
SD:=sdLastOpened
else
SD:=sdCustomDir;
C.StartDir:=SD;
if SD=sdCustomDir then
C.CustomStartDir:=DEStartDir.Directory
else
C.CustomStartDir:='';
if RBRootUseProjectDir.Checked then
RD:=rdProjectDir
else if RBRootFileSystemRoot.Checked then
RD:=rdRootDir
else if RBRootUserDir.Checked then
RD:=rdUserDir
else
RD:=rdCustomDir;
C.RootDir:=rD;
if rD=rdCustomDir then
C.CustomRootDir:=DERootDir.Directory
else
C.CustomRootDir:='';
C.FilesInTree:=CBShowFilesInline.Checked;
C.SyncCurrentEditor:=CBSyncCurrentEditor.Checked;
SO:=[];
if CBUseAbsoluteFilenames.Checked then
Include(SO,fsoAbsolutePaths);
if CBMatchOnlyFilename.Checked then
Include(SO,fsoMatchOnlyFileName);
if CBUseLetters.Checked then
Include(SO,fsoUseLetters);
C.SearchOptions:=SO;
// Re-index
if lRootDir<>C.GetResolvedRootDir then
C.IndexRootDir;
C.WriteConfig;
end;
class function TFileBrowserOptionsFrame.SupportedOptionsClass: TAbstractIDEOptionsClass;
begin
Result:=IDEEditorGroups.GetByIndex(GroupEnvironment)^.GroupClass;
end;
end.
|