28
Classes, SysUtils, LCLProc, FileUtil, Forms, StdCtrls, Dialogs, Controls,
29
EnvironmentOpts, MacroIntf, LazarusIDEStrConsts, InputHistory, LazConf,
30
IDEProcs, IDEOptionsIntf;
32
Classes, SysUtils, LCLProc, FileUtil, CodeToolManager, DefineTemplates, Forms,
33
StdCtrls, Dialogs, Controls, EnvironmentOpts, MacroIntf, LazarusIDEStrConsts,
34
InputHistory, LazConf, IDEProcs, IDEOptionsIntf, IDEDialogs, InitialSetupDlgs;
36
40
TFilesOptionsFrame = class(TAbstractIDEOptionsEditor)
37
41
AutoCloseCompileDialogCheckBox: TCheckBox;
38
42
CompilerMessagesButton:TButton;
43
CompilerMessagesComboBox:TComboBox;
44
CompilerMessagesLabel:TLabel;
39
45
CompilerPathButton:TButton;
40
46
CompilerPathComboBox:TComboBox;
47
CompilerPathLabel:TLabel;
41
48
FPCSourceDirButton:TButton;
42
49
FPCSourceDirComboBox:TComboBox;
43
CompilerPathLabel:TLabel;
44
50
FPCSourceDirLabel:TLabel;
45
CompilerMessagesLabel:TLabel;
51
LazarusDirButton:TButton;
52
LazarusDirComboBox:TComboBox;
53
LazarusDirLabel:TLabel;
46
54
MakePathButton:TButton;
47
55
MakePathComboBox:TComboBox;
48
TestBuildDirButton:TButton;
49
TestBuildDirComboBox:TComboBox;
50
CompilerMessagesComboBox:TComboBox;
51
TestBuildDirLabel:TLabel;
52
56
MakePathLabel:TLabel;
53
LazarusDirButton:TButton;
54
LazarusDirComboBox:TComboBox;
55
LazarusDirLabel:TLabel;
56
57
MaxRecentOpenFilesComboBox: TComboBox;
57
58
MaxRecentOpenFilesLabel: TLabel;
58
59
MaxRecentProjectFilesComboBox: TComboBox;
59
60
MaxRecentProjectFilesLabel: TLabel;
60
61
OpenLastProjectAtStartCheckBox: TCheckBox;
61
62
ShowCompileDialogCheckBox: TCheckBox;
63
TestBuildDirButton:TButton;
64
TestBuildDirComboBox:TComboBox;
65
TestBuildDirLabel:TLabel;
62
66
procedure CompilerMessagesButtonClick(Sender:TObject);
63
67
procedure FilesButtonClick(Sender: TObject);
64
68
procedure DirectoriesButtonClick(Sender: TObject);
65
69
procedure ShowCompileDialogCheckBoxChange(Sender: TObject);
67
71
FOldLazarusDir: string;
72
FOldRealLazarusDir: string;
68
73
FOldCompilerFilename: string;
74
FOldRealCompilerFilename: string;
69
75
FOldFPCSourceDir: string;
76
FOldRealFPCSourceDir: string;
70
77
FOldMakeFilename: string;
78
FOldRealMakeFilename: string;
71
79
FOldTestDir: string;
72
function CheckLazarusDir: boolean;
73
function IsFPCSourceDir: boolean;
80
FOldRealTestDir: string;
81
fOldCompilerMessagesFilename: string;
82
fOldRealCompilerMessagesFilename: string;
83
fOldMaxRecentOpenFiles: integer;
84
fOldMaxRecentProjectFiles: integer;
85
fOldOpenLastProjectAtStart: boolean;
86
fOldShowCompileDialog: boolean;
87
fOldAutoCloseCompileDialog: boolean;
88
function CheckLazarusDir(Buttons: TMsgDlgButtons): boolean;
89
function CheckCompiler(Buttons: TMsgDlgButtons): boolean;
90
function CheckFPCSourceDir(Buttons: TMsgDlgButtons): boolean;
74
91
function CheckTestDir: boolean;
92
function CheckMake: boolean;
76
94
function Check: Boolean; override;
77
95
function GetTitle: String; override;
78
96
procedure Setup(ADialog: TAbstractOptionsEditorDialog); override;
79
97
procedure ReadSettings(AOptions: TAbstractIDEOptions); override;
80
98
procedure WriteSettings(AOptions: TAbstractIDEOptions); override;
99
procedure RestoreSettings(AOptions: TAbstractIDEOptions); override;
81
100
class function SupportedOptionsClass: TAbstractIDEOptionsClass; override;
111
130
if Sender=CompilerPathButton then begin
112
131
// check compiler filename
113
SetComboBoxText(CompilerPathComboBox,AFilename);
114
CheckExecutable(FOldCompilerFilename,CompilerPathComboBox.Text,
115
lisEnvOptDlgInvalidCompilerFilename,
116
lisEnvOptDlgInvalidCompilerFilenameMsg);
132
SetComboBoxText(CompilerPathComboBox,AFilename,cstFilename);
133
CheckCompiler([mbOk]);
117
134
end else if Sender=MakePathButton then begin
118
135
// check make filename
119
SetComboBoxText(MakePathComboBox,AFilename);
120
CheckExecutable(FOldMakeFilename,MakePathComboBox.Text,
121
lisEnvOptDlgInvalidMakeFilename,
122
lisEnvOptDlgInvalidMakeFilenameMsg);
136
SetComboBoxText(MakePathComboBox,AFilename,cstFilename);
125
140
InputHistories.StoreFileDialogSettings(OpenDialog);
174
190
if Sender=LazarusDirButton then begin
175
191
// check lazarus directory
176
SetComboBoxText(LazarusDirComboBox,ADirectoryName);
192
SetComboBoxText(LazarusDirComboBox,ADirectoryName,cstFilename);
193
CheckLazarusDir([mbOk]);
178
194
end else if Sender=FPCSourceDirButton then begin
179
195
// check fpc source directory
180
SetComboBoxText(FPCSourceDirComboBox,ADirectoryName);
196
SetComboBoxText(FPCSourceDirComboBox,ADirectoryName,cstFilename);
197
CheckFPCSourceDir([mbOK]);
182
198
end else if Sender=TestBuildDirButton then begin
183
199
// check test directory
184
SetComboBoxText(TestBuildDirComboBox,ADirectoryName);
200
SetComboBoxText(TestBuildDirComboBox,ADirectoryName,cstFilename);
247
263
function TFilesOptionsFrame.Check: Boolean;
266
with EnvironmentOptions do
268
LazarusDirectory:=LazarusDirComboBox.Text;
269
CompilerFilename:=CompilerPathComboBox.Text;
270
FPCSourceDirectory:=FPCSourceDirComboBox.Text;
271
MakeFilename:=MakePathComboBox.Text;
272
TestBuildDirectory:=TestBuildDirComboBox.Text;
273
CompilerMessagesFilename:=CompilerMessagesComboBox.Text;
250
275
// check lazarus directory
251
if not CheckLazarusDir then
276
if not CheckLazarusDir([mbIgnore,mbCancel]) then exit;
253
277
// check compiler filename
254
if not CheckExecutable(FOldCompilerFilename,CompilerPathComboBox.Text,
255
lisEnvOptDlgInvalidCompilerFilename,lisEnvOptDlgInvalidCompilerFilenameMsg) then
278
if not CheckCompiler([mbIgnore,mbCancel]) then exit;
257
279
// check fpc source directory
258
if not IsFPCSourceDir then
280
if not CheckFPCSourceDir([mbIgnore,mbCancel]) then exit;
260
281
// check make filename
261
if not CheckExecutable(FOldMakeFilename,MakePathComboBox.Text,
262
lisEnvOptDlgInvalidMakeFilename,lisEnvOptDlgInvalidMakeFilenameMsg,true)
282
if not CheckMake then exit;
265
283
// check test directory
266
if not CheckTestDir then
284
if not CheckTestDir then exit;
287
307
FOldCompilerFilename:=CompilerFilename;
288
SetComboBoxText(CompilerPathComboBox,CompilerFilename,MaxComboBoxCount);
308
FOldRealCompilerFilename:=GetParsedCompilerFilename;
309
SetComboBoxText(CompilerPathComboBox,CompilerFilename,cstFilename,MaxComboBoxCount);
312
FOldFPCSourceDir:=FPCSourceDirectory;
313
FOldRealFPCSourceDir:=GetParsedFPCSourceDirectory;
289
314
FPCSourceDirComboBox.Items.Assign(FPCSourceDirHistory);
290
FOldFPCSourceDir:=FPCSourceDirectory;
291
SetComboBoxText(FPCSourceDirComboBox,FPCSourceDirectory,MaxComboBoxCount);
315
SetComboBoxText(FPCSourceDirComboBox,FPCSourceDirectory,cstFilename,MaxComboBoxCount);
318
FOldMakeFilename:=MakeFilename;
319
FOldRealMakeFilename:=GetParsedMakeFilename;
292
320
MakePathComboBox.Items.Assign(MakeFileHistory);
293
FOldMakeFilename:=MakeFilename;
294
SetComboBoxText(MakePathComboBox,MakeFilename,MaxComboBoxCount);
321
SetComboBoxText(MakePathComboBox,MakeFilename,cstFilename,MaxComboBoxCount);
324
FOldTestDir:=TestBuildDirectory;
325
FOldRealTestDir:=GetParsedTestBuildDirectory;
295
326
TestBuildDirComboBox.Items.Assign(TestBuildDirHistory);
296
FOldTestDir:=TestBuildDirectory;
297
SetComboBoxText(TestBuildDirComboBox,TestBuildDirectory,MaxComboBoxCount);
327
SetComboBoxText(TestBuildDirComboBox,TestBuildDirectory,cstFilename,MaxComboBoxCount);
329
// compiler messages file
330
fOldCompilerMessagesFilename:=CompilerMessagesFilename;
331
fOldRealCompilerMessagesFilename:=GetParsedCompilerMessagesFilename;
298
332
CompilerMessagesComboBox.Items.Assign(CompilerMessagesFileHistory);
299
SetComboBoxText(CompilerMessagesComboBox,CompilerMessagesFilename,MaxComboBoxCount);
333
SetComboBoxText(CompilerMessagesComboBox,CompilerMessagesFilename,cstFilename,MaxComboBoxCount);
301
335
// recent files and directories
302
SetComboBoxText(MaxRecentOpenFilesComboBox,IntToStr(MaxRecentOpenFiles));
303
SetComboBoxText(MaxRecentProjectFilesComboBox,IntToStr(MaxRecentProjectFiles));
336
fOldMaxRecentOpenFiles:=MaxRecentOpenFiles;
337
SetComboBoxText(MaxRecentOpenFilesComboBox,IntToStr(MaxRecentOpenFiles),cstCaseInsensitive);
338
fOldMaxRecentProjectFiles:=MaxRecentProjectFiles;
339
SetComboBoxText(MaxRecentProjectFilesComboBox,IntToStr(MaxRecentProjectFiles),cstCaseInsensitive);
340
fOldOpenLastProjectAtStart:=OpenLastProjectAtStart;
342
// open last project at start
304
343
OpenLastProjectAtStartCheckBox.Checked:=OpenLastProjectAtStart;
346
fOldShowCompileDialog:=ShowCompileDialog;
305
347
ShowCompileDialogCheckBox.Checked:=ShowCompileDialog;
348
fOldAutoCloseCompileDialog:=AutoCloseCompileDialog;
306
349
AutoCloseCompileDialogCheckBox.Checked:=AutoCloseCompileDialog;
307
350
AutoCloseCompileDialogCheckBox.Enabled:=ShowCompileDialogCheckBox.Checked;
339
function TFilesOptionsFrame.CheckLazarusDir: boolean;
382
procedure TFilesOptionsFrame.RestoreSettings(AOptions: TAbstractIDEOptions);
384
inherited RestoreSettings(AOptions);
385
with AOptions as TEnvironmentOptions do
387
LazarusDirectory:=FOldLazarusDir;
388
CompilerFilename:=FOldCompilerFilename;
389
FPCSourceDirectory:=FOldFPCSourceDir;
390
MakeFilename:=FOldMakeFilename;
391
TestBuildDirectory:=FOldTestDir;
392
CompilerMessagesFilename:=fOldCompilerMessagesFilename;
394
// recent files and directories
395
MaxRecentOpenFiles:=fOldMaxRecentOpenFiles;
396
MaxRecentProjectFiles:=fOldMaxRecentProjectFiles;
397
OpenLastProjectAtStart:=fOldOpenLastProjectAtStart;
398
ShowCompileDialog := fOldShowCompileDialog;
399
AutoCloseCompileDialog := fOldAutoCloseCompileDialog;
403
function TFilesOptionsFrame.CheckLazarusDir(Buttons: TMsgDlgButtons): boolean;
341
405
NewLazarusDir: string;
342
StopChecking: boolean;
406
Quality: TSDFilenameQuality;
409
if EnvironmentOptions.LazarusDirectory=FOldLazarusDir then exit(true);
345
NewLazarusDir := LazarusDirComboBox.Text;
346
Result := SimpleDirectoryCheck(FOldLazarusDir,NewLazarusDir,
347
lisEnvOptDlgLazarusDirNotFoundMsg,StopChecking);
348
if (not Result) or StopChecking then
351
// lazarus directory specific tests
352
NewLazarusDir := AppendPathDelim(NewLazarusDir);
353
if not CheckLazarusDirectory(NewLazarusDir) then
411
EnvironmentOptions.LazarusDirectory:=LazarusDirComboBox.Text;
412
NewLazarusDir := EnvironmentOptions.GetParsedLazarusDirectory;
413
Quality:=CheckLazarusDirectoryQuality(NewLazarusDir,Note);
414
if Quality<>sddqCompatible then
355
Result:=(MessageDlg(Format(lisEnvOptDlgInvalidLazarusDir,[NewLazarusDir]),
356
mtWarning,[mbIgnore,mbCancel],0)=mrIgnore);
416
if IDEMessageDialog(lisCCOWarningCaption,
417
Format(lisTheLazarusDirectoryDoesNotLookCorrect, [NewLazarusDir, #13, Note
419
mtWarning, Buttons)<>mrIgnore
362
function TFilesOptionsFrame.IsFPCSourceDir: boolean;
426
function TFilesOptionsFrame.CheckFPCSourceDir(Buttons: TMsgDlgButtons): boolean;
364
428
NewFPCSrcDir: string;
365
StopChecking: boolean;
430
Quality: TSDFilenameQuality;
431
CfgCache: TFPCTargetConfigCache;
367
NewFPCSrcDir:=FPCSourceDirComboBox.Text;
368
Result:=IDEMacros.SubstituteMacros(NewFPCSrcDir);
369
if not Result then begin
370
Result:=(MessageDlg(Format(lisEnvOptDlgInvalidFPCSrcDir,[NewFPCSrcDir]),
371
mtWarning,[mbIgnore,mbCancel],0)=mrIgnore);
434
if EnvironmentOptions.FPCSourceDirectory=FOldFPCSourceDir then exit(true);
436
CfgCache:=CodeToolBoss.FPCDefinesCache.ConfigCaches.Find(
437
EnvironmentOptions.GetParsedCompilerFilename,'','','',true);
438
FPCVer:=CfgCache.GetFPCVer;
439
EnvironmentOptions.FPCSourceDirectory:=FPCSourceDirComboBox.Text;
440
NewFPCSrcDir:=EnvironmentOptions.GetParsedFPCSourceDirectory;
441
Quality:=CheckFPCSrcDirQuality(NewFPCSrcDir,Note,FPCVer);
442
if Quality<>sddqCompatible then
444
if IDEMessageDialog(lisCCOWarningCaption,
445
Format(lisTheFPCSourceDirectoryDoesNotLookCorrect, [NewFPCSrcDir, #13,
447
mtWarning, Buttons)<>mrIgnore
374
Result:=SimpleDirectoryCheck(FOldFPCSourceDir,NewFPCSrcDir,
375
lisEnvOptDlgFPCSrcDirNotFoundMsg,StopChecking);
376
if (not Result) or StopChecking then exit;
378
// FPC source directory specific tests
379
if not CheckFPCSourceDir(NewFPCSrcDir) then begin
380
Result:=(MessageDlg(Format(lisEnvOptDlgInvalidFPCSrcDir,[NewFPCSrcDir]),
381
mtWarning,[mbIgnore,mbCancel],0)=mrIgnore);
454
function TFilesOptionsFrame.CheckCompiler(Buttons: TMsgDlgButtons): boolean;
456
NewCompilerFilename: String;
458
Quality: TSDFilenameQuality;
460
if EnvironmentOptions.CompilerFilename=FOldCompilerFilename then exit(true);
462
EnvironmentOptions.CompilerFilename:=CompilerPathComboBox.Text;
463
NewCompilerFilename:=EnvironmentOptions.GetParsedCompilerFilename;
464
Quality:=CheckCompilerQuality(NewCompilerFilename,Note,
465
CodeToolBoss.FPCDefinesCache.TestFilename);
466
if Quality<>sddqCompatible then
468
if IDEMessageDialog(lisCCOWarningCaption,
469
Format(lisTheCompilerFileDoesNotLookCorrect, [NewCompilerFilename, #13,
471
mtWarning, Buttons)<>mrIgnore
389
480
NewTestDir: string;
390
481
StopChecking: boolean;
392
NewTestDir:=TestBuildDirComboBox.Text;
393
Result:=SimpleDirectoryCheck(FOldTestDir,NewTestDir,
483
if EnvironmentOptions.TestBuildDirectory=FOldTestDir then exit(true);
484
EnvironmentOptions.TestBuildDirectory:=TestBuildDirComboBox.Text;
485
NewTestDir:=EnvironmentOptions.GetParsedTestBuildDirectory;
486
Result:=SimpleDirectoryCheck(FOldRealTestDir,NewTestDir,
394
487
lisEnvOptDlgTestDirNotFoundMsg,StopChecking);
395
if (not Result) or StopChecking then exit;
490
function TFilesOptionsFrame.CheckMake: boolean;
492
NewMakeFilename: String;
494
if EnvironmentOptions.MakeFilename=FOldMakeFilename then exit(true);
495
EnvironmentOptions.MakeFilename:=MakePathComboBox.Text;
496
NewMakeFilename:=EnvironmentOptions.GetParsedMakeFilename;
497
Result:=CheckExecutable(FOldRealMakeFilename,NewMakeFilename,
498
lisCCOWarningCaption, Format(lisThePathOfMakeIsNotCorrect, [NewMakeFilename]));
398
501
class function TFilesOptionsFrame.SupportedOptionsClass: TAbstractIDEOptionsClass;