IDE: Make the new build mode dialog work

git-svn-id: trunk@40838 -
This commit is contained in:
juha 2013-04-18 16:56:35 +00:00
parent 2db3f52443
commit 59f2adc660
9 changed files with 262 additions and 249 deletions

View File

@ -1,7 +1,7 @@
object BuildModesForm: TBuildModesForm object BuildModesForm: TBuildModesForm
Left = 473 Left = 337
Height = 366 Height = 366
Top = 550 Top = 564
Width = 612 Width = 612
Caption = 'BuildModesForm' Caption = 'BuildModesForm'
ClientHeight = 366 ClientHeight = 366
@ -19,16 +19,16 @@ object BuildModesForm: TBuildModesForm
Anchors = [akTop, akLeft, akRight, akBottom] Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Around = 6 BorderSpacing.Around = 6
Caption = 'BuildModesGroupBox' Caption = 'BuildModesGroupBox'
ClientHeight = 288 ClientHeight = 276
ClientWidth = 596 ClientWidth = 594
TabOrder = 0 TabOrder = 0
object BuildModesStringGrid: TStringGrid object BuildModesStringGrid: TStringGrid
AnchorSideTop.Control = BuildModeAddSpeedButton AnchorSideTop.Control = BuildModeAddSpeedButton
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 0 Left = 0
Height = 266 Height = 254
Top = 22 Top = 22
Width = 596 Width = 594
Align = alBottom Align = alBottom
Anchors = [akTop, akLeft, akRight, akBottom] Anchors = [akTop, akLeft, akRight, akBottom]
AutoFillColumns = True AutoFillColumns = True
@ -38,19 +38,19 @@ object BuildModesForm: TBuildModesForm
ButtonStyle = cbsCheckboxColumn ButtonStyle = cbsCheckboxColumn
MaxSize = 50 MaxSize = 50
Title.Caption = 'Active' Title.Caption = 'Active'
Width = 197 Width = 196
end end
item item
ButtonStyle = cbsCheckboxColumn ButtonStyle = cbsCheckboxColumn
MaxSize = 50 MaxSize = 50
Title.Caption = 'InSession' Title.Caption = 'InSession'
Width = 197 Width = 196
end end
item item
MaxSize = 500 MaxSize = 500
SizePriority = 100 SizePriority = 100
Title.Caption = 'Title' Title.Caption = 'Title'
Width = 198 Width = 196
end> end>
FixedCols = 0 FixedCols = 0
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goEditing, goSmoothScroll] Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goEditing, goSmoothScroll]
@ -59,9 +59,9 @@ object BuildModesForm: TBuildModesForm
OnSelection = BuildModesStringGridSelection OnSelection = BuildModesStringGridSelection
OnValidateEntry = BuildModesStringGridValidateEntry OnValidateEntry = BuildModesStringGridValidateEntry
ColWidths = ( ColWidths = (
197 196
197 196
198 196
) )
end end
object BuildModeAddSpeedButton: TSpeedButton object BuildModeAddSpeedButton: TSpeedButton
@ -127,17 +127,19 @@ object BuildModesForm: TBuildModesForm
end end
object ButtonPanel1: TButtonPanel object ButtonPanel1: TButtonPanel
Left = 6 Left = 6
Height = 38 Height = 34
Top = 322 Top = 326
Width = 600 Width = 600
OKButton.Name = 'OKButton' OKButton.Name = 'OKButton'
OKButton.DefaultCaption = True OKButton.DefaultCaption = True
OKButton.OnClick = OKButtonClick
HelpButton.Name = 'HelpButton' HelpButton.Name = 'HelpButton'
HelpButton.DefaultCaption = True HelpButton.DefaultCaption = True
CloseButton.Name = 'CloseButton' CloseButton.Name = 'CloseButton'
CloseButton.DefaultCaption = True CloseButton.DefaultCaption = True
CancelButton.Name = 'CancelButton' CancelButton.Name = 'CancelButton'
CancelButton.DefaultCaption = True CancelButton.DefaultCaption = True
CancelButton.OnClick = CancelButtonClick
TabOrder = 1 TabOrder = 1
ShowButtons = [pbOK, pbCancel, pbHelp] ShowButtons = [pbOK, pbCancel, pbHelp]
end end

View File

@ -8,9 +8,8 @@ uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
Grids, Buttons, Menus, ButtonPanel, LCLProc, Grids, Buttons, Menus, ButtonPanel, LCLProc,
ProjectIntf, IDEImagesIntf, IDEOptionsIntf, CompOptsIntf, ProjectIntf, IDEImagesIntf, IDEOptionsIntf, CompOptsIntf,
PackageDefs, TransferMacros, //compiler_inherited_options, PackageDefs, TransferMacros, PathEditorDlg, Project, LazarusIDEStrConsts,
PathEditorDlg, Project, LazarusIDEStrConsts, CompilerOptions, // PackageSystem, CompilerOptions, IDEProcs, BuildModeDiffDlg;
IDEProcs, BuildModeDiffDlg;
type type
@ -26,6 +25,7 @@ type
BuildModesPopupMenu: TPopupMenu; BuildModesPopupMenu: TPopupMenu;
BuildModesStringGrid: TStringGrid; BuildModesStringGrid: TStringGrid;
ButtonPanel1: TButtonPanel; ButtonPanel1: TButtonPanel;
procedure CancelButtonClick(Sender: TObject);
procedure FormCreate(Sender: TObject); procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject); procedure FormDestroy(Sender: TObject);
procedure BuildModeDiffSpeedButtonClick(Sender: TObject); procedure BuildModeDiffSpeedButtonClick(Sender: TObject);
@ -40,43 +40,76 @@ type
procedure BuildModesStringGridValidateEntry(Sender: TObject; procedure BuildModesStringGridValidateEntry(Sender: TObject;
aCol, aRow: Integer; const OldValue: string; var NewValue: String); aCol, aRow: Integer; const OldValue: string; var NewValue: String);
procedure FormShow(Sender: TObject); procedure FormShow(Sender: TObject);
procedure OKButtonClick(Sender: TObject);
private private
FOnLoadOptionsHook: TOnLoadIDEOptions; fActiveBuildMode: TProjectBuildMode;
FOnSaveOptionsHook: TOnSaveIDEOptions; fBuildModes: TProjectBuildModes;
FLoadShowSessionFromProject: boolean;
FProject: TProject;
FShowSession: boolean; FShowSession: boolean;
FSwitchingMode: boolean;
fModeActiveCol: integer; fModeActiveCol: integer;
fModeInSessionCol: integer; fModeInSessionCol: integer;
fModeNameCol: integer; fModeNameCol: integer;
procedure FillBuildModesGrid; procedure FillBuildModesGrid(aOnlyActiveState: Boolean = False);
function GetActiveBuildMode: TProjectBuildMode;
procedure SetActiveBuildMode(AValue: TProjectBuildMode);
procedure UpdateBuildModeButtons; procedure UpdateBuildModeButtons;
procedure ActivateMode(aMode: TProjectBuildMode);
procedure UpdateShowSession;
procedure SetShowSession(const AValue: boolean); procedure SetShowSession(const AValue: boolean);
procedure DoShowSession; procedure DoShowSession;
procedure UpdateDialogCaption; procedure UpdateDialogCaption;
public public
property SwitchingMode: boolean read FSwitchingMode; // the active mode is currently switched constructor Create(AOwner: TComponent); override;
property ShowSession: boolean read FShowSession write SetShowSession; destructor Destroy; override;
property LoadShowSessionFromProject: boolean read FLoadShowSessionFromProject
write FLoadShowSessionFromProject;
function GetSelectedBuildMode: TProjectBuildMode; function GetSelectedBuildMode: TProjectBuildMode;
procedure SetActiveBuildModeByID(AValue: TProjectBuildMode);
public public
property OnLoadIDEOptionsHook: TOnLoadIDEOptions read FOnLoadOptionsHook write FOnLoadOptionsHook; property ActiveBuildMode: TProjectBuildMode read GetActiveBuildMode write SetActiveBuildMode;
property OnSaveIDEOptionsHook: TOnSaveIDEOptions read FOnSaveOptionsHook write FOnSaveOptionsHook; property BuildModes: TProjectBuildModes read fBuildModes;
property ShowSession: boolean read FShowSession write SetShowSession;
end; end;
var function ShowBuildModesDlg: TModalResult;
BuildModesForm: TBuildModesForm;
implementation implementation
{$R *.lfm} {$R *.lfm}
function ShowBuildModesDlg: TModalResult;
var
BuildModesForm: TBuildModesForm;
begin
Assert(Assigned(Project1), 'ShowBuildModesDlg: Project is not assigned.');
Result := mrCancel;
BuildModesForm := TBuildModesForm.Create(nil);
try
BuildModesForm.fBuildModes.Assign(Project1.BuildModes, True); // Copy to dialog.
BuildModesForm.SetActiveBuildModeByID(Project1.ActiveBuildMode);
BuildModesForm.ShowSession:=Project1.SessionStorage in [pssInProjectDir,pssInIDEConfig];
// Show the form. Let user add / edit / delete build modes.
Result := BuildModesForm.ShowModal;
if Result = mrOk then begin
Project1.BuildModes.Assign(BuildModesForm.fBuildModes, True); // Copy back from dialog.
Project1.ActiveBuildModeID:=BuildModesForm.fActiveBuildMode.Identifier;
IncreaseBuildMacroChangeStamp;
end;
finally
BuildModesForm.Free;
end;
end;
{ TBuildModesForm } { TBuildModesForm }
constructor TBuildModesForm.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
fBuildModes := TProjectBuildModes.Create(Nil);
end;
destructor TBuildModesForm.Destroy;
begin
fBuildModes.Free;
inherited Destroy;
end;
procedure TBuildModesForm.FormCreate(Sender: TObject); procedure TBuildModesForm.FormCreate(Sender: TObject);
begin begin
; ;
@ -89,16 +122,13 @@ end;
procedure TBuildModesForm.FormShow(Sender: TObject); procedure TBuildModesForm.FormShow(Sender: TObject);
begin begin
FProject:=Project1; // Now hardcoded.
// modes
UpdateShowSession;
FillBuildModesGrid;
UpdateBuildModeButtons;
// options dialog // options dialog
UpdateDialogCaption; UpdateDialogCaption;
BuildModesGroupBox.Caption:=lisBuildModes; BuildModesGroupBox.Caption:=lisBuildModes;
DoShowSession; DoShowSession;
// modes
FillBuildModesGrid;
UpdateBuildModeButtons;
BuildModeAddSpeedButton.LoadGlyphFromLazarusResource('laz_add'); BuildModeAddSpeedButton.LoadGlyphFromLazarusResource('laz_add');
BuildModeDeleteSpeedButton.LoadGlyphFromLazarusResource('laz_delete'); BuildModeDeleteSpeedButton.LoadGlyphFromLazarusResource('laz_delete');
@ -109,34 +139,23 @@ end;
procedure TBuildModesForm.BuildModeDiffSpeedButtonClick(Sender: TObject); procedure TBuildModesForm.BuildModeDiffSpeedButtonClick(Sender: TObject);
begin begin
FSwitchingMode:=true; // show diff dialog
try ShowBuildModeDiffDialog(GetSelectedBuildMode);
// save changes IncreaseBuildMacroChangeStamp;
OnSaveIDEOptionsHook(Self,FProject.CompilerOptions);
// show diff dialog
ShowBuildModeDiffDialog(GetSelectedBuildMode);
IncreaseBuildMacroChangeStamp;
// load options
OnLoadIDEOptionsHook(Self,FProject.CompilerOptions);
finally
FSwitchingMode:=false;
end;
end; end;
procedure TBuildModesForm.BuildModeAddSpeedButtonClick(Sender: TObject); procedure TBuildModesForm.BuildModeAddSpeedButtonClick(Sender: TObject);
var var
i: Integer; i: Integer;
NewName: String; NewName, Identifier: String;
Identifier: String; CurMode, NewMode: TProjectBuildMode;
CurMode: TProjectBuildMode;
NewMode: TProjectBuildMode;
begin begin
// use current mode as template // use current mode as template
i:=BuildModesStringGrid.Row-1; i:=BuildModesStringGrid.Row-1;
if (i>=0) then if (i>=0) then
begin begin
Identifier:=BuildModesStringGrid.Cells[fModeNameCol,i+1]; Identifier:=BuildModesStringGrid.Cells[fModeNameCol,i+1];
CurMode:=FProject.BuildModes[i]; CurMode:=fBuildModes[i];
end end
else begin else begin
Identifier:='Mode'; Identifier:='Mode';
@ -147,16 +166,14 @@ begin
repeat repeat
inc(i); inc(i);
NewName:=Identifier+IntToStr(i); NewName:=Identifier+IntToStr(i);
until FProject.BuildModes.Find(NewName)=nil; until fBuildModes.Find(NewName)=nil;
// create new mode // create new mode
NewMode:=FProject.BuildModes.Add(NewName); NewMode:=fBuildModes.Add(NewName);
// clone // clone
if CurMode<>nil then if CurMode<>nil then
NewMode.Assign(CurMode); NewMode.Assign(CurMode);
// show fActiveBuildMode:=NewMode; // activate
FillBuildModesGrid; FillBuildModesGrid; // show
// activate
ActivateMode(NewMode);
// select identifier // select identifier
BuildModesStringGrid.Col:=fModeNameCol; BuildModesStringGrid.Col:=fModeNameCol;
BuildModesStringGrid.Row:=BuildModesStringGrid.RowCount-1; BuildModesStringGrid.Row:=BuildModesStringGrid.RowCount-1;
@ -172,27 +189,27 @@ begin
Grid:=BuildModesStringGrid; Grid:=BuildModesStringGrid;
i:=Grid.Row-1; i:=Grid.Row-1;
if i<0 then exit; if i<0 then exit;
if FProject.BuildModes.Count=1 then if fBuildModes.Count=1 then
begin begin
MessageDlg(lisCCOErrorCaption, lisThereMustBeAtLeastOneBuildMode, MessageDlg(lisCCOErrorCaption, lisThereMustBeAtLeastOneBuildMode,
mtError,[mbCancel],0); mtError,[mbCancel],0);
exit; exit;
end; end;
CurMode:=FProject.BuildModes[i]; CurMode:=fBuildModes[i];
// when delete the activated: activate another // when delete the activated: activate another
if FProject.ActiveBuildMode=CurMode then if fActiveBuildMode=CurMode then
begin begin
if i<FProject.BuildModes.Count-1 then if i<fBuildModes.Count-1 then
ActivateMode(FProject.BuildModes[i+1]) fActiveBuildMode:=fBuildModes[i+1]
else else
ActivateMode(FProject.BuildModes[i-1]); fActiveBuildMode:=fBuildModes[i-1];
end; end;
if FProject.ActiveBuildMode=CurMode then begin if fActiveBuildMode=CurMode then begin
debugln(['TBuildModesEditorFrame.BuildModeDeleteSpeedButtonClick activate failed']); debugln(['TBuildModesForm.BuildModeDeleteSpeedButtonClick activate failed']);
exit; exit;
end; end;
// delete mode // delete mode
FProject.BuildModes.Delete(i); fBuildModes.Delete(i);
FillBuildModesGrid; FillBuildModesGrid;
// select next mode // select next mode
if i>=Grid.RowCount then if i>=Grid.RowCount then
@ -206,9 +223,9 @@ var
i: Integer; i: Integer;
begin begin
i:=BuildModesStringGrid.Row-1; i:=BuildModesStringGrid.Row-1;
if i+1>=FProject.BuildModes.Count then exit; if i+1>=fBuildModes.Count then exit;
FProject.BuildModes.Move(i,i+1); fBuildModes.Move(i,i+1);
FProject.BuildModes[0].InSession:=false; fBuildModes[0].InSession:=false;
inc(i); inc(i);
FillBuildModesGrid; FillBuildModesGrid;
BuildModesStringGrid.Row:=i+1; BuildModesStringGrid.Row:=i+1;
@ -220,9 +237,9 @@ var
begin begin
i:=BuildModesStringGrid.Row-1; i:=BuildModesStringGrid.Row-1;
if i<=0 then exit; if i<=0 then exit;
FProject.BuildModes.Move(i,i-1); fBuildModes.Move(i,i-1);
dec(i); dec(i);
FProject.BuildModes[0].InSession:=false; fBuildModes[0].InSession:=false;
FillBuildModesGrid; FillBuildModesGrid;
BuildModesStringGrid.Row:=i+1; BuildModesStringGrid.Row:=i+1;
end; end;
@ -231,32 +248,31 @@ procedure TBuildModesForm.BuildModesCheckboxToggled(Sender: TObject;
aCol, aRow: Integer; aState: TCheckboxState); aCol, aRow: Integer; aState: TCheckboxState);
var var
CurMode: TProjectBuildMode; CurMode: TProjectBuildMode;
b: Boolean;
i: Integer; i: Integer;
Grid: TStringGrid; Grid: TStringGrid;
begin begin
debugln(['TBuildModesForm.BuildModesCheckboxToggled Row=',aRow,' Col=',aCol,' ',ord(aState)]); debugln(['TBuildModesForm.BuildModesCheckboxToggled Row=',aRow,' Col=',aCol,' ',ord(aState)]);
i:=aRow-1; i:=aRow-1;
if (i<0) or (i>=FProject.BuildModes.Count) then exit; if (i<0) or (i>=fBuildModes.Count) then exit;
CurMode:=FProject.BuildModes[i]; CurMode:=fBuildModes[i];
Grid:=BuildModesStringGrid; Grid:=BuildModesStringGrid;
if aCol=fModeActiveCol then if aCol=fModeActiveCol then
begin begin
// activate // activate
if CurMode=FProject.ActiveBuildMode then begin if CurMode=fActiveBuildMode then begin
debugln(['TBuildModesForm.BuildModesCheckboxToggled, is ActiveBuildMode',i]); debugln(['TBuildModesForm.BuildModesCheckboxToggled, is ActiveBuildMode',i]);
// there must always be an active mode // Switch back to Checked state. There must always be an active mode
Grid.Cells[aCol,aRow]:=Grid.Columns[aCol].ValueChecked; Grid.Cells[aCol,aRow]:=Grid.Columns[aCol].ValueChecked;
end end
else begin else begin
debugln(['TBuildModesForm.BuildModesCheckboxToggled, another Mode',i]); debugln(['TBuildModesForm.BuildModesCheckboxToggled, another Mode',i]);
ActivateMode(CurMode); fActiveBuildMode:=CurMode;
FillBuildModesGrid(True);
end; end;
end else if aCol=fModeInSessionCol then end else if aCol=fModeInSessionCol then
begin begin
// in session // in session
b:=aState=cbChecked; if (aState=cbChecked) and (i=0) then
if b and (i=0) then
begin begin
Grid.Cells[aCol,aRow]:=Grid.Columns[aCol].ValueUnchecked; Grid.Cells[aCol,aRow]:=Grid.Columns[aCol].ValueUnchecked;
MessageDlg(lisCCOErrorCaption, MessageDlg(lisCCOErrorCaption,
@ -264,7 +280,7 @@ begin
mtError,[mbCancel],0); mtError,[mbCancel],0);
exit; exit;
end; end;
CurMode.InSession:=b; CurMode.InSession:=aState=cbChecked;
end; end;
end; end;
@ -279,14 +295,13 @@ procedure TBuildModesForm.BuildModesStringGridValidateEntry(Sender: TObject;
var var
CurMode: TProjectBuildMode; CurMode: TProjectBuildMode;
s: string; s: string;
j: Integer;
b: Boolean;
i: Integer; i: Integer;
b: Boolean;
begin begin
debugln(['TBuildModesForm.BuildModesStringGridValidateEntry Row=',aRow,' Col=',aCol]); debugln(['TBuildModesForm.BuildModesStringGridValidateEntry Row=',aRow,' Col=',aCol]);
i:=aRow-1; i:=aRow-1;
if (i<0) or (i>=FProject.BuildModes.Count) then exit; if (i<0) or (i>=fBuildModes.Count) then exit;
CurMode:=FProject.BuildModes[i]; CurMode:=fBuildModes[i];
if aCol=fModeInSessionCol then if aCol=fModeInSessionCol then
begin begin
// in session // in session
@ -304,42 +319,43 @@ begin
begin begin
// identifier // identifier
s:=NewValue; s:=NewValue;
for j:=1 to length(s) do for i:=1 to length(s) do
if s[j]<' ' then if s[i]<' ' then
s[j]:=' '; s[i]:=' ';
CurMode.Identifier:=s; CurMode.Identifier:=s;
NewValue:=s; NewValue:=s;
end; end;
UpdateDialogCaption; UpdateDialogCaption;
end; end;
procedure TBuildModesForm.FillBuildModesGrid; procedure TBuildModesForm.FillBuildModesGrid(aOnlyActiveState: Boolean);
var var
i: Integer; i: Integer;
CurMode: TProjectBuildMode; CurMode: TProjectBuildMode;
Grid: TStringGrid; Grid: TStringGrid;
begin begin
if FProject=nil then exit;
Grid:=BuildModesStringGrid; Grid:=BuildModesStringGrid;
Grid.BeginUpdate; Grid.BeginUpdate;
Grid.RowCount:=FProject.BuildModes.Count+1; Grid.RowCount:=fBuildModes.Count+1;
for i:=0 to fBuildModes.Count-1 do
for i:=0 to FProject.BuildModes.Count-1 do begin begin
CurMode:=FProject.BuildModes[i]; CurMode:=fBuildModes[i];
// active // active
if CurMode=FProject.ActiveBuildMode then if CurMode=fActiveBuildMode then
Grid.Cells[fModeActiveCol,i+1]:=Grid.Columns[fModeActiveCol].ValueChecked Grid.Cells[fModeActiveCol,i+1]:=Grid.Columns[fModeActiveCol].ValueChecked
else else
Grid.Cells[fModeActiveCol,i+1]:=Grid.Columns[fModeActiveCol].ValueUnchecked; Grid.Cells[fModeActiveCol,i+1]:=Grid.Columns[fModeActiveCol].ValueUnchecked;
// in session if not aOnlyActiveState then
if fModeInSessionCol>=0 then begin
if CurMode.InSession then // in session
Grid.Cells[fModeInSessionCol,i+1]:=Grid.Columns[fModeInSessionCol].ValueChecked if fModeInSessionCol>=0 then
else if CurMode.InSession then
Grid.Cells[fModeInSessionCol,i+1]:=Grid.Columns[fModeInSessionCol].ValueUnchecked; Grid.Cells[fModeInSessionCol,i+1]:=Grid.Columns[fModeInSessionCol].ValueChecked
// identifier else
Grid.Cells[fModeNameCol,i+1]:=CurMode.Identifier; Grid.Cells[fModeInSessionCol,i+1]:=Grid.Columns[fModeInSessionCol].ValueUnchecked;
// identifier
Grid.Cells[fModeNameCol,i+1]:=CurMode.Identifier;
end;
end; end;
Grid.EndUpdate(true); Grid.EndUpdate(true);
end; end;
@ -351,17 +367,16 @@ var
Identifier: string; Identifier: string;
begin begin
i:=BuildModesStringGrid.Row-1; i:=BuildModesStringGrid.Row-1;
if (FProject<>nil) and (FProject.BuildModes<>nil) if (fBuildModes<>nil) and (i>=0) and (i<fBuildModes.Count) then
and (i>=0) and (i<FProject.BuildModes.Count) then
begin begin
CurMode:=FProject.BuildModes[i]; CurMode:=fBuildModes[i];
Identifier:=BuildModesStringGrid.Cells[fModeNameCol,i+1]; Identifier:=BuildModesStringGrid.Cells[fModeNameCol,i+1];
end end
else else
CurMode:=nil; CurMode:=nil;
BuildModeAddSpeedButton.Hint:=Format(lisAddNewBuildModeCopyingSettingsFrom, [Identifier]); BuildModeAddSpeedButton.Hint:=Format(lisAddNewBuildModeCopyingSettingsFrom, [Identifier]);
BuildModeDeleteSpeedButton.Enabled:=(CurMode<>nil) and (FProject.BuildModes.Count>1); BuildModeDeleteSpeedButton.Enabled:=(CurMode<>nil) and (fBuildModes.Count>1);
BuildModeDeleteSpeedButton.Hint:=Format(lisDeleteMode, [Identifier]); BuildModeDeleteSpeedButton.Hint:=Format(lisDeleteMode, [Identifier]);
BuildModeMoveUpSpeedButton.Enabled:=(CurMode<>nil) and (i>0); BuildModeMoveUpSpeedButton.Enabled:=(CurMode<>nil) and (i>0);
BuildModeMoveUpSpeedButton.Hint:=Format(lisMoveOnePositionUp, [Identifier]); BuildModeMoveUpSpeedButton.Hint:=Format(lisMoveOnePositionUp, [Identifier]);
@ -370,30 +385,6 @@ begin
BuildModeDiffSpeedButton.Hint:=lisShowDifferencesBetweenModes; BuildModeDiffSpeedButton.Hint:=lisShowDifferencesBetweenModes;
end; end;
procedure TBuildModesForm.ActivateMode(aMode: TProjectBuildMode);
begin
if aMode=FProject.ActiveBuildMode then exit;
FSwitchingMode:=true;
try
// save changes
OnSaveIDEOptionsHook(Self,FProject.CompilerOptions);
// switch
FProject.ActiveBuildMode:=aMode;
IncreaseBuildMacroChangeStamp;
// load options
OnLoadIDEOptionsHook(Self,FProject.CompilerOptions);
finally
FSwitchingMode:=false;
end;
end;
procedure TBuildModesForm.UpdateShowSession;
begin
if LoadShowSessionFromProject then
ShowSession:=(FProject<>nil)
and (FProject.SessionStorage in [pssInProjectDir,pssInIDEConfig]);
end;
procedure TBuildModesForm.SetShowSession(const AValue: boolean); procedure TBuildModesForm.SetShowSession(const AValue: boolean);
begin begin
if AValue=FShowSession then exit; if AValue=FShowSession then exit;
@ -440,14 +431,14 @@ procedure TBuildModesForm.UpdateDialogCaption;
var var
s: String; s: String;
begin begin
if FProject<>nil then if Project1<>nil then
begin begin
s := FProject.GetTitleOrName; s := Project1.GetTitleOrName;
s:=Format(dlgProjectOptionsFor, [s]); s:=Format(dlgProjectOptionsFor, [s]);
if FProject.BuildModes.Count>1 then if fBuildModes.Count>1 then
s:=s+', '+copy(FProject.ActiveBuildMode.GetCaption,1,12); s:=s+', '+copy(fActiveBuildMode.GetCaption,1,12);
end else end else
s:='TBuildModesEditorFrame.GetDialogCaption: no project'; s:='TBuildModesForm.UpdateDialogCaption: no project';
Caption:=s; Caption:=s;
end; end;
@ -456,10 +447,43 @@ var
i: LongInt; i: LongInt;
begin begin
Result:=nil; Result:=nil;
if FProject=nil then exit;
i:=BuildModesStringGrid.Row-1; i:=BuildModesStringGrid.Row-1;
if (i<0) or (i>=FProject.BuildModes.Count) then exit; if (i<0) or (i>=fBuildModes.Count) then exit;
Result:=FProject.BuildModes[i]; Result:=fBuildModes[i];
end;
procedure TBuildModesForm.OKButtonClick(Sender: TObject);
begin
;
end;
procedure TBuildModesForm.CancelButtonClick(Sender: TObject);
begin
;
end;
function TBuildModesForm.GetActiveBuildMode: TProjectBuildMode;
begin
Result := fActiveBuildMode;
end;
procedure TBuildModesForm.SetActiveBuildMode(AValue: TProjectBuildMode);
begin
fActiveBuildMode := AValue;
end;
procedure TBuildModesForm.SetActiveBuildModeByID(AValue: TProjectBuildMode);
var
i: Integer;
begin
for i:=0 to fBuildModes.Count-1 do
begin
if fBuildModes[i].Identifier=AValue.Identifier then
begin
ActiveBuildMode:=fBuildModes[i];
Break;
end;
end;
end; end;
end. end.

View File

@ -22,6 +22,7 @@ type
procedure chkCustomConfigFileClick(Sender: TObject); procedure chkCustomConfigFileClick(Sender: TObject);
private private
FOptions: TBaseCompilerOptions; FOptions: TBaseCompilerOptions;
FHasProjectCompilerOpts: boolean;
public public
constructor Create(TheOwner: TComponent); override; constructor Create(TheOwner: TComponent); override;
function Check: Boolean; override; function Check: Boolean; override;
@ -56,6 +57,10 @@ var
NewConfigFilePath: String; NewConfigFilePath: String;
AdditionalConfig: String; AdditionalConfig: String;
begin begin
// Project compiler options have changed if BuildMode was changed by user.
if FHasProjectCompilerOpts then
FOptions := Project1.CompilerOptions;
NewDontUseConfigFile := not chkConfigFile.Checked; NewDontUseConfigFile := not chkConfigFile.Checked;
NewCustomConfigFile := chkCustomConfigFile.Checked; NewCustomConfigFile := chkCustomConfigFile.Checked;
NewConfigFilePath := edtConfigPath.Text; NewConfigFilePath := edtConfigPath.Text;
@ -103,6 +108,7 @@ procedure TCompilerOtherOptionsFrame.ReadSettings(AOptions: TAbstractIDEOptions)
begin begin
if FOptions = nil then if FOptions = nil then
FOptions := AOptions as TBaseCompilerOptions; FOptions := AOptions as TBaseCompilerOptions;
FHasProjectCompilerOpts := (AOptions is TProjectCompilerOptions);
with AOptions as TBaseCompilerOptions do with AOptions as TBaseCompilerOptions do
begin begin
chkConfigFile.Checked := not DontUseConfigFile; chkConfigFile.Checked := not DontUseConfigFile;

View File

@ -39,6 +39,7 @@ type
private private
FDialog: TAbstractOptionsEditorDialog; FDialog: TAbstractOptionsEditorDialog;
FCompilerOpts: TBaseCompilerOptions; FCompilerOpts: TBaseCompilerOptions;
FHasProjectCompilerOpts: boolean;
OtherUnitsPathEditBtn: TPathEditorButton; OtherUnitsPathEditBtn: TPathEditorButton;
IncludeFilesPathEditBtn: TPathEditorButton; IncludeFilesPathEditBtn: TPathEditorButton;
OtherSourcesPathEditBtn: TPathEditorButton; OtherSourcesPathEditBtn: TPathEditorButton;
@ -135,9 +136,11 @@ var
Msg: String; Msg: String;
begin begin
Result:=false; Result:=false;
// Project compiler options have changed if BuildMode was changed by user.
if FHasProjectCompilerOpts then
FCompilerOpts := Project1.CompilerOptions;
GetParsedPaths; GetParsedPaths;
OldParsedIncludePath := NewParsedIncludePath; OldParsedIncludePath := NewParsedIncludePath;
OldUnparsedIncludePath := FCompilerOpts.IncludePath; OldUnparsedIncludePath := FCompilerOpts.IncludePath;
OldParsedLibraryPath := NewParsedLibraries; OldParsedLibraryPath := NewParsedLibraries;
@ -747,6 +750,7 @@ begin
if AOptions is TProjectCompilerOptions then if AOptions is TProjectCompilerOptions then
begin begin
FHasProjectCompilerOpts:=True;
ProjTargetFileEdit.Visible:=true; ProjTargetFileEdit.Visible:=true;
ProjTargetFileLabel.Visible:=true; ProjTargetFileLabel.Visible:=true;
ProjTargetFileEdit.Text:=TProjectCompilerOptions(AOptions).TargetFilename; ProjTargetFileEdit.Text:=TProjectCompilerOptions(AOptions).TargetFilename;
@ -755,6 +759,7 @@ begin
LCLWidgetTypeLabel.Visible:=true;; LCLWidgetTypeLabel.Visible:=true;;
UpdateTargetFileLabel; UpdateTargetFileLabel;
end else begin end else begin
FHasProjectCompilerOpts:=False;
ProjTargetFileEdit.Visible:=false; ProjTargetFileEdit.Visible:=false;
ProjTargetFileLabel.Visible:=false; ProjTargetFileLabel.Visible:=false;
ProjTargetApplyConventionsCheckBox.Visible:=false; ProjTargetApplyConventionsCheckBox.Visible:=false;

View File

@ -53,7 +53,7 @@ type
aRow: Integer); aRow: Integer);
private private
FLoadShowSessionFromProject: boolean; FLoadShowSessionFromProject: boolean;
FMacroValues: TProjectBuildMacros; // FMacroValues: TProjectBuildMacros;
FProject: TProject; FProject: TProject;
FShowSession: boolean; FShowSession: boolean;
FSwitchingMode: boolean; FSwitchingMode: boolean;
@ -62,7 +62,6 @@ type
procedure CleanMacrosGrid; procedure CleanMacrosGrid;
procedure SaveMacros(UpdateControls: boolean); procedure SaveMacros(UpdateControls: boolean);
procedure UpdateInheritedOptions; procedure UpdateInheritedOptions;
procedure ActivateMode(aMode: TProjectBuildMode);
procedure UpdateShowSession; procedure UpdateShowSession;
procedure UpdateDialogCaption; procedure UpdateDialogCaption;
function GetDialogCaption: string; function GetDialogCaption: string;
@ -75,7 +74,7 @@ type
procedure WriteSettings(AOptions: TAbstractIDEOptions); override; procedure WriteSettings(AOptions: TAbstractIDEOptions); override;
class function SupportedOptionsClass: TAbstractIDEOptionsClass; override; class function SupportedOptionsClass: TAbstractIDEOptionsClass; override;
property AProject: TProject read FProject; property AProject: TProject read FProject;
property MacroValues: TProjectBuildMacros read FMacroValues; // property MacroValues: TProjectBuildMacros read FMacroValues;
property SwitchingMode: boolean read FSwitchingMode; // the active mode is currently switched property SwitchingMode: boolean read FSwitchingMode; // the active mode is currently switched
property ShowSession: boolean read FShowSession write FShowSession; property ShowSession: boolean read FShowSession write FShowSession;
property LoadShowSessionFromProjects: boolean read FLoadShowSessionFromProject property LoadShowSessionFromProjects: boolean read FLoadShowSessionFromProject
@ -99,7 +98,7 @@ var
i: LongInt; i: LongInt;
Macro: TLazBuildMacro; Macro: TLazBuildMacro;
begin begin
if MacroValues=nil then exit; // if MacroValues=nil then exit;
Grid:=IdeMacroValuesStringGrid; Grid:=IdeMacroValuesStringGrid;
if aCol=0 then begin if aCol=0 then begin
// list all build MacroValues // list all build MacroValues
@ -164,13 +163,13 @@ var
i: Integer; i: Integer;
begin begin
Grid:=IdeMacroValuesStringGrid; Grid:=IdeMacroValuesStringGrid;
Grid.RowCount:=MacroValues.Count+2; // + titles + add button Grid.RowCount:=Project1.MacroValues.Count+2; // + titles + add button
for i:=0 to MacroValues.Count-1 do begin for i:=0 to Project1.MacroValues.Count-1 do begin
Grid.Cells[0,i+1]:=MacroValues.Names[i]; Grid.Cells[0,i+1]:=Project1.MacroValues.Names[i];
Grid.Cells[1,i+1]:=MacroValues.ValueFromIndex(i); Grid.Cells[1,i+1]:=Project1.MacroValues.ValueFromIndex(i);
end; end;
i:=MacroValues.Count+1; i:=Project1.MacroValues.Count+1;
Grid.Cells[0,i]:='(none)'; Grid.Cells[0,i]:='(none)';
Grid.Cells[1,i]:=''; Grid.Cells[1,i]:='';
end; end;
@ -275,7 +274,7 @@ var
Values: TStringList; Values: TStringList;
Value: string; Value: string;
begin begin
if MacroValues=nil then exit; // if MacroValues=nil then exit;
Grid:=IdeMacroValuesStringGrid; Grid:=IdeMacroValuesStringGrid;
Values:=TStringList.Create; Values:=TStringList.Create;
try try
@ -285,9 +284,9 @@ begin
Value:=Grid.Cells[1,aRow]; Value:=Grid.Cells[1,aRow];
Values.Values[MacroName]:=Value; Values.Values[MacroName]:=Value;
end; end;
if not MacroValues.Equals(Values) then begin if not Project1.MacroValues.Equals(Values) then begin
// has changed // has changed
MacroValues.Assign(Values); Project1.MacroValues.Assign(Values);
IncreaseBuildMacroChangeStamp; IncreaseBuildMacroChangeStamp;
if UpdateControls then begin if UpdateControls then begin
UpdateInheritedOptions; UpdateInheritedOptions;
@ -308,23 +307,6 @@ begin
InhOptionCtrl.UpdateInheritedTree(AProject.CompilerOptions); InhOptionCtrl.UpdateInheritedTree(AProject.CompilerOptions);
end; end;
procedure TIdeMacroValuesFrame.ActivateMode(aMode: TProjectBuildMode);
begin
if aMode=AProject.ActiveBuildMode then exit;
FSwitchingMode:=true;
try
// save changes
OnSaveIDEOptions(Self,AProject.CompilerOptions);
// switch
AProject.ActiveBuildMode:=aMode;
IncreaseBuildMacroChangeStamp;
// load options
OnLoadIDEOptions(Self,AProject.CompilerOptions);
finally
FSwitchingMode:=false;
end;
end;
procedure TIdeMacroValuesFrame.UpdateShowSession; procedure TIdeMacroValuesFrame.UpdateShowSession;
begin begin
if LoadShowSessionFromProjects then if LoadShowSessionFromProjects then
@ -369,11 +351,12 @@ begin
if AOptions is TProjectCompilerOptions then begin if AOptions is TProjectCompilerOptions then begin
PCOptions:=TProjectCompilerOptions(AOptions); PCOptions:=TProjectCompilerOptions(AOptions);
FProject:=PCOptions.LazProject; FProject:=PCOptions.LazProject;
FMacroValues:=FProject.ActiveBuildMode.MacroValues; Assert(FProject=Project1, 'TIdeMacroValuesFrame.ReadSettings: FProject<>Project1');
// FMacroValues:=FProject.ActiveBuildMode.MacroValues;
// modes // modes
UpdateShowSession; UpdateShowSession;
// macros // macros
MacroValues.Assign(FProject.MacroValues); // MacroValues.Assign(FProject.MacroValues);
UpdateMacrosControls; UpdateMacrosControls;
// options dialog // options dialog
UpdateDialogCaption; UpdateDialogCaption;

View File

@ -1,4 +1,4 @@
inherited IDEOptionsDialog: TIDEOptionsDialog object IDEOptionsDialog: TIDEOptionsDialog
Left = 121 Left = 121
Height = 404 Height = 404
Top = 96 Top = 96
@ -12,14 +12,15 @@ inherited IDEOptionsDialog: TIDEOptionsDialog
Constraints.MinWidth = 500 Constraints.MinWidth = 500
OnShow = FormShow OnShow = FormShow
Position = poScreenCenter Position = poScreenCenter
object ButtonPanel: TButtonPanel[0] LCLVersion = '1.1'
object ButtonPanel: TButtonPanel
AnchorSideLeft.Control = Owner AnchorSideLeft.Control = Owner
AnchorSideRight.Control = Owner AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner AnchorSideBottom.Control = Owner
Left = 6 Left = 6
Height = 38 Height = 34
Top = 360 Top = 364
Width = 663 Width = 663
BorderSpacing.Left = 6 BorderSpacing.Left = 6
BorderSpacing.Right = 6 BorderSpacing.Right = 6
@ -37,20 +38,20 @@ inherited IDEOptionsDialog: TIDEOptionsDialog
TabOrder = 0 TabOrder = 0
ShowButtons = [pbOK, pbCancel, pbHelp] ShowButtons = [pbOK, pbCancel, pbHelp]
end end
object CatTVSplitter: TSplitter[1] object CatTVSplitter: TSplitter
Left = 255 Left = 255
Height = 360 Height = 364
Top = 0 Top = 0
Width = 4 Width = 4
end end
object CategoryPanel: TPanel[2] object CategoryPanel: TPanel
Left = 0 Left = 0
Height = 360 Height = 364
Top = 0 Top = 0
Width = 255 Width = 255
Align = alLeft Align = alLeft
BevelOuter = bvNone BevelOuter = bvNone
ClientHeight = 360 ClientHeight = 364
ClientWidth = 255 ClientWidth = 255
Constraints.MinWidth = 150 Constraints.MinWidth = 150
TabOrder = 2 TabOrder = 2
@ -62,7 +63,7 @@ inherited IDEOptionsDialog: TIDEOptionsDialog
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = SettingsPanel AnchorSideBottom.Control = SettingsPanel
Left = 6 Left = 6
Height = 304 Height = 308
Top = 36 Top = 36
Width = 249 Width = 249
Anchors = [akTop, akLeft, akRight, akBottom] Anchors = [akTop, akLeft, akRight, akBottom]
@ -89,7 +90,6 @@ inherited IDEOptionsDialog: TIDEOptionsDialog
NumGlyphs = 1 NumGlyphs = 1
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 6 BorderSpacing.Left = 6
Font.Color = clBtnShadow
MaxLength = 0 MaxLength = 0
ParentFont = False ParentFont = False
TabOrder = 1 TabOrder = 1
@ -98,7 +98,7 @@ inherited IDEOptionsDialog: TIDEOptionsDialog
object SettingsPanel: TPanel object SettingsPanel: TPanel
Left = 0 Left = 0
Height = 20 Height = 20
Top = 340 Top = 344
Width = 255 Width = 255
Align = alBottom Align = alBottom
AutoSize = True AutoSize = True
@ -106,7 +106,7 @@ inherited IDEOptionsDialog: TIDEOptionsDialog
TabOrder = 2 TabOrder = 2
end end
end end
object BuildModeSelectPanel: TPanel[3] object BuildModeSelectPanel: TPanel
AnchorSideLeft.Control = CatTVSplitter AnchorSideLeft.Control = CatTVSplitter
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = EditorsPanel AnchorSideRight.Control = EditorsPanel
@ -133,8 +133,8 @@ inherited IDEOptionsDialog: TIDEOptionsDialog
AnchorSideTop.Control = BuildModeLabel AnchorSideTop.Control = BuildModeLabel
AnchorSideTop.Side = asrCenter AnchorSideTop.Side = asrCenter
Left = 87 Left = 87
Height = 25 Height = 23
Top = 5 Top = 6
Width = 154 Width = 154
BorderSpacing.Left = 7 BorderSpacing.Left = 7
ItemHeight = 0 ItemHeight = 0
@ -170,19 +170,19 @@ inherited IDEOptionsDialog: TIDEOptionsDialog
Transparent = False Transparent = False
end end
end end
object EditorsPanel: TScrollBox[4] object EditorsPanel: TScrollBox
AnchorSideLeft.Control = CatTVSplitter AnchorSideLeft.Control = CatTVSplitter
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = BuildModeSelectPanel AnchorSideTop.Control = BuildModeSelectPanel
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideBottom.Control = ButtonPanel AnchorSideBottom.Control = ButtonPanel
Left = 259 Left = 259
Height = 320 Height = 324
Top = 40 Top = 40
Width = 413 Width = 413
HorzScrollBar.Page = 409 HorzScrollBar.Page = 407
HorzScrollBar.Tracking = True HorzScrollBar.Tracking = True
VertScrollBar.Page = 316 VertScrollBar.Page = 318
VertScrollBar.Tracking = True VertScrollBar.Tracking = True
Anchors = [akTop, akLeft, akRight, akBottom] Anchors = [akTop, akLeft, akRight, akBottom]
TabOrder = 4 TabOrder = 4

View File

@ -35,11 +35,10 @@ uses
TreeFilterEdit, IDEWindowIntf, IDEOptionsIntf, IDECommands, IDEHelpIntf, TreeFilterEdit, IDEWindowIntf, IDEOptionsIntf, IDECommands, IDEHelpIntf,
EnvironmentOpts, LazarusIDEStrConsts, CompOptsIntf, EditorOptions, EnvironmentOpts, LazarusIDEStrConsts, CompOptsIntf, EditorOptions,
{$IFDEF NewBuildModeWindow} {$IFDEF NewBuildModeWindow}
BuildModesManager, project_save_options, BuildModesManager, project_save_options;
{$ELSE} {$ELSE}
BuildModesEditor, BuildModesEditor;
{$ENDIF} {$ENDIF}
ProjectIntf;
type type
TIDEOptsDlgAction = ( TIDEOptsDlgAction = (
@ -145,9 +144,9 @@ begin
ButtonPanel.HelpButton.OnClick := @HelpButtonClick; ButtonPanel.HelpButton.OnClick := @HelpButtonClick;
OnKeyPress:=@IDEOptionsDialogKeyPress; OnKeyPress:=@IDEOptionsDialogKeyPress;
{$IFnDEF NewBuildModeWindow} {.$IFnDEF NewBuildModeWindow}
BuildModeManageButton.Visible:=False; //BuildModeManageButton.Visible:=False;
{$ENDIF} {.$ENDIF}
end; end;
procedure TIDEOptionsDialog.HelpButtonClick(Sender: TObject); procedure TIDEOptionsDialog.HelpButtonClick(Sender: TObject);
@ -187,9 +186,11 @@ begin
GroupClass := FindGroupClass(Node); GroupClass := FindGroupClass(Node);
end; end;
// Show the Build Mode panel for Compiler Options // Show the Build Mode panel for Compiler Options
{$IFDEF NewBuildModeWindow}
if (GroupClass <> nil) and (GroupClass.InheritsFrom(TLazCompilerOptions)) then if (GroupClass <> nil) and (GroupClass.InheritsFrom(TLazCompilerOptions)) then
BuildModeSelectPanel.Height:=40 BuildModeSelectPanel.Height:=40
else else
{$ENDIF}
BuildModeSelectPanel.Height:=0; BuildModeSelectPanel.Height:=0;
// Hide the old and show the new editor frame // Hide the old and show the new editor frame
if Assigned(AEditor) then if Assigned(AEditor) then
@ -207,44 +208,10 @@ begin
end; end;
procedure TIDEOptionsDialog.BuildModeManageButtonClick(Sender: TObject); procedure TIDEOptionsDialog.BuildModeManageButtonClick(Sender: TObject);
{$IFDEF NewBuildModeWindow}
var
BuildModesForm: TBuildModesForm;
ProjectSaveOptions: TProjectSaveOptionsFrame;
Rec: PIDEOptionsGroupRec;
i: Integer;
{$ENDIF}
begin begin
{$IFDEF NewBuildModeWindow} {$IFDEF NewBuildModeWindow}
BuildModesForm := TBuildModesForm.Create(nil); if ShowBuildModesDlg = mrOK then begin
try
BuildModesForm.OnLoadIDEOptionsHook := @LoadIDEOptions;
BuildModesForm.OnSaveIDEOptionsHook := @SaveIDEOptions;
{ Does not really work (?)
ProjectSaveOptions:=Nil;
Rec := IDEEditorGroups.GetByIndex(GroupProject);
if Rec <> nil then
begin
for i := 0 to Rec^.Items.Count-1 do begin
if Rec^.Items.Items[i]^.EditorClass = TProjectSaveOptionsFrame then begin
ProjectSaveOptions:=TProjectSaveOptionsFrame(Rec^.Items.Items[i]^.EditorClass);
Break;
end;
end;
end;
if ProjectSaveOptions<>nil then
begin
BuildModesForm.LoadShowSessionFromProject:=false;
BuildModesForm.ShowSession:=ProjectSaveOptions.GetSessionLocation in [pssInIDEConfig,pssInProjectDir];
end;
}
BuildModesForm.LoadShowSessionFromProject:=false;
BuildModesForm.ShowSession:=True;
if BuildModesForm.ShowModal = mrOK then begin
;
end;
finally
BuildModesForm.Free;
end; end;
{$ENDIF} {$ENDIF}
end; end;

View File

@ -133,9 +133,9 @@ uses
compiler_linking_options, compiler_verbosity_options, compiler_messages_options, compiler_linking_options, compiler_verbosity_options, compiler_messages_options,
compiler_other_options, compiler_inherited_options, compiler_compilation_options, compiler_other_options, compiler_inherited_options, compiler_compilation_options,
compiler_buildmacro_options, IdeMacroValues, compiler_buildmacro_options, IdeMacroValues,
{.$IFnDEF NewBuildModeWindow} // remove '.' to remove the BuildModesEditor options frame {$IFnDEF NewBuildModeWindow}
BuildModesEditor, BuildModesEditor,
{.$ENDIF} {$ENDIF}
// package option frames // package option frames
package_usage_options, package_description_options, package_integration_options, package_usage_options, package_description_options, package_integration_options,
package_provides_options, package_i18n_options, package_provides_options, package_i18n_options,
@ -3545,9 +3545,9 @@ end;
procedure TMainIDE.mnuChgBuildModeClicked(Sender: TObject); procedure TMainIDE.mnuChgBuildModeClicked(Sender: TObject);
begin begin
{.$IFnDEF NewBuildModeWindow} // remove '.' to remove the BuildModesEditor options frame {$IFnDEF NewBuildModeWindow}
DoOpenIDEOptions(TBuildModesEditorFrame, '', [TProjectCompilerOptions], []); DoOpenIDEOptions(TBuildModesEditorFrame, '', [TProjectCompilerOptions], []);
{.$ENDIF} {$ENDIF}
end; end;
procedure TMainIDE.mnuSetBuildModeClick(Sender: TObject); procedure TMainIDE.mnuSetBuildModeClick(Sender: TObject);

View File

@ -705,6 +705,7 @@ type
TProjectBuildModes = class(TComponent) TProjectBuildModes = class(TComponent)
private private
FAssigning: Boolean;
FChangeStamp: integer; FChangeStamp: integer;
fSavedChangeStamp: int64; fSavedChangeStamp: int64;
fItems: TFPList; fItems: TFPList;
@ -727,13 +728,15 @@ type
function Add(Identifier: string): TProjectBuildMode; function Add(Identifier: string): TProjectBuildMode;
procedure Move(FromIndex, ToIndex: integer); procedure Move(FromIndex, ToIndex: integer);
function Count: integer; function Count: integer;
property Items[Index: integer]: TProjectBuildMode read GetItems; default;
property ChangeStamp: integer read FChangeStamp;
procedure IncreaseChangeStamp; procedure IncreaseChangeStamp;
procedure AddOnChangedHandler(const Handler: TNotifyEvent); procedure AddOnChangedHandler(const Handler: TNotifyEvent);
procedure RemoveOnChangedHandler(const Handler: TNotifyEvent); procedure RemoveOnChangedHandler(const Handler: TNotifyEvent);
function IsModified(InSession: boolean): boolean; function IsModified(InSession: boolean): boolean;
public
property Items[Index: integer]: TProjectBuildMode read GetItems; default;
property ChangeStamp: integer read FChangeStamp;
property LazProject: TProject read FLazProject write FLazProject; property LazProject: TProject read FLazProject write FLazProject;
property Assigning: Boolean read FAssigning;
property Modified: boolean read GetModified write SetModified; property Modified: boolean read GetModified write SetModified;
end; end;
@ -813,6 +816,7 @@ type
FUpdateLock: integer; FUpdateLock: integer;
FUseAsDefault: Boolean; FUseAsDefault: Boolean;
procedure ClearBuildModes; procedure ClearBuildModes;
function GetActiveBuildModeID: string;
function GetAllEditorsInfo(Index: Integer): TUnitEditorInfo; function GetAllEditorsInfo(Index: Integer): TUnitEditorInfo;
function GetFirstAutoRevertLockedUnit: TUnitInfo; function GetFirstAutoRevertLockedUnit: TUnitInfo;
function GetFirstLoadedUnit: TUnitInfo; function GetFirstLoadedUnit: TUnitInfo;
@ -835,6 +839,7 @@ type
const OldUnitName, NewUnitName: string; const OldUnitName, NewUnitName: string;
CheckIfAllowed: boolean; var Allowed: boolean); CheckIfAllowed: boolean; var Allowed: boolean);
procedure SetActiveBuildMode(const AValue: TProjectBuildMode); procedure SetActiveBuildMode(const AValue: TProjectBuildMode);
procedure SetActiveBuildModeID(aIdent: string);
procedure SetAutoOpenDesignerFormsDisabled(const AValue: boolean); procedure SetAutoOpenDesignerFormsDisabled(const AValue: boolean);
procedure SetEnableI18N(const AValue: boolean); procedure SetEnableI18N(const AValue: boolean);
procedure SetEnableI18NForLFM(const AValue: boolean); procedure SetEnableI18NForLFM(const AValue: boolean);
@ -1046,6 +1051,8 @@ type
public public
property ActiveBuildMode: TProjectBuildMode read FActiveBuildMode property ActiveBuildMode: TProjectBuildMode read FActiveBuildMode
write SetActiveBuildMode; write SetActiveBuildMode;
property ActiveBuildModeID: string read GetActiveBuildModeID
write SetActiveBuildModeID;
property ActiveWindowIndexAtStart: integer read FActiveWindowIndexAtStart property ActiveWindowIndexAtStart: integer read FActiveWindowIndexAtStart
write FActiveWindowIndexAtStart; write FActiveWindowIndexAtStart;
property AutoCreateForms: boolean property AutoCreateForms: boolean
@ -4262,6 +4269,11 @@ begin
ActiveBuildMode:=FBuildModes.Add('default'); ActiveBuildMode:=FBuildModes.Add('default');
end; end;
function TProject.GetActiveBuildModeID: string;
begin
Result := ActiveBuildMode.Identifier;
end;
function TProject.GetFirstUnitWithComponent: TUnitInfo; function TProject.GetFirstUnitWithComponent: TUnitInfo;
begin begin
Result:=fFirst[uilWithComponent]; Result:=fFirst[uilWithComponent];
@ -5168,15 +5180,12 @@ end;
procedure TProject.SetActiveBuildMode(const AValue: TProjectBuildMode); procedure TProject.SetActiveBuildMode(const AValue: TProjectBuildMode);
begin begin
if FActiveBuildMode=AValue then exit; if FActiveBuildMode=AValue then exit;
if FCompilerOptions<>nil then
FCompilerOptions.ParsedOpts.InvalidateParseOnChange:=false;
FActiveBuildMode:=AValue; FActiveBuildMode:=AValue;
if FActiveBuildMode<>nil then if FActiveBuildMode<>nil then
begin begin
FMacroValues:=FActiveBuildMode.MacroValues; FMacroValues:=FActiveBuildMode.MacroValues;
FCompilerOptions:=FActiveBuildMode.CompilerOptions; FCompilerOptions:=FActiveBuildMode.CompilerOptions;
FLazCompilerOptions:=FCompilerOptions; FLazCompilerOptions:=FCompilerOptions;
FCompilerOptions.ParsedOpts.InvalidateParseOnChange:=true;
end else begin end else begin
FCompilerOptions:=nil; FCompilerOptions:=nil;
FLazCompilerOptions:=nil; FLazCompilerOptions:=nil;
@ -5187,6 +5196,20 @@ begin
IncreaseBuildMacroChangeStamp; IncreaseBuildMacroChangeStamp;
end; end;
procedure TProject.SetActiveBuildModeID(aIdent: string);
var
i: Integer;
begin
for i:=0 to BuildModes.Count-1 do
begin
if BuildModes[i].Identifier=aIdent then
begin
ActiveBuildMode:=BuildModes[i];
Break;
end;
end;
end;
procedure TProject.SetAutoOpenDesignerFormsDisabled(const AValue: boolean); procedure TProject.SetAutoOpenDesignerFormsDisabled(const AValue: boolean);
begin begin
if FAutoOpenDesignerFormsDisabled=AValue then exit; if FAutoOpenDesignerFormsDisabled=AValue then exit;
@ -5909,7 +5932,7 @@ begin
if CustomOptions=AValue then exit; if CustomOptions=AValue then exit;
InvalidateOptions; InvalidateOptions;
inherited SetCustomOptions(AValue); inherited SetCustomOptions(AValue);
if IsActive and (LazProject<>nil) then if IsActive then
LazProject.DefineTemplates.CustomDefinesChanged; LazProject.DefineTemplates.CustomDefinesChanged;
end; end;
@ -5960,7 +5983,7 @@ begin
if UnitOutputDirectory=AValue then exit; if UnitOutputDirectory=AValue then exit;
InvalidateOptions; InvalidateOptions;
inherited SetUnitOutputDir(AValue); inherited SetUnitOutputDir(AValue);
if IsActive and (LazProject<>nil) then if IsActive then
LazProject.DefineTemplates.OutputDirectoryChanged; LazProject.DefineTemplates.OutputDirectoryChanged;
end; end;
@ -6068,7 +6091,8 @@ end;
function TProjectCompilerOptions.IsActive: boolean; function TProjectCompilerOptions.IsActive: boolean;
begin begin
Result:=(LazProject<>nil) and (LazProject.CompilerOptions=Self); Result:=(LazProject<>nil) and (LazProject.CompilerOptions=Self)
and not LazProject.BuildModes.Assigning;
end; end;
procedure TProjectCompilerOptions.Clear; procedure TProjectCompilerOptions.Clear;
@ -7097,6 +7121,7 @@ var
CurMode: TProjectBuildMode; CurMode: TProjectBuildMode;
begin begin
if Source is TProjectBuildModes then begin if Source is TProjectBuildModes then begin
FAssigning:=True;
OtherModes:=TProjectBuildModes(Source); OtherModes:=TProjectBuildModes(Source);
Clear; Clear;
for i:=0 to OtherModes.Count-1 do for i:=0 to OtherModes.Count-1 do
@ -7108,6 +7133,7 @@ begin
end; end;
if WithModified then if WithModified then
Modified:=OtherModes.Modified; Modified:=OtherModes.Modified;
FAssigning:=False;
end else end else
inherited Assign(Source); inherited Assign(Source);
end; end;