IDE: project options: compiler path: button to browse

git-svn-id: trunk@44138 -
This commit is contained in:
mattias 2014-02-18 17:10:30 +00:00
parent 37556f70b9
commit 62446ddbd8
2 changed files with 79 additions and 9 deletions

View File

@ -252,19 +252,38 @@ object CompilerCompilationOptionsFrame: TCompilerCompilationOptionsFrame
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = chkCompilerCompile AnchorSideTop.Control = chkCompilerCompile
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = grpCompiler AnchorSideRight.Control = BrowseCompilerButton
AnchorSideRight.Side = asrBottom Left = 80
Left = 86
Height = 27 Height = 27
Top = 36 Top = 36
Width = 503 Width = 488
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 12 BorderSpacing.Left = 12
BorderSpacing.Around = 6 BorderSpacing.Top = 6
BorderSpacing.Bottom = 6
ItemHeight = 0 ItemHeight = 0
TabOrder = 3 TabOrder = 3
Text = 'cobCompiler' Text = 'cobCompiler'
end end
object BrowseCompilerButton: TButton
AnchorSideTop.Control = cobCompiler
AnchorSideRight.Control = grpCompiler
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = cobCompiler
AnchorSideBottom.Side = asrBottom
Left = 568
Height = 27
Top = 36
Width = 21
Anchors = [akTop, akRight, akBottom]
AutoSize = True
BorderSpacing.Right = 6
Caption = '...'
OnClick = BrowseCompilerButtonClick
ParentShowHint = False
ShowHint = True
TabOrder = 4
end
end end
object ExecuteBeforeGroupBox: TGroupBox object ExecuteBeforeGroupBox: TGroupBox
AnchorSideLeft.Control = Owner AnchorSideLeft.Control = Owner

View File

@ -5,14 +5,17 @@ unit compiler_compilation_options;
interface interface
uses uses
Controls, StdCtrls, IDEOptionsIntf, Project, CompilerOptions, CompOptsIntf, Controls, StdCtrls, Dialogs, IDEOptionsIntf, Project, CompilerOptions,
PackageDefs, LazarusIDEStrConsts, EnvironmentOpts, LazConf, IDEProcs; CompOptsIntf, IDEDialogs, FileProcs, DefineTemplates, CodeToolManager,
PackageDefs, LazarusIDEStrConsts, EnvironmentOpts, LazConf, IDEProcs,
InputHistory, InitialSetupDlgs, Classes, sysutils;
type type
{ TCompilerCompilationOptionsFrame } { TCompilerCompilationOptionsFrame }
TCompilerCompilationOptionsFrame = class(TAbstractIDEOptionsEditor) TCompilerCompilationOptionsFrame = class(TAbstractIDEOptionsEditor)
BrowseCompilerButton: TButton;
chkCompilerBuild: TCheckBox; chkCompilerBuild: TCheckBox;
chkCompilerCompile: TCheckBox; chkCompilerCompile: TCheckBox;
chkCompilerRun: TCheckBox; chkCompilerRun: TCheckBox;
@ -43,6 +46,7 @@ type
lblRunIfCompiler: TLabel; lblRunIfCompiler: TLabel;
lblRunIfExecAfter: TLabel; lblRunIfExecAfter: TLabel;
lblRunIfExecBefore: TLabel; lblRunIfExecBefore: TLabel;
procedure BrowseCompilerButtonClick(Sender: TObject);
private private
public public
function GetTitle: string; override; function GetTitle: string; override;
@ -58,6 +62,52 @@ implementation
{ TCompilerCompilationOptionsFrame } { TCompilerCompilationOptionsFrame }
procedure TCompilerCompilationOptionsFrame.BrowseCompilerButtonClick(
Sender: TObject);
var
OpenDialog: TOpenDialog;
AFilename: string;
Quality: TSDFilenameQuality;
Note: string;
begin
OpenDialog:=TOpenDialog.Create(nil);
try
InputHistories.ApplyFileDialogSettings(OpenDialog);
OpenDialog.Options:=OpenDialog.Options+[ofPathMustExist];
// set title
if Sender=BrowseCompilerButton then
OpenDialog.Title:=Format(lisChooseCompilerPath,[GetDefaultCompilerFilename])
else
exit;
if OpenDialog.Execute then begin
AFilename:=CleanAndExpandFilename(OpenDialog.Filename);
if Sender=BrowseCompilerButton then begin
// check compiler filename
if IsFPCExecutable(AFilename) then begin
// check compiler
Quality:=CheckCompilerQuality(AFilename,Note,
CodeToolBoss.FPCDefinesCache.TestFilename);
if Quality<>sddqCompatible then begin
if IDEMessageDialog(lisCCOWarningCaption, Format(
lisTheCompilerFileDoesNotLookCorrect, [AFilename, #13, Note]),
mtWarning,[mbIgnore,mbCancel])<>mrIgnore
then
exit;
end;
end else begin
// maybe a script
end;
SetComboBoxText(cobCompiler,AFilename,cstFilename);
end;
end;
InputHistories.StoreFileDialogSettings(OpenDialog);
finally
OpenDialog.Free;
end;
end;
function TCompilerCompilationOptionsFrame.GetTitle: string; function TCompilerCompilationOptionsFrame.GetTitle: string;
begin begin
Result := dlgCOCompilerCommands; Result := dlgCOCompilerCommands;
@ -80,15 +130,16 @@ begin
lblRunIfExecBefore.Caption := lisCOCallOn; lblRunIfExecBefore.Caption := lisCOCallOn;
grpCompiler.Caption := lisCompiler; grpCompiler.Caption := lisCompiler;
lblRunIfCompiler.Caption := lisCOCallOn;
chkCompilerBuild.Caption := lisBuildStage; chkCompilerBuild.Caption := lisBuildStage;
chkCompilerBuild.Checked := True; chkCompilerBuild.Checked := True;
chkCompilerCompile.Caption := lisCompileStage; chkCompilerCompile.Caption := lisCompileStage;
chkCompilerCompile.Checked := True; chkCompilerCompile.Checked := True;
chkCompilerRun.Caption := lisRunStage; chkCompilerRun.Caption := lisRunStage;
chkCompilerRun.Checked := True; chkCompilerRun.Checked := True;
cobCompiler.Text := '';
lblCompiler.Caption := lisCOCommand; lblCompiler.Caption := lisCOCommand;
lblRunIfCompiler.Caption := lisCOCallOn; cobCompiler.Text := '';
BrowseCompilerButton.Hint:='Browse and select a compiler (e.g. ppcx64'+ExeExt+')';
ExecuteAfterGroupBox.Caption := lisCOExecuteAfter; ExecuteAfterGroupBox.Caption := lisCOExecuteAfter;
chkExecAfterBuild.Caption := lisBuildStage; chkExecAfterBuild.Caption := lisBuildStage;