mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 13:17:18 +02:00
IDE: Improve Files options GUI, especially for Fppkg configuration. Issue #40850, patch by n7800.
This commit is contained in:
parent
66e929e9d6
commit
1fa34e6268
@ -96,7 +96,7 @@ type
|
|||||||
FOldRealTestDir: string;
|
FOldRealTestDir: string;
|
||||||
fOldCompilerMessagesFilename: string;
|
fOldCompilerMessagesFilename: string;
|
||||||
fOldRealCompilerMessagesFilename: string;
|
fOldRealCompilerMessagesFilename: string;
|
||||||
fOldFppkcConfigurationFilename: string;
|
fOldFppkgConfigurationFilename: string;
|
||||||
FOldMaxRecentOpenFiles: integer;
|
FOldMaxRecentOpenFiles: integer;
|
||||||
FOldMaxRecentProjectFiles: integer;
|
FOldMaxRecentProjectFiles: integer;
|
||||||
function CheckLazarusDir(Buttons: TMsgDlgButtons): boolean;
|
function CheckLazarusDir(Buttons: TMsgDlgButtons): boolean;
|
||||||
@ -104,7 +104,7 @@ type
|
|||||||
function CheckFPCSourceDir(Buttons: TMsgDlgButtons): boolean;
|
function CheckFPCSourceDir(Buttons: TMsgDlgButtons): boolean;
|
||||||
function CheckTestDir: boolean;
|
function CheckTestDir: boolean;
|
||||||
function CheckMake: boolean;
|
function CheckMake: boolean;
|
||||||
function CheckFPCMsgFile: boolean;
|
function CheckCompilerTranslationFile: boolean;
|
||||||
function CheckFppkgConfigurationFile: boolean;
|
function CheckFppkgConfigurationFile: boolean;
|
||||||
public
|
public
|
||||||
function Check: Boolean; override;
|
function Check: Boolean; override;
|
||||||
@ -132,7 +132,10 @@ begin
|
|||||||
OpenDialog := IDEOpenDialogClass.Create(nil);
|
OpenDialog := IDEOpenDialogClass.Create(nil);
|
||||||
try
|
try
|
||||||
InputHistories.ApplyFileDialogSettings(OpenDialog);
|
InputHistories.ApplyFileDialogSettings(OpenDialog);
|
||||||
OpenDialog.Options := OpenDialog.Options+[ofPathMustExist];
|
OpenDialog.Options := OpenDialog.Options+[ofFileMustExist, ofReadOnly]; // allow select read only files
|
||||||
|
OpenDialog.Filter:=
|
||||||
|
Format('%s (*%s)|*%s|', [dlgFilterExecutable, GetExecutableExt, GetExecutableExt]) +
|
||||||
|
Format('%s (%s)|%s', [dlgFilterAll, GetAllFilesMask, GetAllFilesMask]);
|
||||||
// set title
|
// set title
|
||||||
if Sender = CompilerPathButton then begin
|
if Sender = CompilerPathButton then begin
|
||||||
OpenDialog.Title := Format(lisChooseCompilerExecutable,[GetDefaultCompilerFilename]);
|
OpenDialog.Title := Format(lisChooseCompilerExecutable,[GetDefaultCompilerFilename]);
|
||||||
@ -154,16 +157,18 @@ begin
|
|||||||
|
|
||||||
if OpenDialog.Execute then begin
|
if OpenDialog.Execute then begin
|
||||||
lDirNameF := CleanAndExpandFilename(OpenDialog.Filename);
|
lDirNameF := CleanAndExpandFilename(OpenDialog.Filename);
|
||||||
if UpperCase(lExpandedName) <> UpperCase(lDirNameF) then begin // Changed ?
|
if CompareText(lExpandedName, lDirNameF) <> 0 then begin
|
||||||
lDirText := lDirNameF;
|
lDirText := lDirNameF;
|
||||||
if Sender=CompilerPathButton then begin
|
if Sender=CompilerPathButton then begin
|
||||||
// check compiler filename
|
// check compiler filename
|
||||||
SetComboBoxText(CompilerPathComboBox,lDirText,cstFilename);
|
SetComboBoxText(CompilerPathComboBox,lDirText,cstFilename);
|
||||||
|
EnvironmentOptions.CompilerFilename:=CompilerPathComboBox.Text;
|
||||||
CheckCompiler([mbOk]);
|
CheckCompiler([mbOk]);
|
||||||
end
|
end
|
||||||
else if Sender = MakePathButton then begin
|
else if Sender = MakePathButton then begin
|
||||||
// check make filename
|
// check make filename
|
||||||
SetComboBoxText(MakePathComboBox,lDirText,cstFilename);
|
SetComboBoxText(MakePathComboBox,lDirText,cstFilename);
|
||||||
|
EnvironmentOptions.MakeFilename:=MakePathComboBox.Text;
|
||||||
CheckMake;
|
CheckMake;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -175,40 +180,35 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TFilesOptionsFrame.DirectoriesButtonClick(Sender: TObject);
|
procedure TFilesOptionsFrame.DirectoriesButtonClick(Sender: TObject);
|
||||||
var
|
|
||||||
lDirText : string;
|
|
||||||
|
|
||||||
function ParsedDirName(aParseType: TEnvOptParseType): string;
|
|
||||||
begin
|
|
||||||
if lDirText = '' then
|
|
||||||
Result := EnvironmentOptions.GetParsedValue(aParseType, '')
|
|
||||||
else
|
|
||||||
Result := EnvironmentOptions.GetParsedValue(aParseType, lDirText);
|
|
||||||
end;
|
|
||||||
|
|
||||||
var
|
var
|
||||||
OpenDialog: TSelectDirectoryDialog;
|
OpenDialog: TSelectDirectoryDialog;
|
||||||
lDirName, loDirNameF, lExpandedName: string;
|
lDirText, lDirName, loDirNameF, lExpandedName: string;
|
||||||
begin
|
begin
|
||||||
OpenDialog := TSelectDirectoryDialog.Create(nil);
|
OpenDialog := TSelectDirectoryDialog.Create(nil);
|
||||||
try
|
try
|
||||||
InputHistories.ApplyFileDialogSettings(OpenDialog);
|
InputHistories.ApplyFileDialogSettings(OpenDialog);
|
||||||
OpenDialog.Options := OpenDialog.Options+[ofExtensionDifferent, ofPathMustExist];
|
|
||||||
// set title
|
// set title
|
||||||
if Sender = LazarusDirButton then begin
|
if Sender = LazarusDirButton then begin
|
||||||
OpenDialog.Title := lisChooseLazarusSourceDirectory;
|
OpenDialog.Title := lisChooseLazarusSourceDirectory;
|
||||||
|
OpenDialog.Options := OpenDialog.Options
|
||||||
|
+ [ofPathMustExist,ofReadOnly]; // allow select read only folder
|
||||||
lDirText := LazarusDirComboBox.Text;
|
lDirText := LazarusDirComboBox.Text;
|
||||||
lDirName := ParsedDirName(eopLazarusDirectory);
|
lDirName := EnvironmentOptions.GetParsedValue(eopLazarusDirectory, lDirText);
|
||||||
end
|
end
|
||||||
else if Sender = FPCSourceDirButton then begin
|
else if Sender = FPCSourceDirButton then begin
|
||||||
OpenDialog.Title := lisChooseFPCSourceDir;
|
OpenDialog.Title := lisChooseFPCSourceDir;
|
||||||
|
OpenDialog.Options := OpenDialog.Options
|
||||||
|
+ [ofPathMustExist,ofReadOnly]; // allow select read only folder
|
||||||
lDirText := FPCSourceDirComboBox.Text;
|
lDirText := FPCSourceDirComboBox.Text;
|
||||||
lDirName := ParsedDirName(eopFPCSourceDirectory);
|
lDirName := EnvironmentOptions.GetParsedValue(eopFPCSourceDirectory, lDirText);
|
||||||
end
|
end
|
||||||
else if Sender=TestBuildDirButton then begin
|
else if Sender=TestBuildDirButton then begin
|
||||||
OpenDialog.Title := lisChooseTestBuildDir;
|
OpenDialog.Title := lisChooseTestBuildDir;
|
||||||
|
OpenDialog.Options := OpenDialog.Options
|
||||||
|
- [ofPathMustExist] // allow to choose a non-existent path
|
||||||
|
+ [ofNoReadOnlyReturn]; // the folder must be writable
|
||||||
lDirText := TestBuildDirComboBox.Text;
|
lDirText := TestBuildDirComboBox.Text;
|
||||||
lDirName := ParsedDirName(eopTestBuildDirectory);
|
lDirName := EnvironmentOptions.GetParsedValue(eopTestBuildDirectory, lDirText);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
exit;
|
exit;
|
||||||
@ -221,21 +221,24 @@ begin
|
|||||||
|
|
||||||
if OpenDialog.Execute then begin
|
if OpenDialog.Execute then begin
|
||||||
lDirName := CleanAndExpandDirectory(OpenDialog.Filename);
|
lDirName := CleanAndExpandDirectory(OpenDialog.Filename);
|
||||||
if UpperCase(lDirName)<>UpperCase(lExpandedName) then begin
|
if CompareText(lDirName, lExpandedName) <> 0 then begin
|
||||||
lDirText := lDirName;
|
lDirText := lDirName;
|
||||||
if Sender = LazarusDirButton then begin
|
if Sender = LazarusDirButton then begin
|
||||||
// check lazarus directory
|
// check lazarus directory
|
||||||
SetComboBoxText(LazarusDirComboBox,lDirText,cstFilename);
|
SetComboBoxText(LazarusDirComboBox,lDirText,cstFilename);
|
||||||
|
EnvironmentOptions.LazarusDirectory:=LazarusDirComboBox.Text;
|
||||||
CheckLazarusDir([mbOk]);
|
CheckLazarusDir([mbOk]);
|
||||||
end
|
end
|
||||||
else if Sender = FPCSourceDirButton then begin
|
else if Sender = FPCSourceDirButton then begin
|
||||||
// check fpc source directory
|
// check fpc source directory
|
||||||
SetComboBoxText(FPCSourceDirComboBox,lDirText,cstFilename);
|
SetComboBoxText(FPCSourceDirComboBox,lDirText,cstFilename);
|
||||||
|
EnvironmentOptions.FPCSourceDirectory:=FPCSourceDirComboBox.Text;
|
||||||
CheckFPCSourceDir([mbOK]);
|
CheckFPCSourceDir([mbOK]);
|
||||||
end
|
end
|
||||||
else if Sender = TestBuildDirButton then begin
|
else if Sender = TestBuildDirButton then begin
|
||||||
// check test directory
|
// check test directory
|
||||||
SetComboBoxText(TestBuildDirComboBox,lDirText,cstFilename);
|
SetComboBoxText(TestBuildDirComboBox,lDirText,cstFilename);
|
||||||
|
EnvironmentOptions.TestBuildDirectory:=TestBuildDirComboBox.Text;
|
||||||
CheckTestDir;
|
CheckTestDir;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -256,11 +259,14 @@ begin
|
|||||||
InputHistories.ApplyFileDialogSettings(OpenDialog);
|
InputHistories.ApplyFileDialogSettings(OpenDialog);
|
||||||
OpenDialog.Options:=OpenDialog.Options+[ofPathMustExist];
|
OpenDialog.Options:=OpenDialog.Options+[ofPathMustExist];
|
||||||
OpenDialog.Title:=lisChooseCompilerMessages;
|
OpenDialog.Title:=lisChooseCompilerMessages;
|
||||||
OpenDialog.Filter:=dlgFilterFPCMessageFile+' (*.msg)|*.msg|'+dlgFilterAll+'|'+
|
OpenDialog.Filter:=
|
||||||
GetAllFilesMask;
|
Format('%s (%s)|%s|', [dlgFilterFPCMessageFile, '*.msg', '*.msg']) +
|
||||||
|
Format('%s (%s)|%s', [dlgFilterAll, GetAllFilesMask, GetAllFilesMask]);
|
||||||
if OpenDialog.Execute then begin
|
if OpenDialog.Execute then begin
|
||||||
AFilename:=CleanAndExpandFilename(OpenDialog.Filename);
|
AFilename:=CleanAndExpandFilename(OpenDialog.Filename);
|
||||||
SetComboBoxText(CompilerTranslationFileComboBox,AFilename,cstFilename);
|
SetComboBoxText(CompilerTranslationFileComboBox,AFilename,cstFilename);
|
||||||
|
EnvironmentOptions.CompilerMessagesFilename:=CompilerTranslationFileComboBox.Text;
|
||||||
|
CheckCompilerTranslationFile;
|
||||||
end;
|
end;
|
||||||
InputHistories.StoreFileDialogSettings(OpenDialog);
|
InputHistories.StoreFileDialogSettings(OpenDialog);
|
||||||
finally
|
finally
|
||||||
@ -278,11 +284,14 @@ begin
|
|||||||
InputHistories.ApplyFileDialogSettings(OpenDialog);
|
InputHistories.ApplyFileDialogSettings(OpenDialog);
|
||||||
OpenDialog.Options:=OpenDialog.Options+[ofPathMustExist];
|
OpenDialog.Options:=OpenDialog.Options+[ofPathMustExist];
|
||||||
OpenDialog.Title:=lisChooseFppkgConfigurationFile;
|
OpenDialog.Title:=lisChooseFppkgConfigurationFile;
|
||||||
OpenDialog.Filter:=dlgFilterFppkgConfigurationFile+' (*.cfg)|*.cfg|'+
|
OpenDialog.Filter:=
|
||||||
dlgFilterAll+'|'+GetAllFilesMask;
|
Format('%s (%s)|%s|', [dlgFilterFppkgConfigurationFile, '*.cfg', '*.cfg']) +
|
||||||
|
Format('%s (%s)|%s', [dlgFilterAll, GetAllFilesMask, GetAllFilesMask]);
|
||||||
if OpenDialog.Execute then begin
|
if OpenDialog.Execute then begin
|
||||||
AFilename:=CleanAndExpandFilename(OpenDialog.Filename);
|
AFilename:=CleanAndExpandFilename(OpenDialog.Filename);
|
||||||
SetComboBoxText(FppkgConfigurationFileComboBox,AFilename,cstFilename);
|
SetComboBoxText(FppkgConfigurationFileComboBox,AFilename,cstFilename);
|
||||||
|
EnvironmentOptions.FppkgConfigFile:=FppkgConfigurationFileComboBox.Text;
|
||||||
|
CheckFppkgConfigurationFile;
|
||||||
end;
|
end;
|
||||||
InputHistories.StoreFileDialogSettings(OpenDialog);
|
InputHistories.StoreFileDialogSettings(OpenDialog);
|
||||||
finally
|
finally
|
||||||
@ -381,7 +390,7 @@ begin
|
|||||||
// check test directory
|
// check test directory
|
||||||
if not CheckTestDir then exit;
|
if not CheckTestDir then exit;
|
||||||
// check fpc messages file
|
// check fpc messages file
|
||||||
if not CheckFPCMsgFile then exit;
|
if not CheckCompilerTranslationFile then exit;
|
||||||
// check fppkg configuration file
|
// check fppkg configuration file
|
||||||
if not CheckFppkgConfigurationFile then exit;
|
if not CheckFppkgConfigurationFile then exit;
|
||||||
Result := True;
|
Result := True;
|
||||||
@ -452,7 +461,7 @@ begin
|
|||||||
SetComboBoxText(CompilerTranslationFileComboBox,CompilerMessagesFilename,cstFilename,MaxComboBoxCount);
|
SetComboBoxText(CompilerTranslationFileComboBox,CompilerMessagesFilename,cstFilename,MaxComboBoxCount);
|
||||||
|
|
||||||
// fppkg configuration file
|
// fppkg configuration file
|
||||||
fOldFppkcConfigurationFilename:=FppkgConfigFile;
|
fOldFppkgConfigurationFilename:=FppkgConfigFile;
|
||||||
fOldRealCompilerMessagesFilename:=GetParsedFppkgConfig;
|
fOldRealCompilerMessagesFilename:=GetParsedFppkgConfig;
|
||||||
if FppkgConfigFileHistory.Count>0 then
|
if FppkgConfigFileHistory.Count>0 then
|
||||||
FppkgConfigurationFileComboBox.Items.Assign(FppkgConfigFileHistory);
|
FppkgConfigurationFileComboBox.Items.Assign(FppkgConfigFileHistory);
|
||||||
@ -502,7 +511,7 @@ begin
|
|||||||
MakeFilename:=FOldMakeFilename;
|
MakeFilename:=FOldMakeFilename;
|
||||||
TestBuildDirectory:=FOldTestDir;
|
TestBuildDirectory:=FOldTestDir;
|
||||||
CompilerMessagesFilename:=fOldCompilerMessagesFilename;
|
CompilerMessagesFilename:=fOldCompilerMessagesFilename;
|
||||||
FppkgConfigFile:=fOldFppkcConfigurationFilename;
|
FppkgConfigFile:=fOldFppkgConfigurationFilename;
|
||||||
|
|
||||||
// recent files and directories
|
// recent files and directories
|
||||||
MaxRecentOpenFiles := FOldMaxRecentOpenFiles;
|
MaxRecentOpenFiles := FOldMaxRecentOpenFiles;
|
||||||
@ -608,7 +617,7 @@ begin
|
|||||||
lisCCOWarningCaption, Format(lisThePathOfMakeIsNotCorrect, [NewMakeFilename]));
|
lisCCOWarningCaption, Format(lisThePathOfMakeIsNotCorrect, [NewMakeFilename]));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TFilesOptionsFrame.CheckFPCMsgFile: boolean;
|
function TFilesOptionsFrame.CheckCompilerTranslationFile: boolean;
|
||||||
var
|
var
|
||||||
NewMsgFile: String;
|
NewMsgFile: String;
|
||||||
begin
|
begin
|
||||||
@ -617,9 +626,9 @@ begin
|
|||||||
if EnvironmentOptions.CompilerMessagesFilename<>'' then begin
|
if EnvironmentOptions.CompilerMessagesFilename<>'' then begin
|
||||||
NewMsgFile:=EnvironmentOptions.GetParsedCompilerMessagesFilename;
|
NewMsgFile:=EnvironmentOptions.GetParsedCompilerMessagesFilename;
|
||||||
if not FileExistsUTF8(NewMsgFile) then begin
|
if not FileExistsUTF8(NewMsgFile) then begin
|
||||||
if IDEMessageDialog(lisCCOErrorCaption, Format(
|
if IDEMessageDialog(lisCCOErrorCaption,
|
||||||
lisCompilerMessagesFileNotFound, [#13, NewMsgFile]), mtError, [mbCancel,
|
Format(lisCompilerMessagesFileNotFound, [LineEnding, NewMsgFile]),
|
||||||
mbIgnore])<>mrIgnore
|
mtError, [mbCancel,mbIgnore]) <> mrIgnore
|
||||||
then
|
then
|
||||||
exit(false);
|
exit(false);
|
||||||
end;
|
end;
|
||||||
@ -629,20 +638,32 @@ end;
|
|||||||
|
|
||||||
function TFilesOptionsFrame.CheckFppkgConfigurationFile: boolean;
|
function TFilesOptionsFrame.CheckFppkgConfigurationFile: boolean;
|
||||||
var
|
var
|
||||||
NewFppkgCfgFile: String;
|
NewFppkgCfgFile, Note: String;
|
||||||
begin
|
begin
|
||||||
if EnvironmentOptions.FppkgConfigFile=fOldFppkcConfigurationFilename then exit(true);
|
if EnvironmentOptions.FppkgConfigFile=fOldFppkgConfigurationFilename then exit(true);
|
||||||
EnvironmentOptions.FppkgConfigFile:=FppkgConfigurationFileComboBox.Text;
|
EnvironmentOptions.FppkgConfigFile:=FppkgConfigurationFileComboBox.Text;
|
||||||
|
|
||||||
if EnvironmentOptions.FppkgConfigFile<>'' then begin
|
if EnvironmentOptions.FppkgConfigFile<>'' then begin
|
||||||
NewFppkgCfgFile:=EnvironmentOptions.GetParsedFppkgConfig;
|
NewFppkgCfgFile:=EnvironmentOptions.GetParsedFppkgConfig;
|
||||||
if not FileExistsUTF8(NewFppkgCfgFile) then begin
|
|
||||||
if IDEMessageDialog(lisCCOErrorCaption, Format(
|
if not FileExistsUTF8(NewFppkgCfgFile) then
|
||||||
lisFppkgConfigurationFileNotFound, [#13, NewFppkgCfgFile]), mtError, [mbCancel,
|
begin
|
||||||
mbIgnore])<>mrIgnore
|
if IDEMessageDialog(lisCCOErrorCaption,
|
||||||
|
Format(lisFppkgConfigurationFileNotFound, [LineEnding, NewFppkgCfgFile]),
|
||||||
|
mtError, [mbCancel,mbIgnore]) <> mrIgnore
|
||||||
then
|
then
|
||||||
exit(false);
|
exit(false);
|
||||||
|
end else begin
|
||||||
|
if (CheckFppkgConfigFile (NewFppkgCfgFile, Note) <> sddqCompatible) or
|
||||||
|
(CheckFppkgConfiguration(NewFppkgCfgFile, Note) <> sddqCompatible) then
|
||||||
|
if IDEMessageDialog(lisCCOWarningCaption,
|
||||||
|
Format(lisTheFppkgConfigurationFileDoesNotLookCorrect, [NewFppkgCfgFile, LineEnding, Note]),
|
||||||
|
mtError, [mbCancel,mbIgnore]) <> mrIgnore
|
||||||
|
then
|
||||||
|
exit(false);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Result:=true;
|
Result:=true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -2585,6 +2585,8 @@ resourcestring
|
|||||||
+'does not look correct:%s%s';
|
+'does not look correct:%s%s';
|
||||||
lisTheLazarusDirectoryDoesNotLookCorrect = 'The Lazarus directory "%s" does '
|
lisTheLazarusDirectoryDoesNotLookCorrect = 'The Lazarus directory "%s" does '
|
||||||
+'not look correct:%s%s';
|
+'not look correct:%s%s';
|
||||||
|
lisTheFppkgConfigurationFileDoesNotLookCorrect = 'The Fppkg configuration file '
|
||||||
|
+'"%s" does not look correct:%s%s';
|
||||||
lisTheContainsANotExistingDirectory = 'The %s contains a nonexistent directory:%s%s';
|
lisTheContainsANotExistingDirectory = 'The %s contains a nonexistent directory:%s%s';
|
||||||
lisTheProjectDoesNotUseTheLCLUnitInterfacesButItSeems = 'The project does '
|
lisTheProjectDoesNotUseTheLCLUnitInterfacesButItSeems = 'The project does '
|
||||||
+'not use the LCL unit interfaces, which is required by LCLBase.%sYou will '
|
+'not use the LCL unit interfaces, which is required by LCLBase.%sYou will '
|
||||||
|
Loading…
Reference in New Issue
Block a user