mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-19 08:09:31 +02:00
EnvironmentOptions: add registrable extension classes for other IDE units that need to store options.
git-svn-id: trunk@60891 -
This commit is contained in:
parent
6bb1920582
commit
ba5ac8f30d
@ -453,10 +453,25 @@ type
|
||||
property Items[Index: Integer]: TCustomDesktopOpt read GetItem; default;
|
||||
end;
|
||||
|
||||
{ TIDESubOptions }
|
||||
|
||||
TIDESubOptions = class(TPersistent)
|
||||
private
|
||||
FPath: string;
|
||||
public
|
||||
procedure ReadFromXml(AnXmlConf: TRttiXMLConfig);
|
||||
procedure WriteToXml(AnXmlConf: TRttiXMLConfig);
|
||||
procedure ReadFromXml(AnXmlConf: TRttiXMLConfig; APath: String); virtual; abstract;
|
||||
procedure WriteToXml(AnXmlConf: TRttiXMLConfig; APath: String); virtual; abstract;
|
||||
procedure Assign(Source: TPersistent); override;
|
||||
property Path: String read FPath;
|
||||
end;
|
||||
|
||||
{ TEnvironmentOptions - class for storing environment options }
|
||||
|
||||
TEnvironmentOptions = class(TIDEEnvironmentOptions)
|
||||
private
|
||||
fRegisteredSubConfig: TObjectList;
|
||||
FDebuggerAutoCloseAsm: boolean;
|
||||
// config file
|
||||
FFilename: string;
|
||||
@ -645,6 +660,7 @@ type
|
||||
function GetMakeFilename: string;
|
||||
function GetMsgColors(u: TMessageLineUrgency): TColor;
|
||||
function GetMsgViewColors(c: TMsgWndColor): TColor;
|
||||
function GetSubConfig(Index: Integer): TIDESubOptions;
|
||||
function GetTestBuildDirectory: string;
|
||||
procedure LoadNonDesktop(Path: String);
|
||||
procedure SaveNonDesktop(Path: String);
|
||||
@ -671,6 +687,10 @@ type
|
||||
class function GetGroupCaption:string; override;
|
||||
class function GetInstance: TAbstractIDEOptions; override;
|
||||
procedure DoAfterWrite(Restore: boolean); override;
|
||||
procedure RegisterSubConfig(ASubConfig: TIDESubOptions; APath: String);
|
||||
procedure UnRegisterSubConfig(ASubConfig: TIDESubOptions);
|
||||
function SubConfigCount: integer;
|
||||
property SubConfig[Index: Integer]: TIDESubOptions read GetSubConfig;
|
||||
public
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
@ -1086,6 +1106,24 @@ begin
|
||||
WriteStr(Result, u);
|
||||
end;
|
||||
|
||||
{ TIDESubOptions }
|
||||
|
||||
procedure TIDESubOptions.ReadFromXml(AnXmlConf: TRttiXMLConfig);
|
||||
begin
|
||||
ReadFromXml(AnXmlConf, FPath);
|
||||
end;
|
||||
|
||||
procedure TIDESubOptions.WriteToXml(AnXmlConf: TRttiXMLConfig);
|
||||
begin
|
||||
WriteToXml(AnXmlConf, FPath);
|
||||
end;
|
||||
|
||||
procedure TIDESubOptions.Assign(Source: TPersistent);
|
||||
begin
|
||||
inherited Assign(Source);
|
||||
FPath := TIDESubOptions(Source).FPath;
|
||||
end;
|
||||
|
||||
{ TDesktopOIOptions }
|
||||
|
||||
constructor TDesktopOIOptions.Create;
|
||||
@ -1615,6 +1653,7 @@ var
|
||||
u: TMessageLineUrgency;
|
||||
begin
|
||||
inherited Create;
|
||||
fRegisteredSubConfig := TObjectList.Create(False);
|
||||
for o:=low(FParseValues) to high(FParseValues) do
|
||||
FParseValues[o].ParseStamp:=CTInvalidChangeStamp;
|
||||
|
||||
@ -1773,6 +1812,7 @@ destructor TEnvironmentOptions.Destroy;
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
FreeAndNil(fRegisteredSubConfig);
|
||||
FreeAndNil(FDesktops);
|
||||
FreeAndNil(FDesktop);
|
||||
FreeAndNil(FLastDesktopBeforeDebug);
|
||||
@ -1837,6 +1877,36 @@ begin
|
||||
inherited DoAfterWrite(Restore);
|
||||
end;
|
||||
|
||||
procedure TEnvironmentOptions.RegisterSubConfig(ASubConfig: TIDESubOptions;
|
||||
APath: String);
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
if (APath = '') or (APath = '/') then
|
||||
raise Exception.Create('Empty SubConfig path');
|
||||
if APath[Length(APath)-1] <> '/' then
|
||||
APath := APath + '/';
|
||||
if APath[1] = '/' then
|
||||
delete(APath,1 ,1);
|
||||
for i := 0 to SubConfigCount - 1 do
|
||||
if SubConfig[i].FPath = APath then
|
||||
raise Exception.Create('Duplicate SubConfig path');
|
||||
fRegisteredSubConfig.Add(ASubConfig);
|
||||
ASubConfig.FPath := APath;
|
||||
if FXMLCfg <> nil then
|
||||
ASubConfig.ReadFromXml(FXMLCfg, APath);
|
||||
end;
|
||||
|
||||
procedure TEnvironmentOptions.UnRegisterSubConfig(ASubConfig: TIDESubOptions);
|
||||
begin
|
||||
fRegisteredSubConfig.Remove(ASubConfig);
|
||||
end;
|
||||
|
||||
function TEnvironmentOptions.SubConfigCount: integer;
|
||||
begin
|
||||
Result := fRegisteredSubConfig.Count;
|
||||
end;
|
||||
|
||||
procedure TEnvironmentOptions.EnableDebugDesktop;
|
||||
begin
|
||||
if not Assigned(FLastDesktopBeforeDebug) and Assigned(DebugDesktop) and (DebugDesktop <> ActiveDesktop) then
|
||||
@ -2272,6 +2342,9 @@ begin
|
||||
Desktop.Assign(ActiveDesktop, False);
|
||||
Desktop.ExportSettingsToIDE(Self);
|
||||
|
||||
for i := 0 to SubConfigCount - 1 do
|
||||
SubConfig[i].ReadFromXml(FXMLCfg);
|
||||
|
||||
FileUpdated;
|
||||
except
|
||||
on E: Exception do
|
||||
@ -2605,6 +2678,9 @@ begin
|
||||
FDesktops[i].Save(CurPath+'Desktop'+IntToStr(i+1)+'/');
|
||||
end;
|
||||
|
||||
for i := 0 to SubConfigCount - 1 do
|
||||
SubConfig[i].WriteToXml(FXMLCfg);
|
||||
|
||||
FXMLCfg.Flush;
|
||||
FileUpdated;
|
||||
except
|
||||
@ -3206,6 +3282,11 @@ begin
|
||||
Result:=fMsgViewColors[c];
|
||||
end;
|
||||
|
||||
function TEnvironmentOptions.GetSubConfig(Index: Integer): TIDESubOptions;
|
||||
begin
|
||||
Result := TIDESubOptions(fRegisteredSubConfig[Index]);
|
||||
end;
|
||||
|
||||
function TEnvironmentOptions.GetTestBuildDirectory: string;
|
||||
begin
|
||||
Result:=FParseValues[eopTestBuildDirectory].UnparsedValue;
|
||||
|
Loading…
Reference in New Issue
Block a user