IDE: Save desktop related stuff under XML path Desktop/. Prepare for collection of desktop settings.

git-svn-id: trunk@49419 -
This commit is contained in:
juha 2015-06-23 10:42:05 +00:00
parent 1962d97b75
commit 7e13107ac4
5 changed files with 161 additions and 147 deletions

View File

@ -89,8 +89,8 @@ type
procedure Clear;
procedure Assign(Source: TCompPaletteOptions);
function IsDefault: Boolean;
function Load(XMLConfig: TXMLConfig): boolean;
function Save(XMLConfig: TXMLConfig): boolean;
procedure Load(XMLConfig: TXMLConfig; Path: String);
procedure Save(XMLConfig: TXMLConfig; Path: String);
public
property HiddenPageNames: TStringList read FHiddenPageNames;
end;
@ -431,7 +431,7 @@ begin
and (HiddenPageNames.Count = 0);
end;
function TCompPaletteOptions.Load(XMLConfig: TXMLConfig): boolean;
procedure TCompPaletteOptions.Load(XMLConfig: TXMLConfig; Path: String);
var
CompList: TStringList;
SubPath, CompPath: String;
@ -439,10 +439,10 @@ var
PageCount, CompCount: Integer;
i, j: Integer;
begin
Result:=False;
Path := Path + BasePath;
try
FPageNames.Clear;
SubPath:=BasePath+'Pages/';
SubPath:=Path+'Pages/';
PageCount:=XMLConfig.GetValue(SubPath+'Count', 0);
for i:=1 to PageCount do begin
PageName:=XMLConfig.GetValue(SubPath+'Item'+IntToStr(i)+'/Value', '');
@ -451,7 +451,7 @@ begin
end;
FHiddenPageNames.Clear;
SubPath:=BasePath+'HiddenPages/';
SubPath:=Path+'HiddenPages/';
PageCount:=XMLConfig.GetValue(SubPath+'Count', 0);
for i:=1 to PageCount do begin
PageName:=XMLConfig.GetValue(SubPath+'Item'+IntToStr(i)+'/Value', '');
@ -460,7 +460,7 @@ begin
end;
FComponentPages.Clear;
SubPath:=BasePath+'ComponentPages/';
SubPath:=Path+'ComponentPages/';
PageCount:=XMLConfig.GetValue(SubPath+'Count', 0);
for i:=1 to PageCount do begin
CompPath:=SubPath+'Page'+IntToStr(i)+'/';
@ -479,30 +479,29 @@ begin
exit;
end;
end;
Result:=True;
end;
function TCompPaletteOptions.Save(XMLConfig: TXMLConfig): boolean;
procedure TCompPaletteOptions.Save(XMLConfig: TXMLConfig; Path: String);
var
CompList: TStringList;
SubPath, CompPath: String;
i, j: Integer;
begin
Result:=False;
try
SubPath:=BasePath+'Pages/';
Path := Path + BasePath;
SubPath:=Path+'Pages/';
XMLConfig.DeletePath(SubPath);
XMLConfig.SetDeleteValue(SubPath+'Count', FPageNames.Count, 0);
for i:=0 to FPageNames.Count-1 do
XMLConfig.SetDeleteValue(SubPath+'Item'+IntToStr(i+1)+'/Value', FPageNames[i], '');
SubPath:=BasePath+'HiddenPages/';
SubPath:=Path+'HiddenPages/';
XMLConfig.DeletePath(SubPath);
XMLConfig.SetDeleteValue(SubPath+'Count', FHiddenPageNames.Count, 0);
for i:=0 to FHiddenPageNames.Count-1 do
XMLConfig.SetDeleteValue(SubPath+'Item'+IntToStr(i+1)+'/Value', FHiddenPageNames[i], '');
SubPath:=BasePath+'ComponentPages/';
SubPath:=Path+'ComponentPages/';
XMLConfig.DeletePath(SubPath);
XMLConfig.SetDeleteValue(SubPath+'Count', FComponentPages.Count, 0);
for i:=0 to FComponentPages.Count-1 do begin
@ -519,7 +518,6 @@ begin
exit;
end;
end;
Result:=true;
end;
{ TCompPaletteUserOrder }

View File

@ -48,8 +48,8 @@ type
function Equals(Opts: TEditorToolBarOptions): boolean; overload;
procedure Assign(Source: TEditorToolBarOptions);
procedure CreateDefaults;
function Load(XMLConfig: TXMLConfig): Boolean;
function Save(XMLConfig: TXMLConfig): Boolean;
procedure Load(XMLConfig: TXMLConfig; Path: String);
procedure Save(XMLConfig: TXMLConfig; Path: String);
published
property Visible: Boolean read FVisible write FVisible;
property Position: string read FPosition write FPosition;
@ -190,24 +190,24 @@ begin
FButtonNames.Add('---------------');
end;
function TEditorToolBarOptions.Load(XMLConfig: TXMLConfig): Boolean;
procedure TEditorToolBarOptions.Load(XMLConfig: TXMLConfig; Path: String);
var
ButtonCount: Integer;
ButtonName: string;
I: Integer;
cfg: TConfigStorage;
begin
Result := True;
if XMLConfig.HasPath(BasePath + 'Count', True) then
Path := Path + BasePath;
if XMLConfig.HasPath(Path + 'Count', True) then
begin
FVisible := XMLConfig.GetValue(BasePath + 'Visible', True);
FPosition := XMLConfig.GetValue(BasePath + 'Position', 'Top');
ButtonCount := XMLConfig.GetValue(BasePath + 'Count', 0);
FVisible := XMLConfig.GetValue(Path + 'Visible', True);
FPosition := XMLConfig.GetValue(Path + 'Position', 'Top');
ButtonCount := XMLConfig.GetValue(Path + 'Count', 0);
for I := 1 to ButtonCount do
begin
ButtonName := XMLConfig.GetValue(BasePath + 'Button' + IntToStr(I) + '/Name', '');
ButtonName := XMLConfig.GetValue(Path + 'Button' + IntToStr(I) + '/Name', '');
if ButtonName = '' then // Old format
ButtonName := XMLConfig.GetValue(BasePath + 'Buttons/Name' + IntToStr(I) + '/Value', '');
ButtonName := XMLConfig.GetValue(Path + 'Buttons/Name' + IntToStr(I) + '/Value', '');
if ButtonName <> '' then
FButtonNames.Add(ButtonName);
end;
@ -237,16 +237,16 @@ begin
end;
end;
function TEditorToolBarOptions.Save(XMLConfig: TXMLConfig): Boolean;
procedure TEditorToolBarOptions.Save(XMLConfig: TXMLConfig; Path: String);
var
I: Integer;
begin
Result := True;
XMLConfig.SetDeleteValue(BasePath + 'Visible', FVisible, False);
XMLConfig.SetDeleteValue(BasePath + 'Position', FPosition, 'Top');
XMLConfig.SetDeleteValue(BasePath + 'Count', ButtonNames.Count, 0);
Path := Path + BasePath;
XMLConfig.SetDeleteValue(Path + 'Visible', FVisible, False);
XMLConfig.SetDeleteValue(Path + 'Position', FPosition, 'Top');
XMLConfig.SetDeleteValue(Path + 'Count', ButtonNames.Count, 0);
for I := 0 to ButtonNames.Count-1 do
XMLConfig.SetDeleteValue(BasePath + 'Button' + IntToStr(I+1) + '/Name', ButtonNames[I], '');
XMLConfig.SetDeleteValue(Path + 'Button' + IntToStr(I+1) + '/Name', ButtonNames[I], '');
end;
{ TAllEditorToolbars }

View File

@ -37,8 +37,8 @@ uses
{$ifdef Windows}
ShlObj,
{$endif}
Classes, SysUtils, TypInfo, Graphics, Controls, Forms, LCLProc, FileProcs,
Dialogs, LazConfigStorage, Laz2_XMLCfg, LazUTF8,
Classes, SysUtils, TypInfo, strutils, Graphics, Controls, Forms, LCLProc,
FileProcs, Dialogs, LazConfigStorage, Laz2_XMLCfg, LazUTF8,
// IDEIntf
ProjectIntf, ObjectInspector, IDEWindowIntf, IDEOptionsIntf,
ComponentReg, IDEExternToolIntf, MacroDefIntf,
@ -49,9 +49,10 @@ uses
IdeCoolbarData, EditorToolbarStatic;
const
EnvOptsVersion: integer = 108;
EnvOptsVersion: integer = 109;
// 107 added Lazarus version
// 108 added LastCalledByLazarusFullPath
// 109 changed paths for desktop settings, supporting multiple desktops.
{$IFDEF Windows}
DefaultMakefilename = '$Path($(CompPath))make.exe';
@ -265,6 +266,9 @@ type
FXMLCfg: TRttiXMLConfig;
FConfigStore: TXMLOptionsStorage;
FDbgConfigStore: TXMLOptionsStorage; // for debugger
// Options are saved / loaded using these.
XMLConfig: TXMLConfig;
FCfg: TXMLOptionsStorage;
// title
FIDETitleStartsWithProject: boolean;
@ -440,8 +444,10 @@ type
function GetMsgColors(u: TMessageLineUrgency): TColor;
function GetMsgViewColors(c: TMsgWndColor): TColor;
function GetTestBuildDirectory: string;
procedure LoadNonDesktop(XMLConfig: TXMLConfig; Cfg: TXMLOptionsStorage; Path: String);
procedure SaveNonDesktop(XMLConfig: TXMLConfig; Cfg: TXMLOptionsStorage; Path: String);
procedure LoadDesktop(Path: String);
procedure LoadNonDesktop(Path: String);
procedure SaveDesktop(Path: String);
procedure SaveNonDesktop(Path: String);
procedure SetCompilerFilename(const AValue: string);
procedure SetCompilerMessagesFilename(AValue: string);
procedure SetDebuggerEventLogColors(AIndex: TDBGEventType;
@ -1102,8 +1108,7 @@ begin
FFileHasChangedOnDisk:=true;
end;
procedure TEnvironmentOptions.LoadNonDesktop(XMLConfig: TXMLConfig; Cfg: TXMLOptionsStorage;
Path: String);
procedure TEnvironmentOptions.LoadNonDesktop(Path: String);
procedure LoadBackupInfo(var BackupInfo: TBackupInfo; const Path:string);
var i:integer;
@ -1159,9 +1164,9 @@ begin
FLastCalledByLazarusFullPath:=XMLConfig.GetValue(Path+'LastCalledByLazarusFullPath/Value','');
// global build options, additions and overrides
Cfg.AppendBasePath('BuildMatrix');
FBuildMatrixOptions.LoadFromConfig(Cfg);
Cfg.UndoAppendBasePath;
FCfg.AppendBasePath('BuildMatrix');
FBuildMatrixOptions.LoadFromConfig(FCfg);
FCfg.UndoAppendBasePath;
FUseBuildModes:=XMLConfig.GetValue(Path+'Build/UseBuildModes',false);
// backup
@ -1200,9 +1205,35 @@ begin
end;
end;
procedure TEnvironmentOptions.LoadDesktop(Path: String);
begin
// Windows layout
IDEWindowCreators.SimpleLayoutStorage.LoadFromConfig(FCfg,Path);
FIDEDialogLayoutList.LoadFromConfig(FConfigStore, Path+'Dialogs/');
FSingleTaskBarButton:=XMLConfig.GetValue(Path+'SingleTaskBarButton/Value', False);
FHideIDEOnRun:=XMLConfig.GetValue(Path+'HideIDEOnRun/Value',false);
FIDETitleStartsWithProject:=XMLConfig.GetValue(Path+'IDETitleStartsWithProject/Value',false);
FIDETitleIncludesBuildMode:=XMLConfig.GetValue(Path+'IDETitleIncludesBuildMode/Value',false);
IDEProjectDirectoryInIdeTitle:=XMLConfig.GetValue(Path+'IDEProjectDirectoryInIdeTitle/Value',false);
FComponentPaletteVisible:=XMLConfig.GetValue(Path+'ComponentPaletteVisible/Value',true);
FAutoAdjustIDEHeight:=XMLConfig.GetValue(Path+'AutoAdjustIDEHeight/Value',true);
FAutoAdjustIDEHeightFullCompPal:=XMLConfig.GetValue(Path+'AutoAdjustIDEHeightFullComponentPalette/Value',true);
FCompletionWindowWidth:=XMLConfig.GetValue(Path+'CompletionWindowWidth/Value', 320);
FCompletionWindowHeight:=XMLConfig.GetValue(Path+'CompletionWindowHeight/Value', 6);
// Window menu
FIDENameForDesignedFormList:=XMLConfig.GetValue(Path+'IDENameForDesignedFormList/Value',false);
if AnsiStartsStr('EnvironmentOptions', Path) then
Path := ''; // Toolbars and palette were at the top level in XML.
// IDE Coolbar
FIDECoolBarOptions.Load(XMLConfig, Path);
// Editor Toolbar
FEditorToolBarOptions.Load(XMLConfig, Path);
// component palette
FComponentPaletteOptions.Load(XMLConfig, Path);
end;
procedure TEnvironmentOptions.Load(OnlyDesktop:boolean);
var
XMLConfig: TXMLConfig;
procedure AddRecentProjectInitial(aProjPath, aProjFile: string);
// Add a project to the list of recent projects if the project has write access.
@ -1226,17 +1257,16 @@ var
var
Path, CurPath: String;
Cfg: TXMLOptionsStorage;
i, j: Integer;
Rec: PIDEOptionsGroupRec;
NodeName: String;
mwc: TMsgWndColor;
u: TMessageLineUrgency;
begin
Cfg:=nil;
FCfg:=nil;
try
XMLConfig:=GetXMLCfg(false);
Cfg:=TXMLOptionsStorage.Create(XMLConfig);
FCfg:=TXMLOptionsStorage.Create(XMLConfig);
try
Path:='EnvironmentOptions/';
FFileVersion:=XMLConfig.GetValue(Path+'Version/Value',0);
@ -1253,7 +1283,7 @@ begin
end;
// language
fLanguageID:=XMLConfig.GetValue('EnvironmentOptions/Language/ID','');
fLanguageID:=XMLConfig.GetValue(Path+'Language/ID','');
// auto save
FAskSaveSessionOnly:=XMLConfig.GetValue(Path+'AutoSave/AskSaveSessionOnly',false);
@ -1265,23 +1295,6 @@ begin
FShowCompileDialog:=XMLConfig.GetValue(Path+'ShowCompileDialog/Value',false);
FAutoCloseCompileDialog:=XMLConfig.GetValue(Path+'AutoCloseCompileDialog/Value',false);
// Windows layout
IDEWindowCreators.SimpleLayoutStorage.LoadFromConfig(Cfg,Path+'Desktop/');
FIDEDialogLayoutList.LoadFromConfig(FConfigStore, Path+'Desktop/Dialogs/');
FSingleTaskBarButton := XMLConfig.GetValue(Path+'Desktop/SingleTaskBarButton/Value', False);
FHideIDEOnRun:=XMLConfig.GetValue(Path+'Desktop/HideIDEOnRun/Value',false);
FIDETitleStartsWithProject:=XMLConfig.GetValue(Path+'Desktop/IDETitleStartsWithProject/Value',false);
FIDETitleIncludesBuildMode:=XMLConfig.GetValue(Path+'Desktop/IDETitleIncludesBuildMode/Value',false);
IDEProjectDirectoryInIdeTitle:=XMLConfig.GetValue(Path+'Desktop/IDEProjectDirectoryInIdeTitle/Value',false);
FComponentPaletteVisible:=XMLConfig.GetValue(Path+'Desktop/ComponentPaletteVisible/Value',true);
FAutoAdjustIDEHeight:=XMLConfig.GetValue(Path+'Desktop/AutoAdjustIDEHeight/Value',true);
FAutoAdjustIDEHeightFullCompPal:=XMLConfig.GetValue(Path+'Desktop/AutoAdjustIDEHeightFullComponentPalette/Value',true);
FCompletionWindowWidth:=XMLConfig.GetValue(Path+'Desktop/CompletionWindowWidth/Value', 320);
FCompletionWindowHeight:=XMLConfig.GetValue(Path+'Desktop/CompletionWindowHeight/Value', 6);
// Window menu
FIDENameForDesignedFormList:=XMLConfig.GetValue(Path+'Desktop/IDENameForDesignedFormList/Value',false);
// form editor
FShowGrid:=XMLConfig.GetValue(Path+'FormEditor/ShowGrid',true);
FShowBorderSpacing:=XMLConfig.GetValue(Path+'FormEditor/ShowBorderSpacing',false);
@ -1313,7 +1326,7 @@ begin
FSwitchToFavoritesOITab:=XMLConfig.GetValue(Path+'FormEditor/SwitchToFavoritesOITab/Value',false);
if not OnlyDesktop then
LoadNonDesktop(XMLConfig, Cfg, Path);
LoadNonDesktop(Path);
// project inspector
FProjInspSortAlphabetically:=XMLConfig.GetValue(Path+'ProjInspSortAlphabetically/Value',false);
@ -1400,13 +1413,6 @@ begin
FAskForFilenameOnNewFile:=XMLConfig.GetValue(Path+'AskForFilenameOnNewFile/Value',false);
FLowercaseDefaultFilename:=XMLConfig.GetValue(Path+'LowercaseDefaultFilename/Value',true);
// IDE Coolbar
FIDECoolBarOptions.Load(XMLConfig);
// Editor Toolbar
FEditorToolBarOptions.Load(XMLConfig);
// component palette
FComponentPaletteOptions.Load(XMLConfig);
// fpdoc
FPDocPaths := XMLConfig.GetValue(Path+'LazDoc/Paths','');
if FFileVersion<=105 then
@ -1421,7 +1427,8 @@ begin
FObjectInspectorOptions.SaveBounds:=false;
// IDEEditorGroups
for i := 0 to IDEEditorGroups.Count - 1 do begin
for i := 0 to IDEEditorGroups.Count - 1 do
begin
Rec := IDEEditorGroups[i];
NodeName := Rec^.GroupClass.ClassName;
Rec^.Collapsed := XMLConfig.GetValue(Path+'OptionDialog/Tree/' + NodeName + '/Value',
@ -1435,8 +1442,20 @@ begin
end;
end;
// The user can define many desktops. They are saved under path Desktops/.
CurPath:='Desktops/';
if XMLConfig.HasPath(CurPath, True) then
begin
// New path under Desktops/.
j := XMLConfig.GetValue(CurPath+'Count/', 1);
for i := 0 to j-1 do
LoadDesktop(CurPath+'Desktop'+IntToStr(i+1)+'/');
end
else // Old path was under EnvironmentOptions/.
LoadDesktop(Path+'Desktop/');
finally
Cfg.Free;
FCfg.Free;
end;
FileUpdated;
except
@ -1446,8 +1465,7 @@ begin
end;
end;
procedure TEnvironmentOptions.SaveNonDesktop(XMLConfig: TXMLConfig; Cfg: TXMLOptionsStorage;
Path: String);
procedure TEnvironmentOptions.SaveNonDesktop(Path: String);
procedure SaveBackupInfo(var BackupInfo: TBackupInfo; Path:string);
var i:integer;
@ -1504,9 +1522,9 @@ begin
XMLConfig.SetDeleteValue(Path+'LastCalledByLazarusFullPath/Value',FLastCalledByLazarusFullPath,'');
// global buid options
Cfg.AppendBasePath('BuildMatrix');
FBuildMatrixOptions.SaveToConfig(Cfg,IsGlobalMode);
Cfg.UndoAppendBasePath;
FCfg.AppendBasePath('BuildMatrix');
FBuildMatrixOptions.SaveToConfig(FCfg,IsGlobalMode);
FCfg.UndoAppendBasePath;
XMLConfig.SetDeleteValue(Path+'Build/UseBuildModes',FUseBuildModes,false);
// backup
@ -1547,22 +1565,45 @@ begin
end;
end;
procedure TEnvironmentOptions.SaveDesktop(Path: String);
begin
// windows
IDEWindowCreators.SimpleLayoutStorage.SaveToConfig(FCfg,Path);
FIDEDialogLayoutList.SaveToConfig(FConfigStore,Path+'Dialogs/');
XMLConfig.SetDeleteValue(Path+'SingleTaskBarButton/Value',FSingleTaskBarButton, False);
XMLConfig.SetDeleteValue(Path+'HideIDEOnRun/Value',FHideIDEOnRun,false);
XMLConfig.SetDeleteValue(Path+'IDETitleStartsWithProject/Value',FIDETitleStartsWithProject,false);
XMLConfig.SetDeleteValue(Path+'IDETitleIncludesBuildMode/Value',FIDETitleIncludesBuildMode,false);
XMLConfig.SetDeleteValue(Path+'IDEProjectDirectoryInIdeTitle/Value',FIDEProjectDirectoryInIdeTitle,false);
XMLConfig.SetDeleteValue(Path+'ComponentPaletteVisible/Value',FComponentPaletteVisible,true);
XMLConfig.SetDeleteValue(Path+'AutoAdjustIDEHeight/Value',FAutoAdjustIDEHeight,true);
XMLConfig.SetDeleteValue(Path+'AutoAdjustIDEHeightFullComponentPalette/Value',
FAutoAdjustIDEHeightFullCompPal,true);
XMLConfig.SetDeleteValue(Path+'CompletionWindowWidth/Value',FCompletionWindowWidth, 320);
XMLConfig.SetDeleteValue(Path+'CompletionWindowHeight/Value',FCompletionWindowHeight, 6);
// Window menu
XMLConfig.SetDeleteValue(Path+'IDENameForDesignedFormList/Value',FIDENameForDesignedFormList,false);
// IDE Coolbar
FIDECoolBarOptions.Save(XMLConfig, Path);
// Editor Toolbar
FEditorToolBarOptions.Save(XMLConfig, Path);
// component palette
FComponentPaletteOptions.Save(XMLConfig, Path);
end;
procedure TEnvironmentOptions.Save(OnlyDesktop: boolean);
var
XMLConfig: TXMLConfig;
var
Path: String;
Path, CurPath, NodeName: String;
i, j: Integer;
NodeName: String;
Rec: PIDEOptionsGroupRec;
Cfg: TXMLOptionsStorage;
mwc: TMsgWndColor;
u: TMessageLineUrgency;
begin
Cfg:=nil;
FCfg:=nil;
try
XMLConfig:=GetXMLCfg(true);
Cfg:=TXMLOptionsStorage.Create(XMLConfig);
FCfg:=TXMLOptionsStorage.Create(XMLConfig);
try
Path:='EnvironmentOptions/';
@ -1580,34 +1621,6 @@ begin
XMLConfig.SetDeleteValue(Path+'AutoSave/LastSavedProjectFile',FLastSavedProjectFile,'');
XMLConfig.SetDeleteValue(Path+'AutoSave/OpenLastProjectAtStart',FOpenLastProjectAtStart,true);
// windows
IDEWindowCreators.SimpleLayoutStorage.SaveToConfig(Cfg,Path+'Desktop/');
FIDEDialogLayoutList.SaveToConfig(FConfigStore,Path+'Desktop/Dialogs/');
XMLConfig.SetDeleteValue(Path+'Desktop/SingleTaskBarButton/Value',
FSingleTaskBarButton, False);
XMLConfig.SetDeleteValue(Path+'Desktop/HideIDEOnRun/Value',FHideIDEOnRun,
false);
XMLConfig.SetDeleteValue(Path+'Desktop/IDETitleStartsWithProject/Value',
FIDETitleStartsWithProject,false);
XMLConfig.SetDeleteValue(Path+'Desktop/IDETitleIncludesBuildMode/Value',
FIDETitleIncludesBuildMode,false);
XMLConfig.SetDeleteValue(Path+'Desktop/IDEProjectDirectoryInIdeTitle/Value',
FIDEProjectDirectoryInIdeTitle,false);
XMLConfig.SetDeleteValue(Path+'Desktop/ComponentPaletteVisible/Value',
FComponentPaletteVisible,true);
XMLConfig.SetDeleteValue(Path+'Desktop/AutoAdjustIDEHeight/Value',
FAutoAdjustIDEHeight,true);
XMLConfig.SetDeleteValue(Path+'Desktop/AutoAdjustIDEHeightFullComponentPalette/Value',
FAutoAdjustIDEHeightFullCompPal,true);
XMLConfig.SetDeleteValue(Path+'Desktop/CompletionWindowWidth/Value',
FCompletionWindowWidth, 320);
XMLConfig.SetDeleteValue(Path+'Desktop/CompletionWindowHeight/Value',
FCompletionWindowHeight, 6);
// Window menu
XMLConfig.SetDeleteValue(Path+'Desktop/IDENameForDesignedFormList/Value',
FIDENameForDesignedFormList,false);
// form editor
XMLConfig.SetDeleteValue(Path+'FormEditor/ShowBorderSpacing',FShowBorderSpacing,false);
XMLConfig.SetDeleteValue(Path+'FormEditor/ShowGrid',FShowGrid,true);
@ -1641,7 +1654,7 @@ begin
XMLConfig.SetDeleteValue(Path+'AutoCloseCompileDialog/Value',FAutoCloseCompileDialog,False);
if not OnlyDesktop then
SaveNonDesktop(XMLConfig, Cfg, Path);
SaveNonDesktop(Path);
// project inspector
XMLConfig.SetDeleteValue(Path+'ProjInspSortAlphabetically/Value',FProjInspSortAlphabetically,false);
@ -1702,17 +1715,9 @@ begin
AmbiguousFileActionNames[fAmbiguousFileAction],
AmbiguousFileActionNames[afaAsk]);
XMLConfig.SetDeleteValue(Path+'AskForFilenameOnNewFile/Value',
FAskForFilenameOnNewFile,false);
FAskForFilenameOnNewFile,false);
XMLConfig.SetDeleteValue(Path+'LowercaseDefaultFilename/Value',
FLowercaseDefaultFilename,true);
// IDE Coolbar
FIDECoolBarOptions.Save(XMLConfig);
// Editor Toolbar
FEditorToolBarOptions.Save(XMLConfig);
// component palette
FComponentPaletteOptions.Save(XMLConfig);
// fpdoc
XMLConfig.SetDeleteValue(Path+'LazDoc/Paths',FPDocPaths,'');
@ -1725,7 +1730,8 @@ begin
FObjectInspectorOptions.Save;
// IDEEditorGroups
for i := 0 to IDEEditorGroups.Count - 1 do begin
for i := 0 to IDEEditorGroups.Count - 1 do
begin
Rec := IDEEditorGroups[i];
NodeName := Rec^.GroupClass.ClassName;
XMLConfig.SetDeleteValue(Path+'OptionDialog/Tree/' + NodeName + '/Value',
@ -1740,8 +1746,16 @@ begin
end;
end;
end;
// The user can define many desktops. They are saved under path Desktops/.
CurPath:='Desktops/';
XMLConfig.SetDeleteValue(CurPath+'Count', 1, 0); // ToDo: use count from collection.
j := 1;
for i := 0 to j-1 do // ToDo: iterate collection.
SaveDesktop(CurPath+'Desktop'+IntToStr(i+1)+'/');
finally
Cfg.Free;
FCfg.Free;
end;
XMLConfig.Flush;
FileUpdated;

View File

@ -792,7 +792,7 @@ begin
XMLConfig := OpenXML(ImportDialog.Filename);
if Assigned(XMLConfig) then
try
fLocalOptions.Load(XMLConfig);
fLocalOptions.Load(XMLConfig, '');
ActualReadSettings; // Read from options to GUI.
ShowMessageFmt(lisSuccessfullyImported, [ImportDialog.Filename]);
fConfigChanged := True;
@ -812,7 +812,7 @@ begin
if Assigned(XMLConfig) then
try
ActualWriteSettings(fLocalOptions); // Write from GUI to options.
fLocalOptions.Save(XMLConfig);
fLocalOptions.Save(XMLConfig, '');
ShowMessageFmt(lisSuccessfullyExported, [ExportDialog.Filename]);
finally
XMLConfig.Free;

View File

@ -78,8 +78,8 @@ type
destructor Destroy; override;
procedure Clear;
function EqualToolbars(Opts: TIDECoolBarOptions): boolean;
procedure Load(XMLConfig: TXMLConfig);
procedure Save(XMLConfig: TXMLConfig);
procedure Load(XMLConfig: TXMLConfig; Path: String);
procedure Save(XMLConfig: TXMLConfig; Path: String);
public
property IDECoolBarVisible: Boolean read FIDECoolBarVisible write FIDECoolBarVisible;
property IDECoolBarWidth: Integer read FIDECoolBarWidth write FIDECoolBarWidth;
@ -307,20 +307,21 @@ begin
FIDECoolBarToolBars.Add(ToolBarOpts);
end;
procedure TIDECoolBarOptions.Load(XMLConfig: TXMLConfig);
procedure TIDECoolBarOptions.Load(XMLConfig: TXMLConfig; Path: String);
var
ToolBarOpt: TIDEToolBarOptions;
ToolBarCount: Integer;
I: Integer;
begin
ToolbarCount := XMLConfig.GetValue(BasePath + 'Count', 0);
Path := Path + BasePath;
ToolbarCount := XMLConfig.GetValue(Path + 'Count', 0);
if ToolBarCount = 0 then // Old format
ToolbarCount := XMLConfig.GetValue(BasePath + 'ToolBarCount/Value', 0);
FIDECoolBarVisible := XMLConfig.GetValue(BasePath + 'Visible/Value', True);
FIDECoolBarWidth := XMLConfig.GetValue(BasePath + 'Width/Value', 230);
FIDECoolBarGrabStyle := XMLConfig.GetValue(BasePath + 'GrabStyle/Value', 1);
FIDECoolBarGrabWidth := XMLConfig.GetValue(BasePath + 'GrabWidth/Value', 5);
FIDECoolBarBorderStyle := XMLConfig.GetValue(BasePath + 'BorderStyle/Value', 1);
ToolbarCount := XMLConfig.GetValue(Path + 'ToolBarCount/Value', 0);
FIDECoolBarVisible := XMLConfig.GetValue(Path + 'Visible/Value', True);
FIDECoolBarWidth := XMLConfig.GetValue(Path + 'Width/Value', 230);
FIDECoolBarGrabStyle := XMLConfig.GetValue(Path + 'GrabStyle/Value', 1);
FIDECoolBarGrabWidth := XMLConfig.GetValue(Path + 'GrabWidth/Value', 5);
FIDECoolBarBorderStyle := XMLConfig.GetValue(Path + 'BorderStyle/Value', 1);
if ToolBarCount > 0 then
begin
FIDECoolBarToolBars.Clear;
@ -329,32 +330,33 @@ begin
ToolBarOpt := TIDEToolBarOptions.Create;
FIDECoolBarToolBars.Add(ToolBarOpt);
ToolBarOpt.FPosition := I;
ToolBarOpt.Load(XMLConfig, BasePath + 'ToolBar' + IntToStr(I+1) + '/');
ToolBarOpt.Load(XMLConfig, Path + 'ToolBar' + IntToStr(I+1) + '/');
end;
end;
if ToolBarCount = 0 then
CreateDefaultToolbars;
end;
procedure TIDECoolBarOptions.Save(XMLConfig: TXMLConfig);
procedure TIDECoolBarOptions.Save(XMLConfig: TXMLConfig; Path: String);
var
DefaultOpts: TDefaultCoolBarOptions;
I: Integer;
begin
DefaultOpts := TDefaultCoolBarOptions.Create;
try
XMLConfig.DeletePath(BasePath);
XMLConfig.SetDeleteValue(BasePath + 'Visible/Value', FIDECoolBarVisible, True);
XMLConfig.SetDeleteValue(BasePath + 'Width/Value', FIDECoolBarWidth, 0);
XMLConfig.SetDeleteValue(BasePath + 'GrabStyle/Value', FIDECoolBarGrabStyle, 1);
XMLConfig.SetDeleteValue(BasePath + 'GrabWidth/Value', FIDECoolBarGrabWidth, 5);
XMLConfig.SetDeleteValue(BasePath + 'BorderStyle/Value', FIDECoolBarBorderStyle, 1);
Path := Path + BasePath;
XMLConfig.DeletePath(Path);
XMLConfig.SetDeleteValue(Path + 'Visible/Value', FIDECoolBarVisible, True);
XMLConfig.SetDeleteValue(Path + 'Width/Value', FIDECoolBarWidth, 0);
XMLConfig.SetDeleteValue(Path + 'GrabStyle/Value', FIDECoolBarGrabStyle, 1);
XMLConfig.SetDeleteValue(Path + 'GrabWidth/Value', FIDECoolBarGrabWidth, 5);
XMLConfig.SetDeleteValue(Path + 'BorderStyle/Value', FIDECoolBarBorderStyle, 1);
if EqualToolbars(DefaultOpts) then Exit;
if FIDECoolBarToolBars.Count > 0 then
begin
XMLConfig.SetDeleteValue(BasePath + 'Count', FIDECoolBarToolBars.Count, 0);
XMLConfig.SetDeleteValue(Path + 'Count', FIDECoolBarToolBars.Count, 0);
for I := 0 to FIDECoolBarToolBars.Count - 1 do
FIDECoolBarToolBars[I].Save(XMLConfig, BasePath + 'ToolBar' + IntToStr(I+1) + '/');
FIDECoolBarToolBars[I].Save(XMLConfig, Path + 'ToolBar' + IntToStr(I+1) + '/');
end;
finally
DefaultOpts.Free;