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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -35,11 +35,10 @@ uses
TreeFilterEdit, IDEWindowIntf, IDEOptionsIntf, IDECommands, IDEHelpIntf,
EnvironmentOpts, LazarusIDEStrConsts, CompOptsIntf, EditorOptions,
{$IFDEF NewBuildModeWindow}
BuildModesManager, project_save_options,
BuildModesManager, project_save_options;
{$ELSE}
BuildModesEditor,
BuildModesEditor;
{$ENDIF}
ProjectIntf;
type
TIDEOptsDlgAction = (
@ -145,9 +144,9 @@ begin
ButtonPanel.HelpButton.OnClick := @HelpButtonClick;
OnKeyPress:=@IDEOptionsDialogKeyPress;
{$IFnDEF NewBuildModeWindow}
BuildModeManageButton.Visible:=False;
{$ENDIF}
{.$IFnDEF NewBuildModeWindow}
//BuildModeManageButton.Visible:=False;
{.$ENDIF}
end;
procedure TIDEOptionsDialog.HelpButtonClick(Sender: TObject);
@ -187,9 +186,11 @@ begin
GroupClass := FindGroupClass(Node);
end;
// Show the Build Mode panel for Compiler Options
{$IFDEF NewBuildModeWindow}
if (GroupClass <> nil) and (GroupClass.InheritsFrom(TLazCompilerOptions)) then
BuildModeSelectPanel.Height:=40
else
{$ENDIF}
BuildModeSelectPanel.Height:=0;
// Hide the old and show the new editor frame
if Assigned(AEditor) then
@ -207,44 +208,10 @@ begin
end;
procedure TIDEOptionsDialog.BuildModeManageButtonClick(Sender: TObject);
{$IFDEF NewBuildModeWindow}
var
BuildModesForm: TBuildModesForm;
ProjectSaveOptions: TProjectSaveOptionsFrame;
Rec: PIDEOptionsGroupRec;
i: Integer;
{$ENDIF}
begin
{$IFDEF NewBuildModeWindow}
BuildModesForm := TBuildModesForm.Create(nil);
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;
if ShowBuildModesDlg = mrOK then begin
end;
{$ENDIF}
end;

View File

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

View File

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