From 8a1e70fd574a6eaec6980c97012804f1ade39a22 Mon Sep 17 00:00:00 2001 From: mattias Date: Tue, 22 Dec 2015 22:39:01 +0000 Subject: [PATCH] IDE: use unit dialog: save choice of uses section git-svn-id: trunk@50998 - --- components/codetools/sourcechanger.pas | 1 + ide/codetoolsoptions.pas | 11 +++++++++++ ide/useunitdlg.lfm | 21 ++++++++++++--------- ide/useunitdlg.pas | 17 ++++++++++++++--- 4 files changed, 38 insertions(+), 12 deletions(-) diff --git a/components/codetools/sourcechanger.pas b/components/codetools/sourcechanger.pas index 27f12a76ae..cfbc960f35 100644 --- a/components/codetools/sourcechanger.pas +++ b/components/codetools/sourcechanger.pas @@ -189,6 +189,7 @@ type UpdateAllMethodSignatures: boolean; // uses section UsesInsertPolicy: TUsesInsertPolicy; + UsesSectionPreferInterface: boolean; CurFlags: TBeautifyCodeFlags; diff --git a/ide/codetoolsoptions.pas b/ide/codetoolsoptions.pas index ad52ea6cf5..4df67b7bb3 100644 --- a/ide/codetoolsoptions.pas +++ b/ide/codetoolsoptions.pas @@ -102,6 +102,7 @@ type FSetPropertyVariableIsPrefix: Boolean; FSetPropertyVariableUseConst: Boolean; FUsesInsertPolicy: TUsesInsertPolicy; + FUsesSectionPreferInterface: boolean; // identifier completion FIdentComplAddSemicolon: Boolean; @@ -221,6 +222,8 @@ type read FSetPropertyVariableUseConst write SetSetPropertyVariableUseConst; property UsesInsertPolicy: TUsesInsertPolicy read FUsesInsertPolicy write FUsesInsertPolicy; + property UsesSectionPreferInterface: boolean read FUsesSectionPreferInterface + write FUsesSectionPreferInterface; // identifier completion property IdentComplAddSemicolon: Boolean read FIdentComplAddSemicolon @@ -501,6 +504,8 @@ begin FUsesInsertPolicy:=UsesInsertPolicyNameToPolicy(XMLConfig.GetValue( 'CodeToolsOptions/UsesInsertPolicy/Value', UsesInsertPolicyNames[DefaultUsesInsertPolicy])); + FUsesSectionPreferInterface:=XMLConfig.GetValue( + 'CodeToolsOptions/UsesSectionPreferInterface/Value',true); // identifier completion FIdentComplAddSemicolon:=XMLConfig.GetValue( @@ -661,6 +666,8 @@ begin XMLConfig.SetDeleteValue('CodeToolsOptions/UsesInsertPolicy/Value', UsesInsertPolicyNames[FUsesInsertPolicy], UsesInsertPolicyNames[DefaultUsesInsertPolicy]); + XMLConfig.SetDeleteValue('CodeToolsOptions/UsesSectionPreferInterface/Value', + FUsesSectionPreferInterface,true); // identifier completion XMLConfig.SetDeleteValue('CodeToolsOptions/IdentifierCompletion/AddSemicolon', @@ -810,6 +817,7 @@ begin FSetPropertyVariableIsPrefix:=CodeToolsOpts.FSetPropertyVariableIsPrefix; FSetPropertyVariableUseConst:=CodeToolsOpts.FSetPropertyVariableUseConst; FUsesInsertPolicy:=CodeToolsOpts.FUsesInsertPolicy; + FUsesSectionPreferInterface:=CodeToolsOpts.FUsesSectionPreferInterface; // identifier completion FIdentComplAddSemicolon:=CodeToolsOpts.FIdentComplAddSemicolon; @@ -872,6 +880,7 @@ begin FSetPropertyVariableIsPrefix:=false; FSetPropertyVariableUseConst:=false; FUsesInsertPolicy:=DefaultUsesInsertPolicy; + FUsesSectionPreferInterface:=true; // identifier completion FIdentComplAddSemicolon:=true; @@ -952,6 +961,7 @@ begin and (FSetPropertyVariableIsPrefix=CodeToolsOpts.FSetPropertyVariableIsPrefix) and (FSetPropertyVariableUseConst=CodeToolsOpts.FSetPropertyVariableUseConst) and (FUsesInsertPolicy=CodeToolsOpts.FUsesInsertPolicy) + and (FUsesSectionPreferInterface=CodeToolsOpts.FUsesSectionPreferInterface) // identifier completion and (FIdentComplAddSemicolon=CodeToolsOpts.FIdentComplAddSemicolon) @@ -1072,6 +1082,7 @@ begin Beauty.PropertyStoredIdentPostfix:=PropertyStoredIdentPostfix; Beauty.PrivateVariablePrefix:=PrivateVariablePrefix; Beauty.UsesInsertPolicy:=UsesInsertPolicy; + Beauty.UsesSectionPreferInterface:=UsesSectionPreferInterface; end else inherited AssignTo(Dest); diff --git a/ide/useunitdlg.lfm b/ide/useunitdlg.lfm index d547818394..4485a21a2c 100644 --- a/ide/useunitdlg.lfm +++ b/ide/useunitdlg.lfm @@ -9,14 +9,15 @@ object UseUnitDialog: TUseUnitDialog ClientWidth = 363 Constraints.MinHeight = 150 Constraints.MinWidth = 200 + OnClose = FormClose OnCreate = FormCreate OnDestroy = FormDestroy Position = poScreenCenter - LCLVersion = '1.3' + LCLVersion = '1.7' object ButtonPanel1: TButtonPanel Left = 6 - Height = 30 - Top = 386 + Height = 28 + Top = 388 Width = 351 OKButton.Name = 'OKButton' OKButton.DefaultCaption = True @@ -41,7 +42,7 @@ object UseUnitDialog: TUseUnitDialog AnchorSideBottom.Control = ButtonPanel1 Left = 6 Height = 49 - Top = 331 + Top = 333 Width = 351 Anchors = [akLeft, akRight, akBottom] AutoFill = True @@ -56,7 +57,7 @@ object UseUnitDialog: TUseUnitDialog ChildSizing.ShrinkVertical = crsScaleChilds ChildSizing.Layout = cclLeftToRightThenTopToBottom ChildSizing.ControlsPerLine = 2 - ClientHeight = 24 + ClientHeight = 32 ClientWidth = 347 Columns = 2 ItemIndex = 0 @@ -74,7 +75,7 @@ object UseUnitDialog: TUseUnitDialog AnchorSideRight.Side = asrBottom AnchorSideBottom.Control = AllUnitsCheckBox Left = 6 - Height = 263 + Height = 265 Top = 32 Width = 351 Anchors = [akTop, akLeft, akRight, akBottom] @@ -83,16 +84,18 @@ object UseUnitDialog: TUseUnitDialog OnDblClick = UnitsListBoxDblClick OnDrawItem = UnitsListBoxDrawItem OnKeyDown = UnitsListBoxKeyDown + ScrollWidth = 349 Style = lbOwnerDrawFixed TabOrder = 1 + TopIndex = -1 end object AllUnitsCheckBox: TCheckBox AnchorSideLeft.Control = Owner AnchorSideBottom.Control = SectionRadioGroup Left = 12 Height = 24 - Top = 301 - Width = 115 + Top = 303 + Width = 100 Anchors = [akLeft, akBottom] BorderSpacing.Left = 6 BorderSpacing.Around = 6 @@ -104,7 +107,7 @@ object UseUnitDialog: TUseUnitDialog AnchorSideLeft.Control = Owner AnchorSideTop.Control = Owner Left = 6 - Height = 28 + Height = 25 Top = 6 Width = 351 ButtonWidth = 23 diff --git a/ide/useunitdlg.pas b/ide/useunitdlg.pas index a1d16a4ef9..451a202a78 100644 --- a/ide/useunitdlg.pas +++ b/ide/useunitdlg.pas @@ -34,7 +34,7 @@ uses Dialogs, LCLProc, FileProcs, Graphics, LCLType, SourceEditor, LazIDEIntf, IDEImagesIntf, LazarusIDEStrConsts, ProjectIntf, IDEWindowIntf, Project, CodeCache, CodeToolManager, IdentCompletionTool, CodeTree, ListFilterEdit, - LinkScanner; + LinkScanner, CodeToolsOptions; type @@ -47,6 +47,7 @@ type UnitsListBox: TListBox; SectionRadioGroup: TRadioGroup; procedure AllUnitsCheckBoxChange(Sender: TObject); + procedure FormClose(Sender: TObject; var {%H-}CloseAction: TCloseAction); procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); procedure SectionRadioGroupClick(Sender: TObject); @@ -153,7 +154,10 @@ begin SectionRadioGroup.Items.Clear; SectionRadioGroup.Items.Add(dlgInsertInterface); SectionRadioGroup.Items.Add(dlgInsertImplementation); - SectionRadioGroup.ItemIndex:=0; + if CodeToolsOpts.UsesSectionPreferInterface then + SectionRadioGroup.ItemIndex:=0 + else + SectionRadioGroup.ItemIndex:=1; ButtonPanel1.OKButton.Caption:=lisMenuOk; ButtonPanel1.CancelButton.Caption:=lisCancel; UnitImgInd := IDEImages.LoadImage(16, 'item_unit'); @@ -162,7 +166,6 @@ end; procedure TUseUnitDialog.FormDestroy(Sender: TObject); begin - IDEDialogLayoutList.SaveLayout(Self); FOtherUnits.Free; FProjUnits.Free; FImplUsedUnits.Free; @@ -204,6 +207,14 @@ begin FilterEdit.InvalidateFilter; end; +procedure TUseUnitDialog.FormClose(Sender: TObject; + var CloseAction: TCloseAction); +begin + CodeToolsOpts.UsesSectionPreferInterface:=SectionRadioGroup.ItemIndex=0; + IDEDialogLayoutList.SaveLayout(Self); + CodeToolsOpts.Save; +end; + procedure TUseUnitDialog.UnitsListBoxDblClick(Sender: TObject); begin if UnitsListBox.ItemIndex >= 0 then