diff --git a/components/ideintf/projectintf.pas b/components/ideintf/projectintf.pas index 190b28846f..24d4eeecb0 100644 --- a/components/ideintf/projectintf.pas +++ b/components/ideintf/projectintf.pas @@ -260,6 +260,7 @@ type TProjectSessionStorages = set of TProjectSessionStorage; const + pssHasSeparateSession = [pssInProjectDir,pssInIDEConfig]; DefaultProjectCleanOutputFileMask = '*'; DefaultProjectCleanSourcesFileMask = '*.ppu;*.ppl;*.o;*.or'; DefaultProjectSessionStorage = pssInProjectInfo; // this value is not saved to the lpi file diff --git a/ide/buildmodesmanager.pas b/ide/buildmodesmanager.pas index 7c84759874..4ac3b1c5ed 100644 --- a/ide/buildmodesmanager.pas +++ b/ide/buildmodesmanager.pas @@ -121,19 +121,24 @@ procedure UpdateBuildModeCombo(aCombo: TComboBox); var i, ActiveIndex: Integer; CurMode: TProjectBuildMode; + sl: TStringList; begin ActiveIndex := 0; - aCombo.Clear; - aCombo.Items.Add(lisAllBuildModes); - for i := 0 to Project1.BuildModes.Count-1 do - begin - CurMode := Project1.BuildModes[i]; - aCombo.Items.Add(CurMode.Identifier); - if CurMode = Project1.ActiveBuildMode then - ActiveIndex := i+1; // Will be set as ItemIndex in Combo. + sl:=TStringList.Create; + try + sl.Add(lisAllBuildModes); + for i := 0 to Project1.BuildModes.Count-1 do + begin + CurMode := Project1.BuildModes[i]; + sl.Add(CurMode.Identifier); + if CurMode = Project1.ActiveBuildMode then + ActiveIndex := sl.Count-1; // Will be set as ItemIndex in Combo. + end; + aCombo.Items.Assign(sl); + aCombo.ItemIndex := ActiveIndex; + finally + sl.Free; end; - Assert(ActiveIndex > 0, 'UpdateBuildModeCombo: ActiveIndex = 0'); - aCombo.ItemIndex := ActiveIndex; end; { TBuildModesForm } diff --git a/ide/ideoptionsdlg.lfm b/ide/ideoptionsdlg.lfm index 1ecde94223..c505d93be1 100644 --- a/ide/ideoptionsdlg.lfm +++ b/ide/ideoptionsdlg.lfm @@ -1,7 +1,7 @@ object IDEOptionsDialog: TIDEOptionsDialog - Left = 121 + Left = 308 Height = 404 - Top = 96 + Top = 206 Width = 689 ActiveControl = FilterEdit BorderIcons = [biSystemMenu] @@ -19,8 +19,8 @@ object IDEOptionsDialog: TIDEOptionsDialog AnchorSideRight.Side = asrBottom AnchorSideBottom.Control = Owner Left = 6 - Height = 34 - Top = 364 + Height = 36 + Top = 362 Width = 677 BorderSpacing.Left = 6 BorderSpacing.Right = 6 @@ -40,18 +40,18 @@ object IDEOptionsDialog: TIDEOptionsDialog end object CatTVSplitter: TSplitter Left = 255 - Height = 364 + Height = 362 Top = 0 Width = 4 end object CategoryPanel: TPanel Left = 0 - Height = 364 + Height = 362 Top = 0 Width = 255 Align = alLeft BevelOuter = bvNone - ClientHeight = 364 + ClientHeight = 362 ClientWidth = 255 Constraints.MinWidth = 150 TabOrder = 2 @@ -63,8 +63,8 @@ object IDEOptionsDialog: TIDEOptionsDialog AnchorSideRight.Side = asrBottom AnchorSideBottom.Control = SettingsPanel Left = 6 - Height = 308 - Top = 36 + Height = 304 + Top = 38 Width = 249 Anchors = [akTop, akLeft, akRight, akBottom] BorderSpacing.Top = 5 @@ -81,7 +81,7 @@ object IDEOptionsDialog: TIDEOptionsDialog AnchorSideLeft.Control = CategoryPanel AnchorSideRight.Side = asrBottom Left = 6 - Height = 23 + Height = 25 Top = 8 Width = 200 OnFilterItem = FilterEditFilterItem @@ -90,6 +90,7 @@ object IDEOptionsDialog: TIDEOptionsDialog NumGlyphs = 1 Anchors = [akTop, akLeft, akRight] BorderSpacing.Left = 6 + Font.Color = clBtnShadow MaxLength = 0 ParentFont = False TabOrder = 1 @@ -98,7 +99,7 @@ object IDEOptionsDialog: TIDEOptionsDialog object SettingsPanel: TPanel Left = 0 Height = 20 - Top = 344 + Top = 342 Width = 255 Align = alBottom AutoSize = True @@ -123,7 +124,7 @@ object IDEOptionsDialog: TIDEOptionsDialog Left = 12 Height = 15 Top = 10 - Width = 68 + Width = 62 Caption = 'Build Mode' ParentColor = False end @@ -132,9 +133,9 @@ object IDEOptionsDialog: TIDEOptionsDialog AnchorSideLeft.Side = asrBottom AnchorSideTop.Control = BuildModeLabel AnchorSideTop.Side = asrCenter - Left = 87 - Height = 24 - Top = 5 + Left = 81 + Height = 29 + Top = 3 Width = 154 BorderSpacing.Left = 7 ItemHeight = 0 @@ -148,7 +149,7 @@ object IDEOptionsDialog: TIDEOptionsDialog AnchorSideLeft.Side = asrBottom AnchorSideTop.Control = BuildModeComboBox AnchorSideTop.Side = asrCenter - Left = 248 + Left = 242 Height = 25 Top = 5 Width = 27 @@ -157,6 +158,22 @@ object IDEOptionsDialog: TIDEOptionsDialog OnClick = BuildModeManageButtonClick TabOrder = 1 end + object BuildModeInSessionCheckBox: TCheckBox + AnchorSideLeft.Control = BuildModeManageButton + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = BuildModeComboBox + AnchorSideTop.Side = asrCenter + Left = 275 + Height = 24 + Top = 5 + Width = 78 + BorderSpacing.Left = 6 + Caption = 'In session' + OnChange = BuildModeInSessionCheckBoxChange + ParentShowHint = False + ShowHint = True + TabOrder = 2 + end end object EditorsPanel: TScrollBox AnchorSideLeft.Control = CatTVSplitter @@ -165,12 +182,12 @@ object IDEOptionsDialog: TIDEOptionsDialog AnchorSideTop.Side = asrBottom AnchorSideBottom.Control = ButtonPanel Left = 259 - Height = 324 + Height = 322 Top = 40 Width = 427 - HorzScrollBar.Page = 421 + HorzScrollBar.Page = 425 HorzScrollBar.Tracking = True - VertScrollBar.Page = 318 + VertScrollBar.Page = 320 VertScrollBar.Tracking = True Anchors = [akTop, akLeft, akRight, akBottom] TabOrder = 4 diff --git a/ide/ideoptionsdlg.pas b/ide/ideoptionsdlg.pas index 88ce1f1f70..c1c2f4518d 100644 --- a/ide/ideoptionsdlg.pas +++ b/ide/ideoptionsdlg.pas @@ -49,18 +49,20 @@ type TIDEOptionsDialog = class(TAbstractOptionsEditorDialog) BuildModeComboBox: TComboBox; - BuildModeManageButton: TButton; + BuildModeInSessionCheckBox: TCheckBox; BuildModeLabel: TLabel; + BuildModeManageButton: TButton; + BuildModeSelectPanel: TPanel; ButtonPanel: TButtonPanel; + CategoryPanel: TPanel; CategoryTree: TTreeView; CatTVSplitter: TSplitter; - CategoryPanel: TPanel; EditorsPanel: TScrollBox; FilterEdit: TTreeFilterEdit; - BuildModeSelectPanel: TPanel; SettingsPanel: TPanel; procedure BuildModeComboBoxClick(Sender: TObject); procedure BuildModeComboBoxSelect(Sender: TObject); + procedure BuildModeInSessionCheckBoxChange(Sender: TObject); procedure BuildModeManageButtonClick(Sender: TObject); procedure CategoryTreeChange(Sender: TObject; Node: TTreeNode); procedure CategoryTreeCollapsed(Sender: TObject; Node: TTreeNode); @@ -73,17 +75,16 @@ type procedure OkButtonClick(Sender: TObject); procedure CancelButtonClick(Sender: TObject); private + FEditorsCreated: Boolean; + FEditorToOpen: TAbstractIDEOptionsEditorClass; + FNewLastSelected: PIDEOptionsEditorRec; FOnLoadOptionsHook: TOnLoadIDEOptions; FOnSaveOptionsHook: TOnSaveIDEOptions; FOptionsFilter: TIDEOptionsEditorFilter; - FEditorToOpen: TAbstractIDEOptionsEditorClass; + FPrevComboIndex: integer; + FPrevEditor: TAbstractIDEOptionsEditor; + FSelectNode: TTreeNode; FSettings: TIDEOptionsEditorSettings; - PrevEditor: TAbstractIDEOptionsEditor; - FEditorsCreated: Boolean; - SelectNode: TTreeNode; - NewLastSelected: PIDEOptionsEditorRec; - PrevComboIndex: integer; - function FindGroupClass(Node: TTreeNode): TAbstractIDEOptionsClass; procedure TraverseSettings(AOptions: TAbstractIDEOptions; anAction: TIDEOptsDlgAction); function CheckValues: boolean; @@ -94,6 +95,8 @@ type function SearchEditorNode(AEditor: TAbstractIDEOptionsEditorClass): TTreeNode; function PassesFilter(ARec: PIDEOptionsGroupRec): Boolean; procedure SetSettings(const AValue: TIDEOptionsEditorSettings); + function AllBuildModes: boolean; + procedure UpdateBuildModeButtons; public constructor Create(AOwner: TComponent); override; function ShowModal: Integer; override; @@ -125,11 +128,14 @@ uses constructor TIDEOptionsDialog.Create(AOwner: TComponent); begin inherited Create(AOwner); - PrevEditor := nil; + FPrevEditor := nil; FEditorsCreated := False; FEditorToOpen := nil; SettingsPanel.Constraints.MinHeight:=0; BuildModeSelectPanel.Height:=0; + BuildModeInSessionCheckBox.Caption:=lisInSession; + BuildModeInSessionCheckBox.Hint:= + lisEnableThisToStoreTheBuildModeInYourSessionLpsInste; IDEDialogLayoutList.ApplyLayout(Self, Width, Height); Caption := dlgIDEOptions; @@ -152,12 +158,13 @@ begin BuildModesManager.OnLoadIDEOptionsHook := @LoadIDEOptions; BuildModesManager.OnSaveIDEOptionsHook := @SaveIDEOptions; UpdateBuildModeCombo(BuildModeComboBox); + UpdateBuildModeButtons; end; procedure TIDEOptionsDialog.HelpButtonClick(Sender: TObject); begin - if PrevEditor<>nil then - LazarusHelp.ShowHelpForIDEControl(PrevEditor) + if FPrevEditor<>nil then + LazarusHelp.ShowHelpForIDEControl(FPrevEditor) else LazarusHelp.ShowHelpForIDEControl(Self); end; @@ -197,45 +204,54 @@ begin BuildModeSelectPanel.Height:=0; // Hide the old and show the new editor frame if Assigned(AEditor) then - NewLastSelected := AEditor.Rec; - if (AEditor <> PrevEditor) then begin - if Assigned(PrevEditor) then - PrevEditor.Visible := False; + FNewLastSelected := AEditor.Rec; + if (AEditor <> FPrevEditor) then begin + if Assigned(FPrevEditor) then + FPrevEditor.Visible := False; if Assigned(AEditor) then begin AEditor.Align := alClient; AEditor.BorderSpacing.Around := 6; AEditor.Visible := True; end; - PrevEditor := AEditor; + FPrevEditor := AEditor; end; end; procedure TIDEOptionsDialog.BuildModeComboBoxClick(Sender: TObject); begin - PrevComboIndex := BuildModeComboBox.ItemIndex; + FPrevComboIndex := BuildModeComboBox.ItemIndex; end; procedure TIDEOptionsDialog.BuildModeComboBoxSelect(Sender: TObject); begin - if BuildModeComboBox.Text = lisAllBuildModes then begin + if AllBuildModes then begin ShowMessage('This will allow changing all build modes at once. Not implemented yet.'); - BuildModeComboBox.ItemIndex := PrevComboIndex; + BuildModeComboBox.ItemIndex := FPrevComboIndex; + BuildModeInSessionCheckBox.Enabled:=false; end - else + else begin SwitchBuildMode(BuildModeComboBox.Text); + end; +end; + +procedure TIDEOptionsDialog.BuildModeInSessionCheckBoxChange(Sender: TObject); +var + NewInSession: Boolean; +begin + NewInSession:=BuildModeInSessionCheckBox.Checked; + if NewInSession and (Project1.ActiveBuildMode=Project1.BuildModes[0]) then + begin + MessageDlg(lisCCOErrorCaption, + lisTheFirstBuildModeIsTheDefaultModeAndMustBeStoredIn, + mtError,[mbCancel],0); + BuildModeInSessionCheckBox.Checked:=false; + end else + Project1.ActiveBuildMode.InSession:=BuildModeInSessionCheckBox.Checked; end; procedure TIDEOptionsDialog.BuildModeManageButtonClick(Sender: TObject); -var - ProjectSaveOptions: TProjectSaveOptionsFrame; - ShowSes: Boolean; begin - ProjectSaveOptions:=TProjectSaveOptionsFrame(FindEditor(TProjectSaveOptionsFrame)); - if Assigned(ProjectSaveOptions) then - ShowSes:=ProjectSaveOptions.GetSessionLocation in [pssInIDEConfig,pssInProjectDir] - else - ShowSes:=Project1.SessionStorage in [pssInProjectDir,pssInIDEConfig]; - if ShowBuildModesDlg(ShowSes) = mrOK then + if ShowBuildModesDlg(Project1.SessionStorage in pssHasSeparateSession) = mrOK then UpdateBuildModeCombo(BuildModeComboBox); end; @@ -265,9 +281,9 @@ var Command: Word; begin Command := EditorOpts.KeyMap.TranslateKey(Key,Shift,nil); - if (Command=ecContextHelp) and (PrevEditor <> nil) then begin + if (Command=ecContextHelp) and (FPrevEditor <> nil) then begin Key:=VK_UNKNOWN; - LazarusHelp.ShowHelpForIDEControl(PrevEditor); + LazarusHelp.ShowHelpForIDEControl(FPrevEditor); end; end; @@ -285,7 +301,7 @@ end; procedure TIDEOptionsDialog.OkButtonClick(Sender: TObject); begin - IDEEditorGroups.LastSelected := NewLastSelected; + IDEEditorGroups.LastSelected := FNewLastSelected; if not CheckValues then Exit; IDEDialogLayoutList.SaveLayout(Self); @@ -459,6 +475,8 @@ begin if Assigned(OnLoadIDEOptionsHook) then OnLoadIDEOptionsHook(Self, AOptions); TraverseSettings(AOptions,iodaRead); + if AOptions is TProjectCompilerOptions then + UpdateBuildModeButtons; end; procedure TIDEOptionsDialog.SaveIDEOptions(Sender: TObject; AOptions: TAbstractIDEOptions); @@ -496,7 +514,7 @@ begin Exit; FEditorsCreated := True; IDEEditorGroups.Resort; - SelectNode := nil; + FSelectNode := nil; for i := 0 to IDEEditorGroups.Count - 1 do begin @@ -535,15 +553,15 @@ begin ItemParent.Expanded := not Instance.Rec^.Collapsed; end; if IDEEditorGroups.LastSelected = Rec^.Items[j] then - SelectNode := ItemNode; + FSelectNode := ItemNode; end; if (GroupNode.GetFirstChild <> nil) and (GroupNode.GetFirstChild.Data <> nil) then TAbstractIDEOptionsEditor(GroupNode.GetFirstChild.Data).GroupRec := Rec; GroupNode.Expanded := not Rec^.Collapsed; end; end; - if SelectNode <> nil then - SelectNode.Selected := True; + if FSelectNode <> nil then + FSelectNode.Selected := True; end; function TIDEOptionsDialog.SearchEditorNode(AEditor: TAbstractIDEOptionsEditorClass): TTreeNode; @@ -592,14 +610,26 @@ begin end; end; +function TIDEOptionsDialog.AllBuildModes: boolean; +begin + Result:=BuildModeComboBox.Text = lisAllBuildModes; +end; + +procedure TIDEOptionsDialog.UpdateBuildModeButtons; +begin + BuildModeInSessionCheckBox.Visible:=Project1.SessionStorage in pssHasSeparateSession; + BuildModeInSessionCheckBox.Enabled:=not AllBuildModes; + BuildModeInSessionCheckBox.Checked:=Project1.ActiveBuildMode.InSession; +end; + procedure TIDEOptionsDialog.DoOpenEditor(EditorToOpen: TAbstractIDEOptionsEditorClass); var Node: TTreeNode; begin if EditorToOpen = nil then begin - if SelectNode <> nil then - Node := SelectNode + if FSelectNode <> nil then + Node := FSelectNode else Node := CategoryTree.Items.GetFirstNode end @@ -607,7 +637,7 @@ begin Node := SearchEditorNode(EditorToOpen); if Node <> nil then CategoryTree.Selected := Node; - SelectNode := nil; + FSelectNode := nil; end; function TIDEOptionsDialog.ShowModal: Integer; diff --git a/ide/lazarusidestrconsts.pas b/ide/lazarusidestrconsts.pas index c858020b82..0af94cdc09 100644 --- a/ide/lazarusidestrconsts.pas +++ b/ide/lazarusidestrconsts.pas @@ -5360,6 +5360,8 @@ resourcestring dlgIdeMacroValues = 'IDE Macro Values'; lisBuildModes = 'Build modes'; lisInSession = 'In session'; + lisEnableThisToStoreTheBuildModeInYourSessionLpsInste = 'Enable this to ' + +'store the build mode in your session (.lps) instead of the lpi'; lisThereMustBeAtLeastOneBuildMode = 'There must be at least one build mode.'; lisTheFirstBuildModeIsTheDefaultModeAndMustBeStoredIn = 'The first build ' +'mode is the default mode and must be stored in the project, not in the session.'; diff --git a/ide/project.pp b/ide/project.pp index fadca00719..eb8dc2339f 100644 --- a/ide/project.pp +++ b/ide/project.pp @@ -2916,7 +2916,7 @@ begin CurSessionFilename := ''; if (not (pwfSkipSeparateSessionInfo in ProjectWriteFlags)) - and (SessionStorage in [pssInProjectDir,pssInIDEConfig]) then begin + and (SessionStorage in pssHasSeparateSession) then begin // save session in separate file .lps if OverrideProjectInfoFile<>'' then @@ -3809,7 +3809,7 @@ begin // load session file (if available) if (not LoadParts) - and (SessionStorage in [pssInProjectDir,pssInIDEConfig]) + and (SessionStorage in pssHasSeparateSession) and (CompareFilenames(ProjectInfoFile,ProjectSessionFile)<>0) then begin if FileExistsUTF8(ProjectSessionFile) then begin //DebugLn('TProject.ReadProject loading Session ProjectSessionFile=',ProjectSessionFile); @@ -7192,6 +7192,7 @@ procedure TProjectBuildMode.SetInSession(const AValue: boolean); begin if FInSession=AValue then exit; FInSession:=AValue; + IncreaseChangeStamp; end; procedure TProjectBuildMode.OnItemChanged(Sender: TObject); @@ -7202,7 +7203,7 @@ end; procedure TProjectBuildMode.SetModified(const AValue: boolean); begin if AValue then - fSavedChangeStamp:=CTInvalidChangeStamp64 + IncreaseChangeStamp else fSavedChangeStamp:=FChangeStamp; end;