IDE: Refactoring, extract LoadNonDesktop from TEnvironmentOptions.Load.

git-svn-id: trunk@49416 -
This commit is contained in:
juha 2015-06-23 10:42:01 +00:00
parent ea74ed9399
commit 4626c393b2

View File

@ -258,6 +258,7 @@ type
// config file
FFilename: string;
FFileAge: longint;
FFileVersion: integer;
FFileHasChangedOnDisk: boolean;
FMaxExtToolsInParallel: integer;
FOldLazarusVersion: string;
@ -439,6 +440,8 @@ type
function GetMsgColors(u: TMessageLineUrgency): TColor;
function GetMsgViewColors(c: TMsgWndColor): TColor;
function GetTestBuildDirectory: string;
procedure LoadNonDesktop(XMLConfig: TXMLConfig; Cfg: TXMLOptionsStorage;
Path: String);
procedure SetCompilerFilename(const AValue: string);
procedure SetCompilerMessagesFilename(AValue: string);
procedure SetDebuggerEventLogColors(AIndex: TDBGEventType;
@ -1099,22 +1102,8 @@ begin
FFileHasChangedOnDisk:=true;
end;
procedure TEnvironmentOptions.Load(OnlyDesktop:boolean);
var
XMLConfig: TXMLConfig;
FileVersion: integer;
procedure AddRecentProjectInitial(aProjPath, aProjFile: string);
// Add a project to the list of recent projects if the project has write access.
// The check can be removed when the IDE allows compiling read-only projects.
var
WholeFilePath: String;
begin
aProjPath:=SwitchPathDelims(aProjPath, True);
WholeFilePath:=ExtractFilePath(Application.ExeName) + aProjPath + aProjFile;
if FileIsWritable(aProjPath) and FileIsWritable(WholeFilePath) then
AddToRecentList(WholeFilePath,FRecentProjectFiles,FMaxRecentProjectFiles,rltFile);
end;
procedure TEnvironmentOptions.LoadNonDesktop(XMLConfig: TXMLConfig; Cfg: TXMLOptionsStorage;
Path: String);
procedure LoadBackupInfo(var BackupInfo: TBackupInfo; const Path:string);
var i:integer;
@ -1132,117 +1121,16 @@ var
end;
AdditionalExtension:=XMLConfig.GetValue(Path+'AdditionalExtension','bak');
MaxCounter:=XMLConfig.GetValue(Path+'MaxCounter',9);
if FileVersion<101 then
if FFileVersion<101 then
SubDirectory:=''
else
SubDirectory:=XMLConfig.GetValue(Path+'SubDirectory','backup');
end;
end;
procedure LoadPascalFileExt(const Path: string);
begin
fPascalFileExtension:=PascalExtToType(XMLConfig.GetValue(
Path+'Naming/PascalFileExtension',PascalExtension[petPAS]));
if fPascalFileExtension=petNone then
fPascalFileExtension:=petPAS;
end;
procedure LoadLanguage;
begin
fLanguageID:=XMLConfig.GetValue('EnvironmentOptions/Language/ID','');
end;
var
Path: String;
CurPath: String;
i, j: Integer;
Rec: PIDEOptionsGroupRec;
Cfg: TXMLOptionsStorage;
EventType: TDBGEventType;
NodeName: String;
mwc: TMsgWndColor;
u: TMessageLineUrgency;
begin
Cfg:=nil;
try
XMLConfig:=GetXMLCfg(false);
Cfg:=TXMLOptionsStorage.Create(XMLConfig);
try
Path:='EnvironmentOptions/';
FileVersion:=XMLConfig.GetValue(Path+'Version/Value',0);
FOldLazarusVersion:=XMLConfig.GetValue(Path+'Version/Lazarus','');
if FOldLazarusVersion='' then begin
// 108 added LastCalledByLazarusFullPath
// 107 added Lazarus version
// 1.1 r36507 106
// 0.9.31 r28811 106
// 0.9.29 r21344 106
// 0.9.27 r16725 106
// 0.9.25 r12751 106
// 0.9.23 r10809 106
end;
// language
LoadLanguage;
// auto save
FAskSaveSessionOnly:=XMLConfig.GetValue(Path+'AutoSave/AskSaveSessionOnly',false);
FAutoSaveEditorFiles:=XMLConfig.GetValue(Path+'AutoSave/EditorFiles',true);
FAutoSaveProject:=XMLConfig.GetValue(Path+'AutoSave/Project',true);
FAutoSaveIntervalInSecs:=XMLConfig.GetValue(Path+'AutoSave/IntervalInSecs',600);
FLastSavedProjectFile:=XMLConfig.GetValue(Path+'AutoSave/LastSavedProjectFile','');
FOpenLastProjectAtStart:=XMLConfig.GetValue(Path+'AutoSave/OpenLastProjectAtStart',true);
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);
FGridColor:=XMLConfig.GetValue(Path+'FormEditor/GridColor',FGridColor);
FSnapToGrid:=XMLConfig.GetValue(Path+'FormEditor/SnapToGrid',true);
FGridSizeX:=XMLConfig.GetValue(Path+'FormEditor/GridSizeX',8);
FGridSizeY:=XMLConfig.GetValue(Path+'FormEditor/GridSizeY',8);
FShowGuideLines:=XMLConfig.GetValue(Path+'FormEditor/ShowGuideLines',true);
FSnapToGuideLines:=XMLConfig.GetValue(Path+'FormEditor/SnapToGuideLines',true);
FGuideLineColorLeftTop:=XMLConfig.GetValue(Path+'FormEditor/GuideLineColorLeftTop',
FGuideLineColorLeftTop);
FGuideLineColorRightBottom:=XMLConfig.GetValue(Path+'FormEditor/GuideLineColorRightBottom',
FGuideLineColorRightBottom);
FShowComponentCaptions:=XMLConfig.GetValue(Path+'FormEditor/ShowComponentCaptions',true);
FShowEditorHints:=XMLConfig.GetValue(Path+'FormEditor/ShowEditorHints',true);
FAutoCreateFormsOnOpen:=XMLConfig.GetValue(Path+'FormEditor/AutoCreateFormsOnOpen',true);
FCheckPackagesOnFormCreate:=XMLConfig.GetValue(Path+'FormEditor/CheckPackagesOnFormCreate',true);
FRightClickSelects:=XMLConfig.GetValue(Path+'FormEditor/RightClickSelects',true);
FGrabberColor:=XMLConfig.GetValue(Path+'FormEditor/GrabberColor/Value',FGrabberColor);
FMarkerColor:=XMLConfig.GetValue(Path+'FormEditor/MarkerColor/Value',FMarkerColor);
FRubberbandSelectionColor:=XMLConfig.GetValue(Path+'FormEditor/Rubberband/SelectionColor/Value',
FRubberbandSelectionColor);
FRubberbandCreationColor:=XMLConfig.GetValue(Path+'FormEditor/Rubberband/CreationColor/Value',
FRubberbandCreationColor);
FRubberbandSelectsGrandChilds:=XMLConfig.GetValue(Path+'FormEditor/Rubberband/SelectsGrandChilds/Value',false);
FDesignerPaintLazy:=XMLConfig.GetValue(Path+'FormEditor/DesignerPaint/Lazy/Value',true);
FCreateComponentFocusNameProperty:=XMLConfig.GetValue(
Path+'FormEditor/CreateComponentFocusNameProperty/Value',false);
FSwitchToFavoritesOITab:=XMLConfig.GetValue(Path+'FormEditor/SwitchToFavoritesOITab/Value',false);
if not OnlyDesktop then begin
// files
LazarusDirectory:=XMLConfig.GetValue(Path+'LazarusDirectory/Value',LazarusDirectory);
LoadRecentList(XMLConfig,FLazarusDirHistory,Path+'LazarusDirectory/History/',rltFile);
@ -1312,6 +1200,121 @@ begin
end;
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.
// The check can be removed when the IDE allows compiling read-only projects.
var
WholeFilePath: String;
begin
aProjPath:=SwitchPathDelims(aProjPath, True);
WholeFilePath:=ExtractFilePath(Application.ExeName) + aProjPath + aProjFile;
if FileIsWritable(aProjPath) and FileIsWritable(WholeFilePath) then
AddToRecentList(WholeFilePath,FRecentProjectFiles,FMaxRecentProjectFiles,rltFile);
end;
procedure LoadPascalFileExt(const Path: string);
begin
fPascalFileExtension:=PascalExtToType(XMLConfig.GetValue(
Path+'Naming/PascalFileExtension',PascalExtension[petPAS]));
if fPascalFileExtension=petNone then
fPascalFileExtension:=petPAS;
end;
var
Path, CurPath: String;
Cfg: TXMLOptionsStorage;
i, j: Integer;
Rec: PIDEOptionsGroupRec;
NodeName: String;
mwc: TMsgWndColor;
u: TMessageLineUrgency;
begin
Cfg:=nil;
try
XMLConfig:=GetXMLCfg(false);
Cfg:=TXMLOptionsStorage.Create(XMLConfig);
try
Path:='EnvironmentOptions/';
FFileVersion:=XMLConfig.GetValue(Path+'Version/Value',0);
FOldLazarusVersion:=XMLConfig.GetValue(Path+'Version/Lazarus','');
if FOldLazarusVersion='' then begin
// 108 added LastCalledByLazarusFullPath
// 107 added Lazarus version
// 1.1 r36507 106
// 0.9.31 r28811 106
// 0.9.29 r21344 106
// 0.9.27 r16725 106
// 0.9.25 r12751 106
// 0.9.23 r10809 106
end;
// language
fLanguageID:=XMLConfig.GetValue('EnvironmentOptions/Language/ID','');
// auto save
FAskSaveSessionOnly:=XMLConfig.GetValue(Path+'AutoSave/AskSaveSessionOnly',false);
FAutoSaveEditorFiles:=XMLConfig.GetValue(Path+'AutoSave/EditorFiles',true);
FAutoSaveProject:=XMLConfig.GetValue(Path+'AutoSave/Project',true);
FAutoSaveIntervalInSecs:=XMLConfig.GetValue(Path+'AutoSave/IntervalInSecs',600);
FLastSavedProjectFile:=XMLConfig.GetValue(Path+'AutoSave/LastSavedProjectFile','');
FOpenLastProjectAtStart:=XMLConfig.GetValue(Path+'AutoSave/OpenLastProjectAtStart',true);
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);
FGridColor:=XMLConfig.GetValue(Path+'FormEditor/GridColor',FGridColor);
FSnapToGrid:=XMLConfig.GetValue(Path+'FormEditor/SnapToGrid',true);
FGridSizeX:=XMLConfig.GetValue(Path+'FormEditor/GridSizeX',8);
FGridSizeY:=XMLConfig.GetValue(Path+'FormEditor/GridSizeY',8);
FShowGuideLines:=XMLConfig.GetValue(Path+'FormEditor/ShowGuideLines',true);
FSnapToGuideLines:=XMLConfig.GetValue(Path+'FormEditor/SnapToGuideLines',true);
FGuideLineColorLeftTop:=XMLConfig.GetValue(Path+'FormEditor/GuideLineColorLeftTop',
FGuideLineColorLeftTop);
FGuideLineColorRightBottom:=XMLConfig.GetValue(Path+'FormEditor/GuideLineColorRightBottom',
FGuideLineColorRightBottom);
FShowComponentCaptions:=XMLConfig.GetValue(Path+'FormEditor/ShowComponentCaptions',true);
FShowEditorHints:=XMLConfig.GetValue(Path+'FormEditor/ShowEditorHints',true);
FAutoCreateFormsOnOpen:=XMLConfig.GetValue(Path+'FormEditor/AutoCreateFormsOnOpen',true);
FCheckPackagesOnFormCreate:=XMLConfig.GetValue(Path+'FormEditor/CheckPackagesOnFormCreate',true);
FRightClickSelects:=XMLConfig.GetValue(Path+'FormEditor/RightClickSelects',true);
FGrabberColor:=XMLConfig.GetValue(Path+'FormEditor/GrabberColor/Value',FGrabberColor);
FMarkerColor:=XMLConfig.GetValue(Path+'FormEditor/MarkerColor/Value',FMarkerColor);
FRubberbandSelectionColor:=XMLConfig.GetValue(Path+'FormEditor/Rubberband/SelectionColor/Value',
FRubberbandSelectionColor);
FRubberbandCreationColor:=XMLConfig.GetValue(Path+'FormEditor/Rubberband/CreationColor/Value',
FRubberbandCreationColor);
FRubberbandSelectsGrandChilds:=XMLConfig.GetValue(Path+'FormEditor/Rubberband/SelectsGrandChilds/Value',false);
FDesignerPaintLazy:=XMLConfig.GetValue(Path+'FormEditor/DesignerPaint/Lazy/Value',true);
FCreateComponentFocusNameProperty:=XMLConfig.GetValue(
Path+'FormEditor/CreateComponentFocusNameProperty/Value',false);
FSwitchToFavoritesOITab:=XMLConfig.GetValue(Path+'FormEditor/SwitchToFavoritesOITab/Value',false);
if not OnlyDesktop then
LoadNonDesktop(XMLConfig, Cfg, Path);
// project inspector
FProjInspSortAlphabetically:=XMLConfig.GetValue(Path+'ProjInspSortAlphabetically/Value',false);
FProjInspShowDirHierarchy:=XMLConfig.GetValue(Path+'ProjInspShowDirHierarchy/Value',false);
@ -1374,7 +1377,7 @@ begin
// naming
LoadPascalFileExt(Path+'');
if FileVersion>=103 then begin
if FFileVersion>=103 then begin
fCharcaseFileAction:=CharCaseFileActionNameToType(XMLConfig.GetValue(
Path+'CharcaseFileAction/Value',''));
end else begin
@ -1386,7 +1389,7 @@ begin
else
fCharcaseFileAction:=ccfaIgnore;
end;
if FileVersion>=104 then
if FFileVersion>=104 then
CurPath:=Path+'AmbiguousFileAction/Value'
else
CurPath:=Path+'AmbigiousFileAction/Value';
@ -1406,7 +1409,7 @@ begin
// fpdoc
FPDocPaths := XMLConfig.GetValue(Path+'LazDoc/Paths','');
if FileVersion<=105 then
if FFileVersion<=105 then
FPDocPaths:=LineBreaksToDelimiter(FPDocPaths,';');
// 'new items'