From 89a92b39361f574ea57bf6739de84ed64cb1736a Mon Sep 17 00:00:00 2001 From: mattias Date: Wed, 21 Apr 2010 18:18:52 +0000 Subject: [PATCH] IDE: optimized initializing IDE options git-svn-id: trunk@24797 - --- components/education/educationlaz.pas | 2 +- components/education/educomppalette.pas | 20 ++++-------- components/education/eduenvoptsframe.pas | 15 +++++---- components/education/edumenu.pas | 8 +++-- components/education/edunewprogram.pas | 20 +++++++----- components/education/eduoipages.pas | 12 ++++--- components/education/eduoptions.pas | 7 ++++ components/education/edupkgsystem.pas | 6 ++-- components/education/edupropsevents.pas | 32 +++++++++---------- components/education/eduspeedbuttons.pas | 9 ++++-- .../codetools_linesplitting_options.pas | 8 ++--- ide/frames/codetools_space_options.pas | 5 +-- ide/ideoptionsdlg.pas | 6 +++- 13 files changed, 83 insertions(+), 67 deletions(-) diff --git a/components/education/educationlaz.pas b/components/education/educationlaz.pas index 3da7c88a66..ff0bbcbbd5 100644 --- a/components/education/educationlaz.pas +++ b/components/education/educationlaz.pas @@ -7,7 +7,7 @@ unit educationlaz; interface uses - EduEnvOptsFrame, EduOptions, EduPkgSystem, EduCompPalette, EduMenu, + EduEnvOptsFrame, EduOptions, EduPkgSystem, EduCompPalette, EduMenu, EduNewProgram, EduPropsEvents, EduOIPages, EduOptionsDlg, EduSpeedButtons, LazarusPackageIntf; diff --git a/components/education/educomppalette.pas b/components/education/educomppalette.pas index dc60b95c43..41a28abdf7 100644 --- a/components/education/educomppalette.pas +++ b/components/education/educomppalette.pas @@ -329,7 +329,9 @@ end; procedure TEduCompPaletteFrame.ReadSettings(AOptions: TAbstractIDEOptions); begin - FillComponentTreeView; + if AOptions=EducationOptions then begin + FillComponentTreeView; + end; end; procedure TEduCompPaletteFrame.Setup(ADialog: TAbstractOptionsEditorDialog); @@ -348,7 +350,9 @@ end; procedure TEduCompPaletteFrame.WriteSettings(AOptions: TAbstractIDEOptions); begin - SaveFillComponentTreeView; + if AOptions=EducationOptions then begin + SaveFillComponentTreeView; + end; end; { TEduComponentPaletteOptions } @@ -427,20 +431,8 @@ begin end; procedure TEduComponentPaletteOptions.Apply(Enable: boolean); -var - i: Integer; - Page: TBaseComponentPage; - j: Integer; - Comp: TRegisteredComponent; begin inherited Apply(Enable); - for i:=0 to IDEComponentPalette.Count-1 do begin - Page:=IDEComponentPalette[i]; - for j:=0 to Page.Count-1 do begin - Comp:=Page[j]; - Comp.Visible:=(not Enable) or ComponentVisible[Comp.ComponentClass.ClassName]; - end; - end; if IDEComponentPalette<>nil then IDEComponentPalette.UpdateVisible; end; diff --git a/components/education/eduenvoptsframe.pas b/components/education/eduenvoptsframe.pas index 6cd8fb6805..038b746fac 100644 --- a/components/education/eduenvoptsframe.pas +++ b/components/education/eduenvoptsframe.pas @@ -109,17 +109,18 @@ end; procedure TEduEnvFrame.ReadSettings(AOptions: TAbstractIDEOptions); begin - EnableCheckBox.Checked:=EducationOptions.Enabled; - //OnLoadIDEOptions(Self,EducationOptions); + if AOptions=EducationOptions then begin + EnableCheckBox.Checked:=EducationOptions.Enabled; + end; end; procedure TEduEnvFrame.WriteSettings(AOptions: TAbstractIDEOptions); begin - EducationOptions.Enabled:=EnableCheckBox.Checked; - //OnSaveIDEOptions(Self,EducationOptions); - if EducationOptions.Save<>mrOk then - DebugLn(['TEduEnvFrame.WriteSettings Failed']); - EducationOptions.Apply; + if AOptions=EducationOptions then begin + EducationOptions.Enabled:=EnableCheckBox.Checked; + if EducationOptions.Save<>mrOk then + DebugLn(['TEduEnvFrame.WriteSettings Failed']); + end; end; class function TEduEnvFrame.SupportedOptionsClass: TAbstractIDEOptionsClass; diff --git a/components/education/edumenu.pas b/components/education/edumenu.pas index ff52524cb9..7a604eb387 100644 --- a/components/education/edumenu.pas +++ b/components/education/edumenu.pas @@ -298,7 +298,9 @@ end; procedure TEduMenuFrame.ReadSettings(AOptions: TAbstractIDEOptions); begin - FillMenuTree; + if AOptions=EducationOptions then begin + FillMenuTree; + end; end; procedure TEduMenuFrame.Setup(ADialog: TAbstractOptionsEditorDialog); @@ -315,7 +317,9 @@ end; procedure TEduMenuFrame.WriteSettings(AOptions: TAbstractIDEOptions); begin - SaveMenuTree; + if AOptions=EducationOptions then begin + SaveMenuTree; + end; end; { TEduMenuOptions } diff --git a/components/education/edunewprogram.pas b/components/education/edunewprogram.pas index f5ad95a351..7ce47110d0 100644 --- a/components/education/edunewprogram.pas +++ b/components/education/edunewprogram.pas @@ -283,10 +283,12 @@ end; procedure TEduNewPrgFrame.ReadSettings(AOptions: TAbstractIDEOptions); begin - AddNewPrgBtnCheckBox.Checked:=EduNewPrgOptions.AddButton; - AddNewPrgMenuItmCheckBox.Checked:=EduNewPrgOptions.AddMenuItem; - AddToNewDlgCheckBox.Checked:=EduNewPrgOptions.AddToNewDialog; - SrcSynEdit.Lines.Text:=EduNewPrgOptions.Source.Text; + if AOptions=EducationOptions then begin + AddNewPrgBtnCheckBox.Checked:=EduNewPrgOptions.AddButton; + AddNewPrgMenuItmCheckBox.Checked:=EduNewPrgOptions.AddMenuItem; + AddToNewDlgCheckBox.Checked:=EduNewPrgOptions.AddToNewDialog; + SrcSynEdit.Lines.Text:=EduNewPrgOptions.Source.Text; + end; end; procedure TEduNewPrgFrame.Setup(ADialog: TAbstractOptionsEditorDialog); @@ -323,10 +325,12 @@ end; procedure TEduNewPrgFrame.WriteSettings(AOptions: TAbstractIDEOptions); begin - EduNewPrgOptions.AddButton:=AddNewPrgBtnCheckBox.Checked; - EduNewPrgOptions.AddMenuItem:=AddNewPrgMenuItmCheckBox.Checked; - EduNewPrgOptions.AddToNewDialog:=AddToNewDlgCheckBox.Checked; - EduNewPrgOptions.Source:=SrcSynEdit.Lines; + if AOptions=EducationOptions then begin + EduNewPrgOptions.AddButton:=AddNewPrgBtnCheckBox.Checked; + EduNewPrgOptions.AddMenuItem:=AddNewPrgMenuItmCheckBox.Checked; + EduNewPrgOptions.AddToNewDialog:=AddToNewDlgCheckBox.Checked; + EduNewPrgOptions.Source:=SrcSynEdit.Lines; + end; end; { TFileDescSingleFileProgram } diff --git a/components/education/eduoipages.pas b/components/education/eduoipages.pas index ba2ff11593..0bcb2a0d54 100644 --- a/components/education/eduoipages.pas +++ b/components/education/eduoipages.pas @@ -132,8 +132,10 @@ end; procedure TEduOIPagesFrame.ReadSettings(AOptions: TAbstractIDEOptions); begin - ckBoxFavs.Checked:=EduOIPagesOptions.OIPageFavs; - ckBoxRestricted.Checked:=EduOIPagesOptions.OIPageRestricted; + if AOptions=EducationOptions then begin + ckBoxFavs.Checked:=EduOIPagesOptions.OIPageFavs; + ckBoxRestricted.Checked:=EduOIPagesOptions.OIPageRestricted; + end; end; procedure TEduOIPagesFrame.Setup(ADialog: TAbstractOptionsEditorDialog); @@ -150,8 +152,10 @@ end; procedure TEduOIPagesFrame.WriteSettings(AOptions: TAbstractIDEOptions); begin - EduOIPagesOptions.OIPageFavs:=ckBoxFavs.Checked; - EduOIPagesOptions.OIPageRestricted:=ckBoxRestricted.Checked; + if AOptions=EducationOptions then begin + EduOIPagesOptions.OIPageFavs:=ckBoxFavs.Checked; + EduOIPagesOptions.OIPageRestricted:=ckBoxRestricted.Checked; + end; end; {$R *.lfm} diff --git a/components/education/eduoptions.pas b/components/education/eduoptions.pas index 55f2df3d7b..7facb0772d 100644 --- a/components/education/eduoptions.pas +++ b/components/education/eduoptions.pas @@ -177,6 +177,7 @@ type function SaveToFile(Filename: string): TModalResult; virtual; function Load: TModalResult; virtual; function Save: TModalResult; virtual; + procedure DoAfterWrite; override; procedure Apply; virtual; function GetFullFilename: string; function OnProjectOpened(Sender: TObject; AProject: TLazProject): TModalResult; @@ -424,6 +425,12 @@ begin FLastSavedChangeStep:=TEduOptsRootNode(Root).ChangeStep; end; +procedure TEduOptions.DoAfterWrite; +begin + inherited DoAfterWrite; + Apply; +end; + procedure TEduOptions.Apply; begin Root.Apply(Enabled); diff --git a/components/education/edupkgsystem.pas b/components/education/edupkgsystem.pas index 43ee76662f..f776449f2b 100644 --- a/components/education/edupkgsystem.pas +++ b/components/education/edupkgsystem.pas @@ -93,12 +93,14 @@ end; procedure TEduPkgSystemFrame.ReadSettings(AOptions: TAbstractIDEOptions); begin - + if AOptions=EducationOptions then begin + end; end; procedure TEduPkgSystemFrame.WriteSettings(AOptions: TAbstractIDEOptions); begin - + if AOptions=EducationOptions then begin + end; end; class function TEduPkgSystemFrame.SupportedOptionsClass: TAbstractIDEOptionsClass; diff --git a/components/education/edupropsevents.pas b/components/education/edupropsevents.pas index 2739abebfc..8ad1ea9282 100644 --- a/components/education/edupropsevents.pas +++ b/components/education/edupropsevents.pas @@ -222,15 +222,15 @@ end; procedure TEduPropsEventsFrame.ReadSettings(AOptions: TAbstractIDEOptions); begin + if AOptions=EducationOptions then begin + PropsMinRadioBtn.Checked:=EduPropsEventsOptions.PropsMinimal; + PropsExtRadioBtn.Checked:=EduPropsEventsOptions.PropsExt; + PropsFullRadioBtn.Checked:=EduPropsEventsOptions.PropsFull; - PropsMinRadioBtn.Checked:=EduPropsEventsOptions.PropsMinimal; - PropsExtRadioBtn.Checked:=EduPropsEventsOptions.PropsExt; - PropsFullRadioBtn.Checked:=EduPropsEventsOptions.PropsFull; - - EventsMinRadioBtn.Checked:=EduPropsEventsOptions.EventsMinimal; - EventsExtRadioBtn.Checked:=EduPropsEventsOptions.EventsExt; - EventsFullRadioBtn.Checked:=EduPropsEventsOptions.EventsFull; - + EventsMinRadioBtn.Checked:=EduPropsEventsOptions.EventsMinimal; + EventsExtRadioBtn.Checked:=EduPropsEventsOptions.EventsExt; + EventsFullRadioBtn.Checked:=EduPropsEventsOptions.EventsFull; + end; end; procedure TEduPropsEventsFrame.Setup(ADialog: TAbstractOptionsEditorDialog); @@ -288,15 +288,15 @@ end; procedure TEduPropsEventsFrame.WriteSettings(AOptions: TAbstractIDEOptions); begin + if AOptions=EducationOptions then begin + EduPropsEventsOptions.PropsMinimal:=PropsMinRadioBtn.Checked; + EduPropsEventsOptions.PropsExt:=PropsExtRadioBtn.Checked; + EduPropsEventsOptions.PropsFull:=PropsFullRadioBtn.Checked; - EduPropsEventsOptions.PropsMinimal:=PropsMinRadioBtn.Checked; - EduPropsEventsOptions.PropsExt:=PropsExtRadioBtn.Checked; - EduPropsEventsOptions.PropsFull:=PropsFullRadioBtn.Checked; - - EduPropsEventsOptions.EventsMinimal:=EventsMinRadioBtn.Checked; - EduPropsEventsOptions.EventsExt:=EventsExtRadioBtn.Checked; - EduPropsEventsOptions.EventsFull:=EventsFullRadioBtn.Checked; - + EduPropsEventsOptions.EventsMinimal:=EventsMinRadioBtn.Checked; + EduPropsEventsOptions.EventsExt:=EventsExtRadioBtn.Checked; + EduPropsEventsOptions.EventsFull:=EventsFullRadioBtn.Checked; + end; end; {$R *.lfm} diff --git a/components/education/eduspeedbuttons.pas b/components/education/eduspeedbuttons.pas index d1bdbba8b8..e39ba6d211 100644 --- a/components/education/eduspeedbuttons.pas +++ b/components/education/eduspeedbuttons.pas @@ -444,7 +444,9 @@ end; procedure TEduSpeedButtonsFrame.ReadSettings(AOptions: TAbstractIDEOptions); begin - FillSpeedButtonsTreeView; + if AOptions=EducationOptions then begin + FillSpeedButtonsTreeView; + end; end; procedure TEduSpeedButtonsFrame.Setup(ADialog: TAbstractOptionsEditorDialog); @@ -453,7 +455,6 @@ begin HideAllButton.Caption:=ersHideAll; ShowSelectionButton.Caption:=ersShowSelection; SpeedButtonsGroupBox.Caption:=ersVisibleSpeedButtons; - end; class function TEduSpeedButtonsFrame.SupportedOptionsClass: TAbstractIDEOptionsClass; @@ -463,7 +464,9 @@ end; procedure TEduSpeedButtonsFrame.WriteSettings(AOptions: TAbstractIDEOptions); begin - SaveFillSpeedButtonsTreeView; + if AOptions=EducationOptions then begin + SaveFillSpeedButtonsTreeView; + end; end; {$R *.lfm} diff --git a/ide/frames/codetools_linesplitting_options.pas b/ide/frames/codetools_linesplitting_options.pas index 74c2369967..c7113bb697 100644 --- a/ide/frames/codetools_linesplitting_options.pas +++ b/ide/frames/codetools_linesplitting_options.pas @@ -92,8 +92,6 @@ var Options: TEditorOptions; begin Options := EditorOpts; - if Assigned(OnSaveIDEOptions) then - OnSaveIDEOptions(Self, Options); SplitPreviewSynEdit.Highlighter := GetHighlighter(Options); Options.GetSynEditPreviewSettings(SplitPreviewSynEdit); SplitPreviewSynEdit.Gutter.Visible := False; @@ -101,14 +99,14 @@ begin SplitPreviewSynEdit.ReadOnly := True; end; -procedure TCodetoolsLineSplittingOptionsFrame.WriteBeautifyCodeOptions(Options: TBeautifyCodeOptions); +procedure TCodetoolsLineSplittingOptionsFrame.WriteBeautifyCodeOptions( + Options: TBeautifyCodeOptions); var ACodeToolsOptions: TCodeToolsOptions; begin ACodeToolsOptions := TCodeToolsOptions.Create; try - if Assigned(OnSaveIDEOptions) then - OnSaveIDEOptions(Self, ACodeToolsOptions); + WriteSettings(ACodeToolsOptions); Options.Assign(ACodeToolsOptions); finally ACodeToolsOptions.Free; diff --git a/ide/frames/codetools_space_options.pas b/ide/frames/codetools_space_options.pas index f4d943cf99..eea0175f38 100644 --- a/ide/frames/codetools_space_options.pas +++ b/ide/frames/codetools_space_options.pas @@ -96,8 +96,6 @@ var Options: TEditorOptions; begin Options := EditorOpts; - if Assigned(OnSaveIDEOptions) then - OnSaveIDEOptions(Self, Options); SpacePreviewSynEdit.Highlighter := GetHighlighter(Options); Options.GetSynEditPreviewSettings(SpacePreviewSynEdit); SpacePreviewSynEdit.Gutter.Visible := False; @@ -112,8 +110,7 @@ var begin ACodeToolsOptions := TCodeToolsOptions.Create; try - if Assigned(OnSaveIDEOptions) then - OnSaveIDEOptions(Self, ACodeToolsOptions); + WriteSettings(ACodeToolsOptions); Options.Assign(ACodeToolsOptions); finally ACodeToolsOptions.Free; diff --git a/ide/ideoptionsdlg.pas b/ide/ideoptionsdlg.pas index 8d0807820c..2940be3224 100644 --- a/ide/ideoptionsdlg.pas +++ b/ide/ideoptionsdlg.pas @@ -241,7 +241,9 @@ var i: integer; Rec: PIDEOptionsGroupRec; Instance: TAbstractIDEOptions; + InstanceList: TFPList; begin + InstanceList:=TFPList.Create; for i := 0 to IDEEditorGroups.Count - 1 do begin Rec := IDEEditorGroups[i]; @@ -252,8 +254,9 @@ begin if Rec^.GroupClass <> nil then begin Instance := Rec^.GroupClass.GetInstance; - if Instance <> nil then + if (InstanceList.IndexOf(Instance)<0) and (Instance <> nil) then begin + InstanceList.Add(Instance); Instance.DoBeforeRead; ReadSettings(Instance); Instance.DoAfterRead; @@ -263,6 +266,7 @@ begin end; // load settings that does not belong to any group ReadSettings(nil); + InstanceList.Free; end; procedure TIDEOptionsDialog.WriteAll;