mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 07:19:18 +02:00
object inspector now uses ConfigSorage instead of laz_xmlxcfg
git-svn-id: trunk@6172 -
This commit is contained in:
parent
1120fa2bdb
commit
cfaf6208d5
@ -35,8 +35,8 @@ uses
|
|||||||
{$IFDEF IDE_MEM_CHECK}
|
{$IFDEF IDE_MEM_CHECK}
|
||||||
MemCheck,
|
MemCheck,
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
Classes, SysUtils, FPCAdds, LCLProc, Forms, Controls, Buttons, GraphType, Graphics,
|
Classes, SysUtils, FPCAdds, LCLProc, Forms, Controls, Buttons, GraphType,
|
||||||
Laz_XMLCfg, ObjectInspector, ExtCtrls, StdCtrls, Spin, EditorOptions,
|
Graphics,ExtCtrls, StdCtrls, Spin, Laz_XMLCfg, ObjectInspector, EditorOptions,
|
||||||
LResources, LazConf, Dialogs, ExtToolDialog, IDEProcs, IDEOptionDefs,
|
LResources, LazConf, Dialogs, ExtToolDialog, IDEProcs, IDEOptionDefs,
|
||||||
InputHistory, LazarusIDEStrConsts, FileUtil;
|
InputHistory, LazarusIDEStrConsts, FileUtil;
|
||||||
|
|
||||||
@ -164,9 +164,10 @@ type
|
|||||||
private
|
private
|
||||||
FFilename: string;
|
FFilename: string;
|
||||||
FFileAge: longint;
|
FFileAge: longint;
|
||||||
FXMLCfg: TXMLConfig;
|
|
||||||
FFileHasChangedOnDisk: boolean;
|
FFileHasChangedOnDisk: boolean;
|
||||||
|
FXMLCfg: TXMLConfig;
|
||||||
|
FConfigStore: TXMLOptionsStorage;
|
||||||
|
|
||||||
FOnApplyWindowLayout: TOnApplyIDEWindowLayout;
|
FOnApplyWindowLayout: TOnApplyIDEWindowLayout;
|
||||||
|
|
||||||
// auto save
|
// auto save
|
||||||
@ -917,6 +918,7 @@ begin
|
|||||||
IDEOptionDefs.IDEDialogLayoutList:=nil;
|
IDEOptionDefs.IDEDialogLayoutList:=nil;
|
||||||
FIDEDialogLayoutList.Free;
|
FIDEDialogLayoutList.Free;
|
||||||
fIDEWindowLayoutList.Free;
|
fIDEWindowLayoutList.Free;
|
||||||
|
FConfigStore.Free;
|
||||||
FXMLCfg.Free;
|
FXMLCfg.Free;
|
||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
@ -1461,13 +1463,14 @@ end;
|
|||||||
function TEnvironmentOptions.GetXMLCfg(CleanConfig: boolean): TXMLConfig;
|
function TEnvironmentOptions.GetXMLCfg(CleanConfig: boolean): TXMLConfig;
|
||||||
begin
|
begin
|
||||||
if FileHasChangedOnDisk or (FXMLCfg=nil) then begin
|
if FileHasChangedOnDisk or (FXMLCfg=nil) then begin
|
||||||
|
FConfigStore.Free;
|
||||||
FXMLCfg.Free;
|
FXMLCfg.Free;
|
||||||
if CleanConfig then
|
if CleanConfig then
|
||||||
FXMLCfg:=TXMLConfig.CreateClean(Filename)
|
FXMLCfg:=TXMLConfig.CreateClean(Filename)
|
||||||
else
|
else
|
||||||
FXMLCfg:=TXMLConfig.Create(Filename);
|
FXMLCfg:=TXMLConfig.Create(Filename);
|
||||||
ObjectInspectorOptions.Filename:=Filename;
|
FConfigStore:=TXMLOptionsStorage.Create(FXMLCfg);
|
||||||
ObjectInspectorOptions.CustomXMLCfg:=FXMLCfg;
|
ObjectInspectorOptions.ConfigStore:=FConfigStore;
|
||||||
end;
|
end;
|
||||||
Result:=FXMLCfg;
|
Result:=FXMLCfg;
|
||||||
end;
|
end;
|
||||||
|
@ -37,7 +37,7 @@ interface
|
|||||||
uses
|
uses
|
||||||
Forms, SysUtils, Buttons, Classes, Graphics, GraphType, StdCtrls, LCLType,
|
Forms, SysUtils, Buttons, Classes, Graphics, GraphType, StdCtrls, LCLType,
|
||||||
LCLIntf, LCLProc, Controls, ComCtrls, ExtCtrls, TypInfo, Messages,
|
LCLIntf, LCLProc, Controls, ComCtrls, ExtCtrls, TypInfo, Messages,
|
||||||
LResources, PairSplitter, Laz_XMLCfg, Menus, Dialogs, ObjInspStrConsts,
|
LResources, PairSplitter, ConfigStorage, Menus, Dialogs, ObjInspStrConsts,
|
||||||
PropEdits, GraphPropEdits, ListViewPropEdit, ImageListEditor,
|
PropEdits, GraphPropEdits, ListViewPropEdit, ImageListEditor,
|
||||||
ComponentTreeView;
|
ComponentTreeView;
|
||||||
|
|
||||||
@ -53,13 +53,9 @@ type
|
|||||||
TOIOptions = class
|
TOIOptions = class
|
||||||
private
|
private
|
||||||
FComponentTreeHeight: integer;
|
FComponentTreeHeight: integer;
|
||||||
FCustomXMLCfg: TXMLConfig;
|
FConfigStore: TConfigStorage;
|
||||||
FDefaultItemHeight: integer;
|
FDefaultItemHeight: integer;
|
||||||
FFilename:string;
|
|
||||||
FFileAge: longint;
|
|
||||||
FShowComponentTree: boolean;
|
FShowComponentTree: boolean;
|
||||||
FXMLCfg: TXMLConfig;
|
|
||||||
FFileHasChangedOnDisk: boolean;
|
|
||||||
|
|
||||||
FSaveBounds: boolean;
|
FSaveBounds: boolean;
|
||||||
FLeft: integer;
|
FLeft: integer;
|
||||||
@ -71,20 +67,14 @@ type
|
|||||||
|
|
||||||
FGridBackgroundColor: TColor;
|
FGridBackgroundColor: TColor;
|
||||||
FShowHints: boolean;
|
FShowHints: boolean;
|
||||||
procedure SetFilename(const NewFilename: string);
|
|
||||||
function FileHasChangedOnDisk: boolean;
|
|
||||||
function GetXMLCfg: TXMLConfig;
|
|
||||||
procedure FileUpdated;
|
|
||||||
public
|
public
|
||||||
constructor Create;
|
constructor Create;
|
||||||
destructor Destroy; override;
|
|
||||||
function Load: boolean;
|
function Load: boolean;
|
||||||
function Save: boolean;
|
function Save: boolean;
|
||||||
procedure Assign(AnObjInspector: TObjectInspector);
|
procedure Assign(AnObjInspector: TObjectInspector);
|
||||||
procedure AssignTo(AnObjInspector: TObjectInspector);
|
procedure AssignTo(AnObjInspector: TObjectInspector);
|
||||||
public
|
public
|
||||||
property Filename:string read FFilename write SetFilename;
|
property ConfigStore: TConfigStorage read FConfigStore write FConfigStore;
|
||||||
property CustomXMLCfg: TXMLConfig read FCustomXMLCfg write FCustomXMLCfg;
|
|
||||||
|
|
||||||
property SaveBounds:boolean read FSaveBounds write FSaveBounds;
|
property SaveBounds:boolean read FSaveBounds write FSaveBounds;
|
||||||
property Left:integer read FLeft write FLeft;
|
property Left:integer read FLeft write FLeft;
|
||||||
@ -2155,46 +2145,9 @@ end;
|
|||||||
|
|
||||||
{ TOIOptions }
|
{ TOIOptions }
|
||||||
|
|
||||||
procedure TOIOptions.SetFilename(const NewFilename: string);
|
|
||||||
begin
|
|
||||||
if FFilename=NewFilename then exit;
|
|
||||||
FFilename:=NewFilename;
|
|
||||||
FFileHasChangedOnDisk:=true;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TOIOptions.FileHasChangedOnDisk: boolean;
|
|
||||||
begin
|
|
||||||
Result:=FFileHasChangedOnDisk
|
|
||||||
or ((FFilename<>'') and (FFileAge<>0) and (FileAge(FFilename)<>FFileAge));
|
|
||||||
FFileHasChangedOnDisk:=Result;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TOIOptions.GetXMLCfg: TXMLConfig;
|
|
||||||
begin
|
|
||||||
if CustomXMLCfg<>nil then begin
|
|
||||||
Result:=CustomXMLCfg;
|
|
||||||
end else begin
|
|
||||||
if FileHasChangedOnDisk or (FXMLCfg=nil) then begin
|
|
||||||
FXMLCfg.Free;
|
|
||||||
FXMLCfg:=TXMLConfig.Create(FFilename);
|
|
||||||
end;
|
|
||||||
Result:=FXMLCfg;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TOIOptions.FileUpdated;
|
|
||||||
begin
|
|
||||||
FFileHasChangedOnDisk:=false;
|
|
||||||
if FFilename<>'' then
|
|
||||||
FFileAge:=FileAge(FFilename)
|
|
||||||
else
|
|
||||||
FFileAge:=0;
|
|
||||||
end;
|
|
||||||
|
|
||||||
constructor TOIOptions.Create;
|
constructor TOIOptions.Create;
|
||||||
begin
|
begin
|
||||||
inherited Create;
|
inherited Create;
|
||||||
FFilename:='';
|
|
||||||
|
|
||||||
FSaveBounds:=false;
|
FSaveBounds:=false;
|
||||||
FLeft:=0;
|
FLeft:=0;
|
||||||
@ -2210,45 +2163,36 @@ begin
|
|||||||
FGridBackgroundColor:=clBtnFace;
|
FGridBackgroundColor:=clBtnFace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TOIOptions.Destroy;
|
function TOIOptions.Load: boolean;
|
||||||
begin
|
|
||||||
FXMLCfg.Free;
|
|
||||||
inherited Destroy;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TOIOptions.Load:boolean;
|
|
||||||
var XMLConfig: TXMLConfig;
|
|
||||||
begin
|
begin
|
||||||
Result:=false;
|
Result:=false;
|
||||||
if not FileExists(FFilename) then exit;
|
if ConfigStore=nil then exit;
|
||||||
try
|
try
|
||||||
XMLConfig:=GetXMLCfg;
|
FSaveBounds:=ConfigStore.GetValue('ObjectInspectorOptions/Bounds/Valid'
|
||||||
|
,false);
|
||||||
FSaveBounds:=XMLConfig.GetValue('ObjectInspectorOptions/Bounds/Valid'
|
|
||||||
,false);
|
|
||||||
if FSaveBounds then begin
|
if FSaveBounds then begin
|
||||||
FLeft:=XMLConfig.GetValue('ObjectInspectorOptions/Bounds/Left',0);
|
FLeft:=ConfigStore.GetValue('ObjectInspectorOptions/Bounds/Left',0);
|
||||||
FTop:=XMLConfig.GetValue('ObjectInspectorOptions/Bounds/Top',0);
|
FTop:=ConfigStore.GetValue('ObjectInspectorOptions/Bounds/Top',0);
|
||||||
FWidth:=XMLConfig.GetValue('ObjectInspectorOptions/Bounds/Width',250);
|
FWidth:=ConfigStore.GetValue('ObjectInspectorOptions/Bounds/Width',250);
|
||||||
FHeight:=XMLConfig.GetValue('ObjectInspectorOptions/Bounds/Height',400);
|
FHeight:=ConfigStore.GetValue('ObjectInspectorOptions/Bounds/Height',400);
|
||||||
end;
|
end;
|
||||||
FPropertyGridSplitterX:=XMLConfig.GetValue(
|
FPropertyGridSplitterX:=ConfigStore.GetValue(
|
||||||
'ObjectInspectorOptions/Bounds/PropertyGridSplitterX',110);
|
'ObjectInspectorOptions/Bounds/PropertyGridSplitterX',110);
|
||||||
if FPropertyGridSplitterX<10 then FPropertyGridSplitterX:=10;
|
if FPropertyGridSplitterX<10 then FPropertyGridSplitterX:=10;
|
||||||
FEventGridSplitterX:=XMLConfig.GetValue(
|
FEventGridSplitterX:=ConfigStore.GetValue(
|
||||||
'ObjectInspectorOptions/Bounds/EventGridSplitterX',110);
|
'ObjectInspectorOptions/Bounds/EventGridSplitterX',110);
|
||||||
if FEventGridSplitterX<10 then FEventGridSplitterX:=10;
|
if FEventGridSplitterX<10 then FEventGridSplitterX:=10;
|
||||||
FDefaultItemHeight:=XMLConfig.GetValue(
|
FDefaultItemHeight:=ConfigStore.GetValue(
|
||||||
'ObjectInspectorOptions/Bounds/DefaultItemHeight',20);
|
'ObjectInspectorOptions/Bounds/DefaultItemHeight',20);
|
||||||
if FDefaultItemHeight<0 then FDefaultItemHeight:=20;
|
if FDefaultItemHeight<0 then FDefaultItemHeight:=20;
|
||||||
FShowComponentTree:=XMLConfig.GetValue(
|
FShowComponentTree:=ConfigStore.GetValue(
|
||||||
'ObjectInspectorOptions/ComponentTree/Show/Value',true);
|
'ObjectInspectorOptions/ComponentTree/Show/Value',true);
|
||||||
FComponentTreeHeight:=XMLConfig.GetValue(
|
FComponentTreeHeight:=ConfigStore.GetValue(
|
||||||
'ObjectInspectorOptions/ComponentTree/Height/Value',100);
|
'ObjectInspectorOptions/ComponentTree/Height/Value',100);
|
||||||
|
|
||||||
FGridBackgroundColor:=XMLConfig.GetValue(
|
FGridBackgroundColor:=ConfigStore.GetValue(
|
||||||
'ObjectInspectorOptions/GridBackgroundColor',clBtnFace);
|
'ObjectInspectorOptions/GridBackgroundColor',clBtnFace);
|
||||||
FShowHints:=XMLConfig.GetValue(
|
FShowHints:=ConfigStore.GetValue(
|
||||||
'ObjectInspectorOptions/ShowHints',false);
|
'ObjectInspectorOptions/ShowHints',false);
|
||||||
except
|
except
|
||||||
on E: Exception do begin
|
on E: Exception do begin
|
||||||
@ -2259,40 +2203,36 @@ begin
|
|||||||
Result:=true;
|
Result:=true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TOIOptions.Save:boolean;
|
function TOIOptions.Save: boolean;
|
||||||
var XMLConfig: TXMLConfig;
|
|
||||||
begin
|
begin
|
||||||
Result:=false;
|
Result:=false;
|
||||||
|
if ConfigStore=nil then exit;
|
||||||
try
|
try
|
||||||
XMLConfig:=GetXMLCfg;
|
ConfigStore.SetDeleteValue('ObjectInspectorOptions/Bounds/Valid',FSaveBounds,
|
||||||
|
|
||||||
XMLConfig.SetDeleteValue('ObjectInspectorOptions/Bounds/Valid',FSaveBounds,
|
|
||||||
false);
|
false);
|
||||||
if FSaveBounds then begin
|
if FSaveBounds then begin
|
||||||
XMLConfig.SetValue('ObjectInspectorOptions/Bounds/Left',FLeft);
|
ConfigStore.SetValue('ObjectInspectorOptions/Bounds/Left',FLeft);
|
||||||
XMLConfig.SetValue('ObjectInspectorOptions/Bounds/Top',FTop);
|
ConfigStore.SetValue('ObjectInspectorOptions/Bounds/Top',FTop);
|
||||||
XMLConfig.SetValue('ObjectInspectorOptions/Bounds/Width',FWidth);
|
ConfigStore.SetValue('ObjectInspectorOptions/Bounds/Width',FWidth);
|
||||||
XMLConfig.SetValue('ObjectInspectorOptions/Bounds/Height',FHeight);
|
ConfigStore.SetValue('ObjectInspectorOptions/Bounds/Height',FHeight);
|
||||||
end;
|
end;
|
||||||
XMLConfig.SetDeleteValue(
|
ConfigStore.SetDeleteValue(
|
||||||
'ObjectInspectorOptions/Bounds/PropertyGridSplitterX',
|
'ObjectInspectorOptions/Bounds/PropertyGridSplitterX',
|
||||||
FPropertyGridSplitterX, 110);
|
FPropertyGridSplitterX, 110);
|
||||||
XMLConfig.SetDeleteValue(
|
ConfigStore.SetDeleteValue(
|
||||||
'ObjectInspectorOptions/Bounds/EventGridSplitterX',
|
'ObjectInspectorOptions/Bounds/EventGridSplitterX',
|
||||||
FEventGridSplitterX, 110);
|
FEventGridSplitterX, 110);
|
||||||
XMLConfig.SetDeleteValue('ObjectInspectorOptions/Bounds/DefaultItemHeight',
|
ConfigStore.SetDeleteValue('ObjectInspectorOptions/Bounds/DefaultItemHeight',
|
||||||
FDefaultItemHeight,20);
|
FDefaultItemHeight,20);
|
||||||
XMLConfig.SetDeleteValue('ObjectInspectorOptions/ComponentTree/Show/Value',
|
ConfigStore.SetDeleteValue('ObjectInspectorOptions/ComponentTree/Show/Value',
|
||||||
FShowComponentTree,true);
|
FShowComponentTree,true);
|
||||||
XMLConfig.SetDeleteValue('ObjectInspectorOptions/ComponentTree/Height/Value',
|
ConfigStore.SetDeleteValue('ObjectInspectorOptions/ComponentTree/Height/Value',
|
||||||
FComponentTreeHeight,100);
|
FComponentTreeHeight,100);
|
||||||
|
|
||||||
XMLConfig.SetDeleteValue('ObjectInspectorOptions/GridBackgroundColor',
|
ConfigStore.SetDeleteValue('ObjectInspectorOptions/GridBackgroundColor',
|
||||||
FGridBackgroundColor,clBackground);
|
FGridBackgroundColor,clBackground);
|
||||||
XMLConfig.SetDeleteValue('ObjectInspectorOptions/ShowHints',FShowHints,
|
ConfigStore.SetDeleteValue('ObjectInspectorOptions/ShowHints',FShowHints,
|
||||||
false);
|
false);
|
||||||
|
|
||||||
if XMLConfig<>CustomXMLCfg then XMLConfig.Flush;
|
|
||||||
except
|
except
|
||||||
on E: Exception do begin
|
on E: Exception do begin
|
||||||
DebugLn('ERROR: TOIOptions.Save: ',E.Message);
|
DebugLn('ERROR: TOIOptions.Save: ',E.Message);
|
||||||
|
Loading…
Reference in New Issue
Block a user