mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-22 07:19:31 +02:00
ide: use unit dialog: save recent settings in environmentopt/recent and not in codetools options, save also AllUnits check state, select first entry on filter
git-svn-id: trunk@51908 -
This commit is contained in:
parent
9309190166
commit
006715e6f9
@ -173,7 +173,6 @@ type
|
||||
UpdateAllMethodSignatures: boolean;
|
||||
// uses section
|
||||
UsesInsertPolicy: TUsesInsertPolicy;
|
||||
UsesSectionPreferInterface: boolean;
|
||||
|
||||
CurFlags: TBeautifyCodeFlags;
|
||||
|
||||
|
@ -102,7 +102,6 @@ type
|
||||
FSetPropertyVariableIsPrefix: Boolean;
|
||||
FSetPropertyVariableUseConst: Boolean;
|
||||
FUsesInsertPolicy: TUsesInsertPolicy;
|
||||
FUsesSectionPreferInterface: boolean;
|
||||
|
||||
// identifier completion
|
||||
FIdentComplAddSemicolon: Boolean;
|
||||
@ -220,9 +219,7 @@ 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
|
||||
write FIdentComplAddSemicolon;
|
||||
@ -501,8 +498,6 @@ begin
|
||||
FUsesInsertPolicy:=UsesInsertPolicyNameToPolicy(XMLConfig.GetValue(
|
||||
'CodeToolsOptions/UsesInsertPolicy/Value',
|
||||
UsesInsertPolicyNames[DefaultUsesInsertPolicy]));
|
||||
FUsesSectionPreferInterface:=XMLConfig.GetValue(
|
||||
'CodeToolsOptions/UsesSectionPreferInterface/Value',true);
|
||||
|
||||
// identifier completion
|
||||
FIdentComplAddSemicolon:=XMLConfig.GetValue(
|
||||
@ -661,8 +656,6 @@ begin
|
||||
XMLConfig.SetDeleteValue('CodeToolsOptions/UsesInsertPolicy/Value',
|
||||
UsesInsertPolicyNames[FUsesInsertPolicy],
|
||||
UsesInsertPolicyNames[DefaultUsesInsertPolicy]);
|
||||
XMLConfig.SetDeleteValue('CodeToolsOptions/UsesSectionPreferInterface/Value',
|
||||
FUsesSectionPreferInterface,true);
|
||||
|
||||
// identifier completion
|
||||
XMLConfig.SetDeleteValue('CodeToolsOptions/IdentifierCompletion/AddSemicolon',
|
||||
@ -812,8 +805,7 @@ begin
|
||||
FSetPropertyVariableIsPrefix:=CodeToolsOpts.FSetPropertyVariableIsPrefix;
|
||||
FSetPropertyVariableUseConst:=CodeToolsOpts.FSetPropertyVariableUseConst;
|
||||
FUsesInsertPolicy:=CodeToolsOpts.FUsesInsertPolicy;
|
||||
FUsesSectionPreferInterface:=CodeToolsOpts.FUsesSectionPreferInterface;
|
||||
|
||||
|
||||
// identifier completion
|
||||
FIdentComplAddSemicolon:=CodeToolsOpts.FIdentComplAddSemicolon;
|
||||
FIdentComplAddAssignOperator:=CodeToolsOpts.FIdentComplAddAssignOperator;
|
||||
@ -874,8 +866,7 @@ begin
|
||||
FSetPropertyVariableIsPrefix:=false;
|
||||
FSetPropertyVariableUseConst:=false;
|
||||
FUsesInsertPolicy:=DefaultUsesInsertPolicy;
|
||||
FUsesSectionPreferInterface:=true;
|
||||
|
||||
|
||||
// identifier completion
|
||||
FIdentComplAddSemicolon:=true;
|
||||
FIdentComplAddAssignOperator:=true;
|
||||
@ -955,7 +946,6 @@ begin
|
||||
and (FSetPropertyVariableIsPrefix=CodeToolsOpts.FSetPropertyVariableIsPrefix)
|
||||
and (FSetPropertyVariableUseConst=CodeToolsOpts.FSetPropertyVariableUseConst)
|
||||
and (FUsesInsertPolicy=CodeToolsOpts.FUsesInsertPolicy)
|
||||
and (FUsesSectionPreferInterface=CodeToolsOpts.FUsesSectionPreferInterface)
|
||||
|
||||
// identifier completion
|
||||
and (FIdentComplAddSemicolon=CodeToolsOpts.FIdentComplAddSemicolon)
|
||||
@ -1075,7 +1065,6 @@ begin
|
||||
Beauty.PropertyStoredIdentPostfix:=PropertyStoredIdentPostfix;
|
||||
Beauty.PrivateVariablePrefix:=PrivateVariablePrefix;
|
||||
Beauty.UsesInsertPolicy:=UsesInsertPolicy;
|
||||
Beauty.UsesSectionPreferInterface:=UsesSectionPreferInterface;
|
||||
end
|
||||
else
|
||||
inherited AssignTo(Dest);
|
||||
|
@ -288,6 +288,11 @@ type
|
||||
constructor Create;
|
||||
end;
|
||||
|
||||
TUseUnitDlgOptions = record
|
||||
AllUnits: Boolean;
|
||||
AddToImplementation: Boolean;
|
||||
end;
|
||||
|
||||
{ TDesktopOpt }
|
||||
|
||||
TDesktopOpt = class
|
||||
@ -514,6 +519,7 @@ type
|
||||
//other recent settings
|
||||
FLastEventMethodCCResult: TCodeCreationDlgResult;
|
||||
FLastVariableCCResult: TCodeCreationDlgResult;
|
||||
FUseUnitDlgOptions: TUseUnitDlgOptions;
|
||||
|
||||
// backup
|
||||
FBackupInfoProjectFiles: TBackupInfo;
|
||||
@ -775,6 +781,8 @@ type
|
||||
read FLastEventMethodCCResult write FLastEventMethodCCResult;
|
||||
property LastVariableCCResult: TCodeCreationDlgResult
|
||||
read FLastVariableCCResult write FLastVariableCCResult;
|
||||
property UseUnitDlgOptions: TUseUnitDlgOptions
|
||||
read FUseUnitDlgOptions write FUseUnitDlgOptions;
|
||||
|
||||
// backup
|
||||
property BackupInfoProjectFiles: TBackupInfo read FBackupInfoProjectFiles
|
||||
@ -1810,6 +1818,9 @@ begin
|
||||
LoadCCResult(FLastEventMethodCCResult, Path+'Recent/EventMethodCCResult', icsPublic);
|
||||
LoadCCResult(FLastVariableCCResult, Path+'Recent/VariableCCResult', icsPrivate);
|
||||
|
||||
FUseUnitDlgOptions.AllUnits:=FXMLCfg.GetValue(Path+'Recent/UseUnitDlg/AllUnits',False);
|
||||
FUseUnitDlgOptions.AddToImplementation:=FXMLCfg.GetValue(Path+'Recent/UseUnitDlg/AddToImplementation',False);
|
||||
|
||||
// Add example projects to an empty project list if examples have write access
|
||||
if (FRecentProjectFiles.count=0) and (not FAlreadyPopulatedRecentFiles) then begin
|
||||
AddRecentProjectInitial('examples/jpeg/', 'jpegexample.lpi');
|
||||
@ -2144,6 +2155,9 @@ begin
|
||||
SaveCCResult(FLastEventMethodCCResult, Path+'Recent/EventMethodCCResult', icsPublic);
|
||||
SaveCCResult(FLastVariableCCResult, Path+'Recent/VariableCCResult', icsPrivate);
|
||||
|
||||
FXMLCfg.SetDeleteValue(Path+'Recent/UseUnitDlg/AllUnits',FUseUnitDlgOptions.AllUnits,False);
|
||||
FXMLCfg.SetDeleteValue(Path+'Recent/UseUnitDlg/AddToImplementation',FUseUnitDlgOptions.AddToImplementation,False);
|
||||
|
||||
// external tools
|
||||
fExternalUserTools.Save(FConfigStore,Path+'ExternalTools/');
|
||||
FXMLCfg.SetDeleteValue(Path+'ExternalTools/MaxInParallel',FMaxExtToolsInParallel,0);
|
||||
|
@ -16,8 +16,8 @@ object UseUnitDialog: TUseUnitDialog
|
||||
LCLVersion = '1.7'
|
||||
object ButtonPanel1: TButtonPanel
|
||||
Left = 6
|
||||
Height = 28
|
||||
Top = 388
|
||||
Height = 26
|
||||
Top = 390
|
||||
Width = 351
|
||||
OKButton.Name = 'OKButton'
|
||||
OKButton.DefaultCaption = True
|
||||
@ -42,7 +42,7 @@ object UseUnitDialog: TUseUnitDialog
|
||||
AnchorSideBottom.Control = ButtonPanel1
|
||||
Left = 6
|
||||
Height = 49
|
||||
Top = 333
|
||||
Top = 335
|
||||
Width = 351
|
||||
Anchors = [akLeft, akRight, akBottom]
|
||||
AutoFill = True
|
||||
@ -57,7 +57,7 @@ object UseUnitDialog: TUseUnitDialog
|
||||
ChildSizing.ShrinkVertical = crsScaleChilds
|
||||
ChildSizing.Layout = cclLeftToRightThenTopToBottom
|
||||
ChildSizing.ControlsPerLine = 2
|
||||
ClientHeight = 32
|
||||
ClientHeight = 29
|
||||
ClientWidth = 347
|
||||
Columns = 2
|
||||
ItemIndex = 0
|
||||
@ -75,7 +75,7 @@ object UseUnitDialog: TUseUnitDialog
|
||||
AnchorSideRight.Side = asrBottom
|
||||
AnchorSideBottom.Control = AllUnitsCheckBox
|
||||
Left = 6
|
||||
Height = 265
|
||||
Height = 272
|
||||
Top = 32
|
||||
Width = 351
|
||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||
@ -87,15 +87,14 @@ object UseUnitDialog: TUseUnitDialog
|
||||
ScrollWidth = 349
|
||||
Style = lbOwnerDrawFixed
|
||||
TabOrder = 1
|
||||
TopIndex = -1
|
||||
end
|
||||
object AllUnitsCheckBox: TCheckBox
|
||||
AnchorSideLeft.Control = Owner
|
||||
AnchorSideBottom.Control = SectionRadioGroup
|
||||
Left = 12
|
||||
Height = 24
|
||||
Top = 303
|
||||
Width = 100
|
||||
Height = 19
|
||||
Top = 310
|
||||
Width = 93
|
||||
Anchors = [akLeft, akBottom]
|
||||
BorderSpacing.Left = 6
|
||||
BorderSpacing.Around = 6
|
||||
@ -107,9 +106,10 @@ object UseUnitDialog: TUseUnitDialog
|
||||
AnchorSideLeft.Control = Owner
|
||||
AnchorSideTop.Control = Owner
|
||||
Left = 6
|
||||
Height = 25
|
||||
Height = 23
|
||||
Top = 6
|
||||
Width = 351
|
||||
OnAfterFilter = FilterEditAfterFilter
|
||||
ButtonWidth = 23
|
||||
NumGlyphs = 1
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
|
@ -34,7 +34,7 @@ uses
|
||||
Dialogs, LCLProc, FileProcs, Graphics, LCLType, SourceEditor, LazIDEIntf,
|
||||
IDEImagesIntf, LazarusIDEStrConsts, ProjectIntf, IDEWindowIntf, Project,
|
||||
CodeCache, CodeToolManager, IdentCompletionTool, CodeTree, ListFilterEdit,
|
||||
LinkScanner, CodeToolsOptions;
|
||||
LinkScanner, EnvironmentOpts;
|
||||
|
||||
type
|
||||
|
||||
@ -47,6 +47,7 @@ type
|
||||
UnitsListBox: TListBox;
|
||||
SectionRadioGroup: TRadioGroup;
|
||||
procedure AllUnitsCheckBoxChange(Sender: TObject);
|
||||
procedure FilterEditAfterFilter(Sender: TObject);
|
||||
procedure FormClose(Sender: TObject; var {%H-}CloseAction: TCloseAction);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure FormDestroy(Sender: TObject);
|
||||
@ -84,6 +85,7 @@ var
|
||||
SrcEdit: TSourceEditor;
|
||||
s: String;
|
||||
CTRes: Boolean;
|
||||
EnvOptions: TUseUnitDlgOptions;
|
||||
begin
|
||||
Result:=mrOk;
|
||||
if not LazarusIDE.BeginCodeTools then begin
|
||||
@ -111,11 +113,13 @@ begin
|
||||
// automatic choice of dest uses-section by cursor position
|
||||
UseUnitDlg.DetermineUsesSection(SrcEdit.CodeBuffer);
|
||||
|
||||
if UseUnitDlg.FilterEdit.Items.Count = 0 then
|
||||
// no available units from current project => turn on "all units"
|
||||
UseUnitDlg.AllUnitsCheckBox.Checked := True;
|
||||
// Read recent properties
|
||||
EnvOptions := EnvironmentOptions.UseUnitDlgOptions;
|
||||
UseUnitDlg.AllUnitsCheckBox.Checked := EnvOptions.AllUnits;
|
||||
UseUnitDlg.SectionRadioGroup.ItemIndex:=Ord(EnvOptions.AddToImplementation);
|
||||
|
||||
if UseUnitDlg.FilterEdit.Items.Count = 0 then begin
|
||||
if (UseUnitDlg.FilterEdit.Items.Count = 0)
|
||||
and UseUnitDlg.AllUnitsCheckBox.Checked then begin
|
||||
// No available units. This may not be a pascal source file.
|
||||
ShowMessage(dlgNoAvailableUnits);
|
||||
Exit(mrCancel);
|
||||
@ -123,6 +127,12 @@ begin
|
||||
|
||||
// Show the dialog.
|
||||
if UseUnitDlg.ShowModal=mrOk then begin
|
||||
|
||||
// Write recent properties
|
||||
EnvOptions.AllUnits := UseUnitDlg.AllUnitsCheckBox.Checked;
|
||||
EnvOptions.AddToImplementation := Boolean(UseUnitDlg.SectionRadioGroup.ItemIndex);
|
||||
EnvironmentOptions.UseUnitDlgOptions := EnvOptions;
|
||||
|
||||
s:=UseUnitDlg.SelectedUnit;
|
||||
if s <> '' then begin
|
||||
if UseUnitDlg.InterfaceSelected then
|
||||
@ -154,10 +164,6 @@ begin
|
||||
SectionRadioGroup.Items.Clear;
|
||||
SectionRadioGroup.Items.Add(dlgInsertInterface);
|
||||
SectionRadioGroup.Items.Add(dlgInsertImplementation);
|
||||
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');
|
||||
@ -210,9 +216,7 @@ 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);
|
||||
@ -440,5 +444,11 @@ begin
|
||||
FilterEdit.InvalidateFilter;
|
||||
end;
|
||||
|
||||
procedure TUseUnitDialog.FilterEditAfterFilter(Sender: TObject);
|
||||
begin
|
||||
if (UnitsListBox.Count > 0) and (UnitsListBox.ItemIndex = -1) then
|
||||
UnitsListBox.ItemIndex := 0;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user