IDE: Desktops: save ObjectInspector grid splitter and info panel properties.

git-svn-id: trunk@56913 -
This commit is contained in:
ondrej 2018-01-02 05:36:42 +00:00
parent 56bdf66786
commit 129140c672
5 changed files with 176 additions and 44 deletions

View File

@ -1,19 +1,19 @@
object ObjectInspectorDlg: TObjectInspectorDlg object ObjectInspectorDlg: TObjectInspectorDlg
Left = 338 Left = -3
Height = 669 Height = 702
Top = 162 Top = 169
Width = 300 Width = 273
BorderStyle = bsSizeToolWin BorderStyle = bsSizeToolWin
Caption = 'ObjectInspectorDlg' Caption = 'ObjectInspectorDlg'
ClientHeight = 669 ClientHeight = 702
ClientWidth = 300 ClientWidth = 273
KeyPreview = True KeyPreview = True
LCLVersion = '1.7' LCLVersion = '1.9.0.0'
object StatusBar: TStatusBar object StatusBar: TStatusBar
Left = 0 Left = 0
Height = 19 Height = 23
Top = 650 Top = 679
Width = 300 Width = 273
Panels = < Panels = <
item item
Width = 100 Width = 100
@ -24,11 +24,11 @@ object ObjectInspectorDlg: TObjectInspectorDlg
end end
object AvailPersistentComboBox: TComboBox object AvailPersistentComboBox: TComboBox
Left = 0 Left = 0
Height = 28 Height = 23
Top = 0 Top = 0
Width = 300 Width = 273
Align = alTop Align = alTop
ItemHeight = 14 ItemHeight = 15
OnCloseUp = AvailComboBoxCloseUp OnCloseUp = AvailComboBoxCloseUp
Style = csDropDownList Style = csDropDownList
TabOrder = 0 TabOrder = 0
@ -36,22 +36,22 @@ object ObjectInspectorDlg: TObjectInspectorDlg
object ComponentPanel: TPanel object ComponentPanel: TPanel
Left = 0 Left = 0
Height = 184 Height = 184
Top = 28 Top = 23
Width = 300 Width = 273
Align = alTop Align = alTop
BevelOuter = bvNone BevelOuter = bvNone
ClientHeight = 184 ClientHeight = 184
ClientWidth = 300 ClientWidth = 273
TabOrder = 2 TabOrder = 2
object CompFilterEdit: TTreeFilterEdit object CompFilterEdit: TTreeFilterEdit
AnchorSideLeft.Control = CompFilterLabel AnchorSideLeft.Control = CompFilterLabel
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = CompFilterLabel AnchorSideTop.Control = CompFilterLabel
AnchorSideTop.Side = asrCenter AnchorSideTop.Side = asrCenter
Left = 84 Left = 77
Height = 28 Height = 23
Top = 0 Top = 3
Width = 213 Width = 193
ButtonWidth = 23 ButtonWidth = 23
NumGlyphs = 1 NumGlyphs = 1
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
@ -61,9 +61,9 @@ object ObjectInspectorDlg: TObjectInspectorDlg
end end
object CompFilterLabel: TLabel object CompFilterLabel: TLabel
Left = 3 Left = 3
Height = 14 Height = 15
Top = 7 Top = 7
Width = 76 Width = 69
Caption = 'Co&mponents' Caption = 'Co&mponents'
FocusControl = CompFilterEdit FocusControl = CompFilterEdit
ParentColor = False ParentColor = False
@ -72,7 +72,7 @@ object ObjectInspectorDlg: TObjectInspectorDlg
object MainPopupMenu: TPopupMenu object MainPopupMenu: TPopupMenu
OnPopup = MainPopupMenuPopup OnPopup = MainPopupMenuPopup
OnClose = MainPopupMenuClose OnClose = MainPopupMenuClose
left = 32 Left = 32
top = 64 Top = 64
end end
end end

View File

@ -872,11 +872,6 @@ function dbgs(States: TOIPropertyGridStates): string; overload;
function GetChangeParentCandidates(PropertyEditorHook: TPropertyEditorHook; function GetChangeParentCandidates(PropertyEditorHook: TPropertyEditorHook;
Selection: TPersistentSelectionList): TFPList; Selection: TPersistentSelectionList): TFPList;
implementation
{$R *.lfm}
{$R images\ideintf_images.res}
const const
DefaultOIPageNames: array[TObjectInspectorPage] of shortstring = ( DefaultOIPageNames: array[TObjectInspectorPage] of shortstring = (
'PropertyPage', 'PropertyPage',
@ -891,6 +886,11 @@ const
'RestrictedGrid' 'RestrictedGrid'
); );
implementation
{$R *.lfm}
{$R images\ideintf_images.res}
function SortGridRows(Item1, Item2 : pointer) : integer; function SortGridRows(Item1, Item2 : pointer) : integer;
begin begin
Result:=SysUtils.CompareText(TOIPropertyGridRow(Item1).Name, Result:=SysUtils.CompareText(TOIPropertyGridRow(Item1).Name,

View File

@ -13,7 +13,7 @@ uses
// IdeIntf // IdeIntf
IDEImagesIntf, ToolBarIntf, IDEWindowIntf, IDEImagesIntf, ToolBarIntf, IDEWindowIntf,
// IDE // IDE
LazarusIDEStrConsts, EnvironmentOpts, IDEOptionDefs, InputHistory; LazarusIDEStrConsts, EnvironmentOpts, IDEOptionDefs, InputHistory, MainIntf;
type type
@ -163,7 +163,9 @@ begin
else else
Desktops.Insert(dskIndex, dsk); Desktops.Insert(dskIndex, dsk);
debugln(['TDesktopForm.SaveBitBtnClick: Assign from active desktop to ', aDesktopName]); debugln(['TDesktopForm.SaveBitBtnClick: Assign from active desktop to ', aDesktopName]);
Desktop.ImportSettingsFromIDE; if ObjectInspector1<>nil then
EnvironmentOptions.ObjectInspectorOptions.Assign(ObjectInspector1);
Desktop.ImportSettingsFromIDE(EnvironmentOptions);
dsk.Assign(Desktop); dsk.Assign(Desktop);
ActiveDesktopName := aDesktopName; ActiveDesktopName := aDesktopName;
Result := True; Result := True;

View File

@ -52,7 +52,7 @@ uses
// IDE // IDE
IDEProcs, DialogProcs, LazarusIDEStrConsts, IDETranslations, LazConf, IDEProcs, DialogProcs, LazarusIDEStrConsts, IDETranslations, LazConf,
IDEOptionDefs, TransferMacros, ModeMatrixOpts, Debugger, IDEOptionDefs, TransferMacros, ModeMatrixOpts, Debugger,
IdeCoolbarData, EditorToolbarStatic; IdeCoolbarData, EditorToolbarStatic, math;
const const
EnvOptsVersion: integer = 110; EnvOptsVersion: integer = 110;
@ -287,6 +287,7 @@ type
TEnvOptParseTypes = set of TEnvOptParseType; TEnvOptParseTypes = set of TEnvOptParseType;
type type
TEnvironmentOptions = class;
TLastOpenPackagesList = class(TStringList) TLastOpenPackagesList = class(TStringList)
public public
@ -325,6 +326,30 @@ type
end; end;
TDesktopOptClass = class of TCustomDesktopOpt; TDesktopOptClass = class of TCustomDesktopOpt;
TDesktopOIOptions = class(TPersistent)
private
FInfoBoxHeight: integer;
FShowInfoBox: boolean;
FSplitterX: array[TObjectInspectorPage] of Integer;
function GetSplitterX(const APage: TObjectInspectorPage): Integer;
procedure SetSplitterX(const APage: TObjectInspectorPage;
const ASplitterX: Integer);
protected
procedure AssignTo(Dest: TPersistent); override;
public
constructor Create;
procedure ImportSettingsFromIDE(const AOptions: TEnvironmentOptions);
procedure ExportSettingsToIDE(const AOptions: TEnvironmentOptions);
procedure Load(XMLConfig: TXMLConfig; Path: String);
procedure Save(XMLConfig: TXMLConfig; Path: String);
property SplitterX[const APage: TObjectInspectorPage]: Integer read GetSplitterX write SetSplitterX;
property ShowInfoBox: boolean read FShowInfoBox write FShowInfoBox;
property InfoBoxHeight: integer read FInfoBoxHeight write FInfoBoxHeight;
end;
{ TDesktopOpt } { TDesktopOpt }
TDesktopOpt = class(TCustomDesktopOpt) TDesktopOpt = class(TCustomDesktopOpt)
@ -332,6 +357,7 @@ type
// window layout // window layout
FIDEWindowCreatorsLayoutList: TSimpleWindowLayoutList; FIDEWindowCreatorsLayoutList: TSimpleWindowLayoutList;
FIDEDialogLayoutList: TIDEDialogLayoutList; FIDEDialogLayoutList: TIDEDialogLayoutList;
FObjectInspectorOptions: TDesktopOIOptions;
FSingleTaskBarButton: boolean; FSingleTaskBarButton: boolean;
FHideIDEOnRun: boolean; FHideIDEOnRun: boolean;
FAutoAdjustIDEHeight: boolean; FAutoAdjustIDEHeight: boolean;
@ -366,8 +392,8 @@ type
public public
procedure Load(Path: String); override; procedure Load(Path: String); override;
procedure Save(Path: String); override; procedure Save(Path: String); override;
procedure ImportSettingsFromIDE; procedure ImportSettingsFromIDE(const AOptions: TEnvironmentOptions);
procedure ExportSettingsToIDE; procedure ExportSettingsToIDE(const AOptions: TEnvironmentOptions);
procedure RestoreDesktop; procedure RestoreDesktop;
property IDEWindowCreatorsLayoutList: TSimpleWindowLayoutList read FIDEWindowCreatorsLayoutList write FIDEWindowCreatorsLayoutList; property IDEWindowCreatorsLayoutList: TSimpleWindowLayoutList read FIDEWindowCreatorsLayoutList write FIDEWindowCreatorsLayoutList;
@ -390,6 +416,7 @@ type
property IDECoolBarOptions: TIDECoolBarOptions read FIDECoolBarOptions; property IDECoolBarOptions: TIDECoolBarOptions read FIDECoolBarOptions;
property EditorToolBarOptions: TEditorToolBarOptions read FEditorToolBarOptions; property EditorToolBarOptions: TEditorToolBarOptions read FEditorToolBarOptions;
property ComponentPaletteOptions: TCompPaletteOptions read FComponentPaletteOptions; property ComponentPaletteOptions: TCompPaletteOptions read FComponentPaletteOptions;
property ObjectInspectorOptions: TDesktopOIOptions read FObjectInspectorOptions;
end; end;
{ TUnsupportedDesktopOpt } { TUnsupportedDesktopOpt }
@ -403,8 +430,6 @@ type
procedure Save(Path: String); override; procedure Save(Path: String); override;
end; end;
TEnvironmentOptions = class;
{ TDesktopOptList } { TDesktopOptList }
TDesktopOptList = class(TObjectList) TDesktopOptList = class(TObjectList)
@ -1046,6 +1071,98 @@ begin
WriteStr(Result, u); WriteStr(Result, u);
end; end;
{ TDesktopOIOptions }
constructor TDesktopOIOptions.Create;
var
I: TObjectInspectorPage;
begin
FInfoBoxHeight := -1;
FShowInfoBox := True;
for I in TObjectInspectorPage do
SplitterX[I] := -1;
end;
procedure TDesktopOIOptions.AssignTo(Dest: TPersistent);
var
DDest: TDesktopOIOptions;
I: TObjectInspectorPage;
begin
if Dest is TDesktopOIOptions then
begin
DDest := TDesktopOIOptions(Dest);
for I in TObjectInspectorPage do
DDest.SplitterX[I] := SplitterX[I];
DDest.ShowInfoBox := ShowInfoBox;
DDest.InfoBoxHeight := InfoBoxHeight;
end else
inherited AssignTo(Dest);
end;
function TDesktopOIOptions.GetSplitterX(const APage: TObjectInspectorPage
): Integer;
begin
Result := FSplitterX[APage];
end;
procedure TDesktopOIOptions.ImportSettingsFromIDE(
const AOptions: TEnvironmentOptions);
var
I: TObjectInspectorPage;
o: TOIOptions;
begin
o := AOptions.ObjectInspectorOptions;
for I in TObjectInspectorPage do
FSplitterX[I] := o.GridSplitterX[I];
ShowInfoBox := o.ShowInfoBox;
InfoBoxHeight := o.InfoBoxHeight;
end;
procedure TDesktopOIOptions.Load(XMLConfig: TXMLConfig; Path: String);
var
I: TObjectInspectorPage;
begin
Path := Path + 'ObjectInspector';
for I in TObjectInspectorPage do
FSplitterX[I] := XMLConfig.GetValue(Path+'SplitterX/'+DefaultOIPageNames[I]+'/Value',-1);
ShowInfoBox := XMLConfig.GetValue(Path+'ShowInfoBox/Value',True);
InfoBoxHeight := XMLConfig.GetValue(Path+'InfoBoxHeight/Value',-1);
end;
procedure TDesktopOIOptions.Save(XMLConfig: TXMLConfig; Path: String);
var
I: TObjectInspectorPage;
begin
Path := Path + 'ObjectInspector';
for I in TObjectInspectorPage do
XMLConfig.SetDeleteValue(Path+'SplitterX/'+DefaultOIPageNames[I]+'/Value',FSplitterX[I],-1);
XMLConfig.SetDeleteValue(Path+'ShowInfoBox/Value',ShowInfoBox,True);
XMLConfig.SetDeleteValue(Path+'InfoBoxHeight/Value',InfoBoxHeight,-1);
end;
procedure TDesktopOIOptions.SetSplitterX(const APage: TObjectInspectorPage;
const ASplitterX: Integer);
begin
FSplitterX[APage] := ASplitterX;
end;
procedure TDesktopOIOptions.ExportSettingsToIDE(
const AOptions: TEnvironmentOptions);
var
I: TObjectInspectorPage;
o: TOIOptions;
begin
o := AOptions.ObjectInspectorOptions;
for I in TObjectInspectorPage do
if FSplitterX[I]>=0 then
o.GridSplitterX[I] := Max(10, FSplitterX[I]);
o.ShowInfoBox := ShowInfoBox;
o.InfoBoxHeight := InfoBoxHeight;
end;
{ TUnsupportedDesktopOpt } { TUnsupportedDesktopOpt }
destructor TUnsupportedDesktopOpt.Destroy; destructor TUnsupportedDesktopOpt.Destroy;
@ -1257,6 +1374,8 @@ begin
FEditorToolBarOptions:=TEditorToolBarOptions.Create; FEditorToolBarOptions:=TEditorToolBarOptions.Create;
// component palette // component palette
FComponentPaletteOptions:=TCompPaletteOptions.Create; FComponentPaletteOptions:=TCompPaletteOptions.Create;
// object inspector
FObjectInspectorOptions:=TDesktopOIOptions.Create;
// Windows layout // Windows layout
InitLayoutList; InitLayoutList;
@ -1272,6 +1391,7 @@ begin
FreeAndNil(FEditorToolBarOptions); FreeAndNil(FEditorToolBarOptions);
FreeAndNil(FIDECoolBarOptions); FreeAndNil(FIDECoolBarOptions);
FreeAndNil(FDockedOpt); FreeAndNil(FDockedOpt);
FreeAndNil(FObjectInspectorOptions);
FreeAndNil(FIDEDialogLayoutList); FreeAndNil(FIDEDialogLayoutList);
FreeAndNil(FIDEWindowCreatorsLayoutList); FreeAndNil(FIDEWindowCreatorsLayoutList);
@ -1319,6 +1439,8 @@ begin
FEditorToolBarOptions.Assign(Source.FEditorToolBarOptions); FEditorToolBarOptions.Assign(Source.FEditorToolBarOptions);
// component palette // component palette
FComponentPaletteOptions.Assign(Source.FComponentPaletteOptions); FComponentPaletteOptions.Assign(Source.FComponentPaletteOptions);
// object inspector
FObjectInspectorOptions.Assign(Source.FObjectInspectorOptions);
if IsCompatible and Assigned(FDockedOpt) then if IsCompatible and Assigned(FDockedOpt) then
FDockedOpt.Assign(Source.FDockedOpt); FDockedOpt.Assign(Source.FDockedOpt);
@ -1354,6 +1476,8 @@ begin
FEditorToolBarOptions.Load(FXMLCfg, Path); FEditorToolBarOptions.Load(FXMLCfg, Path);
// component palette // component palette
FComponentPaletteOptions.Load(FXMLCfg, Path); FComponentPaletteOptions.Load(FXMLCfg, Path);
// Object Inspector
FObjectInspectorOptions.Load(FXMLCfg, Path);
if Assigned(FDockedOpt) then if Assigned(FDockedOpt) then
FDockedOpt.Load(Path, FXMLCfg); FDockedOpt.Load(Path, FXMLCfg);
@ -1366,11 +1490,13 @@ begin
FDockedOpt.RestoreDesktop; FDockedOpt.RestoreDesktop;
end; end;
procedure TDesktopOpt.ImportSettingsFromIDE; procedure TDesktopOpt.ImportSettingsFromIDE(const AOptions: TEnvironmentOptions
);
begin begin
IDEWindowIntf.IDEWindowCreators.SimpleLayoutStorage.StoreWindowPositions; IDEWindowIntf.IDEWindowCreators.SimpleLayoutStorage.StoreWindowPositions;
FIDEDialogLayoutList.Assign(IDEWindowIntf.IDEDialogLayoutList); FIDEDialogLayoutList.Assign(IDEWindowIntf.IDEDialogLayoutList);
FIDEWindowCreatorsLayoutList.CopyItemsFrom(IDEWindowIntf.IDEWindowCreators.SimpleLayoutStorage); FIDEWindowCreatorsLayoutList.CopyItemsFrom(IDEWindowIntf.IDEWindowCreators.SimpleLayoutStorage);
FObjectInspectorOptions.ImportSettingsFromIDE(AOptions);
if Assigned(FDockedOpt) then if Assigned(FDockedOpt) then
FDockedOpt.ImportSettingsFromIDE; FDockedOpt.ImportSettingsFromIDE;
@ -1409,18 +1535,21 @@ begin
FEditorToolBarOptions.Save(FXMLCfg, Path); FEditorToolBarOptions.Save(FXMLCfg, Path);
// component palette // component palette
FComponentPaletteOptions.Save(FXMLCfg, Path); FComponentPaletteOptions.Save(FXMLCfg, Path);
// Object Inspector
FObjectInspectorOptions.Save(FXMLCfg, Path);
if Assigned(FDockedOpt) then if Assigned(FDockedOpt) then
FDockedOpt.Save(Path, FXMLCfg); FDockedOpt.Save(Path, FXMLCfg);
end; end;
procedure TDesktopOpt.ExportSettingsToIDE; procedure TDesktopOpt.ExportSettingsToIDE(const AOptions: TEnvironmentOptions);
begin begin
if Assigned(FDockedOpt) then if Assigned(FDockedOpt) then
FDockedOpt.ExportSettingsToIDE; FDockedOpt.ExportSettingsToIDE;
IDEWindowIntf.IDEDialogLayoutList.Assign(FIDEDialogLayoutList); IDEWindowIntf.IDEDialogLayoutList.Assign(FIDEDialogLayoutList);
IDEWindowIntf.IDEWindowCreators.SimpleLayoutStorage.CopyItemsFrom(FIDEWindowCreatorsLayoutList); IDEWindowIntf.IDEWindowCreators.SimpleLayoutStorage.CopyItemsFrom(FIDEWindowCreatorsLayoutList);
FObjectInspectorOptions.ExportSettingsToIDE(AOptions);
end; end;
procedure InitLayoutHelper(const FormID: string); procedure InitLayoutHelper(const FormID: string);
@ -1640,7 +1769,7 @@ begin
try try
if AutoSaveActiveDesktop and Assigned(DebugDesktop) then if AutoSaveActiveDesktop and Assigned(DebugDesktop) then
begin begin
Desktop.ImportSettingsFromIDE; Desktop.ImportSettingsFromIDE(Self);
DebugDesktop.Assign(Desktop); DebugDesktop.Assign(Desktop);
end; end;
@ -1674,7 +1803,7 @@ begin
begin begin
FLastDesktopBeforeDebug := TDesktopOpt.Create(ActiveDesktopName); FLastDesktopBeforeDebug := TDesktopOpt.Create(ActiveDesktopName);
if AutoSaveActiveDesktop then if AutoSaveActiveDesktop then
Desktop.ImportSettingsFromIDE; Desktop.ImportSettingsFromIDE(Self);
FLastDesktopBeforeDebug.Assign(Desktop, False); FLastDesktopBeforeDebug.Assign(Desktop, False);
EnvironmentOptions.UseDesktop(DebugDesktop); EnvironmentOptions.UseDesktop(DebugDesktop);
end; end;
@ -2096,7 +2225,7 @@ begin
end; end;
Desktop.Assign(ActiveDesktop, False); Desktop.Assign(ActiveDesktop, False);
Desktop.ExportSettingsToIDE; Desktop.ExportSettingsToIDE(Self);
FileUpdated; FileUpdated;
except except
@ -2399,7 +2528,7 @@ begin
and (Application.MainForm<>nil) and Application.MainForm.Visible then and (Application.MainForm<>nil) and Application.MainForm.Visible then
begin begin
//save active desktop //save active desktop
Desktop.ImportSettingsFromIDE; Desktop.ImportSettingsFromIDE(Self);
ActiveDesktop.Assign(Desktop); ActiveDesktop.Assign(Desktop);
if Assigned(FLastDesktopBeforeDebug) then//are we in debug session? if Assigned(FLastDesktopBeforeDebug) then//are we in debug session?
@ -2890,8 +3019,8 @@ begin
ActiveDesktopName := ADesktop.Name; ActiveDesktopName := ADesktop.Name;
if ADesktop.AssociatedDebugDesktopName<>'' then if ADesktop.AssociatedDebugDesktopName<>'' then
DebugDesktopName := ADesktop.AssociatedDebugDesktopName; DebugDesktopName := ADesktop.AssociatedDebugDesktopName;
Desktop.ExportSettingsToIDE(Self);
DoAfterWrite(False); //this is needed to get the EditorToolBar refreshed!!! - needed only here in UseDesktop() DoAfterWrite(False); //this is needed to get the EditorToolBar refreshed!!! - needed only here in UseDesktop()
Desktop.ExportSettingsToIDE;
Desktop.RestoreDesktop; Desktop.RestoreDesktop;
//set focus back to the previously focused control //set focus back to the previously focused control

View File

@ -4656,7 +4656,8 @@ procedure TMainIDE.SaveDesktopSettings(TheEnvironmentOptions: TEnvironmentOption
begin begin
if ConsoleVerbosity>0 then if ConsoleVerbosity>0 then
DebugLn(['Hint: (lazarus) TMainIDE.SaveDesktopSettings']); DebugLn(['Hint: (lazarus) TMainIDE.SaveDesktopSettings']);
EnvironmentOptions.Desktop.ImportSettingsFromIDE;
EnvironmentOptions.Desktop.ImportSettingsFromIDE(TheEnvironmentOptions);
if ObjectInspector1<>nil then if ObjectInspector1<>nil then
TheEnvironmentOptions.ObjectInspectorOptions.Assign(ObjectInspector1); TheEnvironmentOptions.ObjectInspectorOptions.Assign(ObjectInspector1);