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
AnchorSideTop.Control = chkCompilerCompile
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = grpCompiler
AnchorSideRight.Side = asrBottom
Left = 86
AnchorSideRight.Control = BrowseCompilerButton
Left = 80
Height = 27
Top = 36
Width = 503
Width = 488
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 12
BorderSpacing.Around = 6
BorderSpacing.Top = 6
BorderSpacing.Bottom = 6
ItemHeight = 0
TabOrder = 3
Text = 'cobCompiler'
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
object ExecuteBeforeGroupBox: TGroupBox
AnchorSideLeft.Control = Owner

View File

@ -5,14 +5,17 @@ unit compiler_compilation_options;
interface
uses
Controls, StdCtrls, IDEOptionsIntf, Project, CompilerOptions, CompOptsIntf,
PackageDefs, LazarusIDEStrConsts, EnvironmentOpts, LazConf, IDEProcs;
Controls, StdCtrls, Dialogs, IDEOptionsIntf, Project, CompilerOptions,
CompOptsIntf, IDEDialogs, FileProcs, DefineTemplates, CodeToolManager,
PackageDefs, LazarusIDEStrConsts, EnvironmentOpts, LazConf, IDEProcs,
InputHistory, InitialSetupDlgs, Classes, sysutils;
type
{ TCompilerCompilationOptionsFrame }
TCompilerCompilationOptionsFrame = class(TAbstractIDEOptionsEditor)
BrowseCompilerButton: TButton;
chkCompilerBuild: TCheckBox;
chkCompilerCompile: TCheckBox;
chkCompilerRun: TCheckBox;
@ -43,6 +46,7 @@ type
lblRunIfCompiler: TLabel;
lblRunIfExecAfter: TLabel;
lblRunIfExecBefore: TLabel;
procedure BrowseCompilerButtonClick(Sender: TObject);
private
public
function GetTitle: string; override;
@ -58,6 +62,52 @@ implementation
{ 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;
begin
Result := dlgCOCompilerCommands;
@ -80,15 +130,16 @@ begin
lblRunIfExecBefore.Caption := lisCOCallOn;
grpCompiler.Caption := lisCompiler;
lblRunIfCompiler.Caption := lisCOCallOn;
chkCompilerBuild.Caption := lisBuildStage;
chkCompilerBuild.Checked := True;
chkCompilerCompile.Caption := lisCompileStage;
chkCompilerCompile.Checked := True;
chkCompilerRun.Caption := lisRunStage;
chkCompilerRun.Checked := True;
cobCompiler.Text := '';
lblCompiler.Caption := lisCOCommand;
lblRunIfCompiler.Caption := lisCOCallOn;
cobCompiler.Text := '';
BrowseCompilerButton.Hint:='Browse and select a compiler (e.g. ppcx64'+ExeExt+')';
ExecuteAfterGroupBox.Caption := lisCOExecuteAfter;
chkExecAfterBuild.Caption := lisBuildStage;