mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-10 21:30:35 +02:00
IDE: Enable fppkg configuration file selection. Issue #40850, patch by Peacoor.
This commit is contained in:
parent
b4fe56e351
commit
30950b1cc2
@ -407,7 +407,7 @@ object FilesOptionsFrame: TFilesOptionsFrame
|
||||
Width = 23
|
||||
Anchors = [akTop, akRight, akBottom]
|
||||
Caption = '...'
|
||||
OnClick = FilesButtonClick
|
||||
OnClick = FppkgConfigurationFileButtonClick
|
||||
ParentShowHint = False
|
||||
ShowHint = True
|
||||
TabOrder = 17
|
||||
|
@ -81,6 +81,7 @@ type
|
||||
procedure CompilerTranslationFileButtonClick(Sender:TObject);
|
||||
procedure FilesButtonClick(Sender: TObject);
|
||||
procedure DirectoriesButtonClick(Sender: TObject);
|
||||
procedure FppkgConfigurationFileButtonClick(Sender: TObject);
|
||||
procedure ShowCompileDialogCheckBoxChange(Sender: TObject);
|
||||
private
|
||||
FOldLazarusDir: string;
|
||||
@ -104,6 +105,7 @@ type
|
||||
function CheckTestDir: boolean;
|
||||
function CheckMake: boolean;
|
||||
function CheckFPCMsgFile: boolean;
|
||||
function CheckFppkgConfigurationFile: boolean;
|
||||
public
|
||||
function Check: Boolean; override;
|
||||
function GetTitle: String; override;
|
||||
@ -135,15 +137,16 @@ begin
|
||||
if Sender = CompilerPathButton then begin
|
||||
OpenDialog.Title := Format(lisChooseCompilerExecutable,[GetDefaultCompilerFilename]);
|
||||
lDirText := CompilerPathComboBox.Text;
|
||||
lDirName := EnvironmentOptions.GetParsedValue(eopCompilerFilename, lDirText);
|
||||
end
|
||||
else if Sender=MakePathButton then begin
|
||||
OpenDialog.Title := lisChooseMakeExecutable;
|
||||
lDirText := MakePathComboBox.Text;
|
||||
lDirName := EnvironmentOptions.GetParsedValue(eopMakeFilename, lDirText);
|
||||
end
|
||||
else
|
||||
exit;
|
||||
|
||||
lDirName := EnvironmentOptions.GetParsedValue(eopCompilerFilename, lDirText);
|
||||
lExpandedName := CleanAndExpandFilename(lDirName);
|
||||
lDirName := GetValidDirectoryAndFilename(lDirName, {out} lDirNameF);
|
||||
OpenDialog.InitialDir := lDirName;
|
||||
@ -171,6 +174,78 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
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
|
||||
OpenDialog: TSelectDirectoryDialog;
|
||||
lDirName, loDirNameF, lExpandedName: string;
|
||||
begin
|
||||
OpenDialog := TSelectDirectoryDialog.Create(nil);
|
||||
try
|
||||
InputHistories.ApplyFileDialogSettings(OpenDialog);
|
||||
OpenDialog.Options := OpenDialog.Options+[ofExtensionDifferent, ofPathMustExist];
|
||||
// set title
|
||||
if Sender = LazarusDirButton then begin
|
||||
OpenDialog.Title := lisChooseLazarusSourceDirectory;
|
||||
lDirText := LazarusDirComboBox.Text;
|
||||
lDirName := ParsedDirName(eopLazarusDirectory);
|
||||
end
|
||||
else if Sender = FPCSourceDirButton then begin
|
||||
OpenDialog.Title := lisChooseFPCSourceDir;
|
||||
lDirText := FPCSourceDirComboBox.Text;
|
||||
lDirName := ParsedDirName(eopFPCSourceDirectory);
|
||||
end
|
||||
else if Sender=TestBuildDirButton then begin
|
||||
OpenDialog.Title := lisChooseTestBuildDir;
|
||||
lDirText := TestBuildDirComboBox.Text;
|
||||
lDirName := ParsedDirName(eopTestBuildDirectory);
|
||||
end
|
||||
else
|
||||
exit;
|
||||
|
||||
lExpandedName := CleanAndExpandDirectory(lDirName);
|
||||
lDirName := GetValidDirectoryAndFilename(lDirName, loDirNameF);
|
||||
|
||||
OpenDialog.InitialDir := IncludeTrailingBackslash(lDirName);
|
||||
OpenDialog.FileName := loDirNameF;
|
||||
|
||||
if OpenDialog.Execute then begin
|
||||
lDirName := CleanAndExpandDirectory(OpenDialog.Filename);
|
||||
if UpperCase(lDirName)<>UpperCase(lExpandedName) then begin
|
||||
lDirText := lDirName;
|
||||
if Sender = LazarusDirButton then begin
|
||||
// check lazarus directory
|
||||
SetComboBoxText(LazarusDirComboBox,lDirText,cstFilename);
|
||||
CheckLazarusDir([mbOk]);
|
||||
end
|
||||
else if Sender = FPCSourceDirButton then begin
|
||||
// check fpc source directory
|
||||
SetComboBoxText(FPCSourceDirComboBox,lDirText,cstFilename);
|
||||
CheckFPCSourceDir([mbOK]);
|
||||
end
|
||||
else if Sender = TestBuildDirButton then begin
|
||||
// check test directory
|
||||
SetComboBoxText(TestBuildDirComboBox,lDirText,cstFilename);
|
||||
CheckTestDir;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
InputHistories.StoreFileDialogSettings(OpenDialog);
|
||||
finally
|
||||
OpenDialog.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TFilesOptionsFrame.CompilerTranslationFileButtonClick(Sender:TObject);
|
||||
var
|
||||
OpenDialog: TOpenDialog;
|
||||
@ -193,64 +268,21 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TFilesOptionsFrame.DirectoriesButtonClick(Sender: TObject);
|
||||
procedure TFilesOptionsFrame.FppkgConfigurationFileButtonClick(Sender: TObject);
|
||||
var
|
||||
OpenDialog: TSelectDirectoryDialog;
|
||||
lDirText : string;
|
||||
lExpandedName: string;
|
||||
lDirName, loDirNameF: string;
|
||||
OpenDialog: TOpenDialog;
|
||||
AFilename: string;
|
||||
begin
|
||||
OpenDialog := TSelectDirectoryDialog.Create(nil);
|
||||
OpenDialog:=IDEOpenDialogClass.Create(nil);
|
||||
try
|
||||
InputHistories.ApplyFileDialogSettings(OpenDialog);
|
||||
OpenDialog.Options := OpenDialog.Options+[ofExtensionDifferent, ofPathMustExist];
|
||||
// set title
|
||||
if Sender = LazarusDirButton then begin
|
||||
OpenDialog.Title := lisChooseLazarusSourceDirectory;
|
||||
lDirText := LazarusDirComboBox.Text;
|
||||
end
|
||||
else if Sender = FPCSourceDirButton then begin
|
||||
OpenDialog.Title := lisChooseFPCSourceDir;
|
||||
lDirText := FPCSourceDirComboBox.Text;
|
||||
end
|
||||
else if Sender=TestBuildDirButton then begin
|
||||
OpenDialog.Title := lisChooseTestBuildDir;
|
||||
lDirText := TestBuildDirComboBox.Text;
|
||||
end
|
||||
else
|
||||
exit;
|
||||
|
||||
if lDirText = '' then
|
||||
lDirName := EnvironmentOptions.GetParsedValue(eopLazarusDirectory, '')
|
||||
else
|
||||
lDirName := EnvironmentOptions.GetParsedValue(eopLazarusDirectory, lDirText);
|
||||
|
||||
lExpandedName := CleanAndExpandDirectory(lDirName);
|
||||
lDirName := GetValidDirectoryAndFilename(lDirName, loDirNameF);
|
||||
|
||||
OpenDialog.InitialDir := IncludeTrailingBackslash(lDirName);
|
||||
OpenDialog.FileName := loDirNameF;
|
||||
|
||||
OpenDialog.Options:=OpenDialog.Options+[ofPathMustExist];
|
||||
OpenDialog.Title:=lisChooseFppkgConfigurationFile;
|
||||
OpenDialog.Filter:=dlgFilterFppkgConfigurationFile+' (*.cfg)|*.cfg|'+
|
||||
dlgFilterAll+'|'+GetAllFilesMask;
|
||||
if OpenDialog.Execute then begin
|
||||
lDirName := CleanAndExpandDirectory(OpenDialog.Filename);
|
||||
if UpperCase(lDirName)<>UpperCase(lExpandedName) then begin
|
||||
lDirText := lDirName;
|
||||
if Sender = LazarusDirButton then begin
|
||||
// check lazarus directory
|
||||
SetComboBoxText(LazarusDirComboBox,lDirText,cstFilename);
|
||||
CheckLazarusDir([mbOk]);
|
||||
end
|
||||
else if Sender = FPCSourceDirButton then begin
|
||||
// check fpc source directory
|
||||
SetComboBoxText(FPCSourceDirComboBox,lDirText,cstFilename);
|
||||
CheckFPCSourceDir([mbOK]);
|
||||
end
|
||||
else if Sender = TestBuildDirButton then begin
|
||||
// check test directory
|
||||
SetComboBoxText(TestBuildDirComboBox,lDirText,cstFilename);
|
||||
CheckTestDir;
|
||||
end;
|
||||
end;
|
||||
AFilename:=CleanAndExpandFilename(OpenDialog.Filename);
|
||||
SetComboBoxText(FppkgConfigurationFileComboBox,AFilename,cstFilename);
|
||||
end;
|
||||
InputHistories.StoreFileDialogSettings(OpenDialog);
|
||||
finally
|
||||
@ -350,6 +382,8 @@ begin
|
||||
if not CheckTestDir then exit;
|
||||
// check fpc messages file
|
||||
if not CheckFPCMsgFile then exit;
|
||||
// check fppkg configuration file
|
||||
if not CheckFppkgConfigurationFile then exit;
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
@ -593,6 +627,25 @@ begin
|
||||
Result:=true;
|
||||
end;
|
||||
|
||||
function TFilesOptionsFrame.CheckFppkgConfigurationFile: boolean;
|
||||
var
|
||||
NewFppkgCfgFile: String;
|
||||
begin
|
||||
if EnvironmentOptions.FppkgConfigFile=fOldFppkcConfigurationFilename then exit(true);
|
||||
EnvironmentOptions.FppkgConfigFile:=FppkgConfigurationFileComboBox.Text;
|
||||
if EnvironmentOptions.FppkgConfigFile<>'' then begin
|
||||
NewFppkgCfgFile:=EnvironmentOptions.GetParsedFppkgConfig;
|
||||
if not FileExistsUTF8(NewFppkgCfgFile) then begin
|
||||
if IDEMessageDialog(lisCCOErrorCaption, Format(
|
||||
lisFppkgConfigurationFileNotFound, [#13, NewFppkgCfgFile]), mtError, [mbCancel,
|
||||
mbIgnore])<>mrIgnore
|
||||
then
|
||||
exit(false);
|
||||
end;
|
||||
end;
|
||||
Result:=true;
|
||||
end;
|
||||
|
||||
class function TFilesOptionsFrame.SupportedOptionsClass: TAbstractIDEOptionsClass;
|
||||
begin
|
||||
Result := TEnvironmentOptions;
|
||||
|
@ -1068,6 +1068,7 @@ resourcestring
|
||||
lisChooseDebuggerExecutable = 'Choose debugger executable';
|
||||
lisChooseTestBuildDir = 'Choose the directory for tests';
|
||||
lisChooseExecutable = 'Choose an executable';
|
||||
lisChooseFppkgConfigurationFile = 'Choose the fppkg configuration file';
|
||||
|
||||
// dialogs
|
||||
lisProjectChanged = 'Project changed';
|
||||
@ -1571,6 +1572,7 @@ resourcestring
|
||||
dlgFilterPascalFile = 'Pascal file';
|
||||
dlgFilterDciFile = 'DCI file';
|
||||
dlgFilterFPCMessageFile = 'FPC message file';
|
||||
dlgFilterFppkgConfigurationFile = 'Fppkg configuration file';
|
||||
dlgFilterCodetoolsTemplateFile = 'CodeTools template file';
|
||||
dlgFilterImagesPng = 'PNG images';
|
||||
dlgFilterImagesBitmap = 'Bitmap images';
|
||||
@ -2529,6 +2531,7 @@ resourcestring
|
||||
lisUnableToReadProcessExitStatus = 'unable to read process ExitStatus';
|
||||
lisFreeingBufferLines = 'freeing buffer lines: %s';
|
||||
lisCompilerMessagesFileNotFound = 'Compiler messages file not found:%s%s';
|
||||
lisFppkgConfigurationFileNotFound = 'Fppkg configuration file not found:%s%s';
|
||||
lisUnableToOpen = 'Unable to open "%s"';
|
||||
lisCompilerDoesNotSupportTarget = 'Compiler "%s" does not support target %s-%s';
|
||||
lisInvalidMode = 'Invalid mode %s';
|
||||
|
Loading…
Reference in New Issue
Block a user