UPD: Move DirectoryHotList to localconfig.xml

This commit is contained in:
Lior Lahav 2026-03-21 17:24:09 +02:00
commit aff36aab56
2 changed files with 57 additions and 7 deletions

View file

@ -16,6 +16,7 @@ var
//Global Configuration Filename
const
gcfExtensionAssociation : string = 'extassoc.xml';
gcfLocalConfig : string = 'localconfig.xml';
procedure LoadPaths;
procedure UpdateEnvironmentVariable;

View file

@ -231,7 +231,8 @@ const
// 13 - Replace Configuration/UseConfigInProgramDir by doublecmd.inf
// 14 - Move some colors to colors.json
// 15 - Move custom columns colors to colors.json
ConfigVersion = 15;
// 16 - Move DirectoryHotList to localconfig.xml
ConfigVersion = 16;
COLORS_JSON = 'colors.json';
@ -996,6 +997,33 @@ begin
end;
end;
function LoadLocalConfig(var {%H-}ErrorMessage: String): Boolean;
var
Root: TXmlNode;
LocalConfig: TXmlConfig;
LocalConfigFileName: String;
begin
LocalConfigFileName := gpCfgDir + gcfLocalConfig;
if mbFileExists(LocalConfigFileName) then
begin
LocalConfig:= TXmlConfig.Create(LocalConfigFileName);
try
LocalConfig.Load;
Root:= LocalConfig.RootNode;
if Assigned(LocalConfig.FindNode(Root, cSectionOfHotDir)) then
begin
gDirectoryHotlist.LoadFromXml(LocalConfig, Root);
Exit(True);
end;
finally
LocalConfig.Free;
end;
end;
Result:= True;
end;
procedure SaveHistoryConfig;
var
Root: TXmlNode;
@ -1049,6 +1077,23 @@ begin
end;
end;
procedure SaveLocalConfig;
var
Root: TXmlNode;
LocalConfig: TXmlConfig;
LocalConfigFileName: String;
begin
LocalConfigFileName := gpCfgDir + gcfLocalConfig;
LocalConfig:= TXmlConfig.Create(LocalConfigFileName);
try
Root:= LocalConfig.RootNode;
gDirectoryHotlist.SaveToXml(LocalConfig, Root, True);
LocalConfig.Save;
finally
LocalConfig.Free;
end;
end;
function GetValidDateTimeFormat(const aFormat, ADefaultFormat: string): string;
begin
try
@ -2486,6 +2531,9 @@ begin
CopySettingsFiles;
{ Local machine-specific configuration }
LoadConfigCheckErrors(@LoadLocalConfig, gpCfgDir + gcfLocalConfig, ErrorMessage);
{ Internal associations }
// "LoadExtsConfig" checks itself if file is present or not
LoadConfigCheckErrors(@LoadExtsConfig, gpCfgDir + gcfExtensionAssociation, ErrorMessage);
@ -2563,6 +2611,7 @@ begin
begin
SaveWithCheck(@SaveEarlyConfig, 'early config', ErrMsg);
SaveWithCheck(@SaveCfgIgnoreList, 'ignore list', ErrMsg);
SaveWithCheck(@SaveLocalConfig, 'local configuration', ErrMsg);
SaveWithCheck(@SaveCfgMainConfig, 'main configuration', ErrMsg);
SaveWithCheck(@SaveHighlightersConfig, 'highlighters config', ErrMsg);
SaveWithCheck(@SaveHistoryConfig, 'various history', ErrMsg);
@ -2668,6 +2717,12 @@ begin
DeleteNode(Root, 'Configuration/UseConfigInProgramDir');
end;
if (LoadedConfigVersion < 16) then
begin
gDirectoryHotlist.LoadFromXML(gConfig, Root);
DeleteNode(Root, cSectionOfHotDir);
end;
{ Language page }
gPOFileName := GetValue(Root, 'Language/POFileName', gPOFileName);
@ -3222,9 +3277,6 @@ begin
gIgnoreListFile:= GetValue(Node, 'IgnoreListFile', gIgnoreListFile);
end;
{ Directories HotList }
gDirectoryHotlist.LoadFromXML(gConfig, Root);
{ Viewer }
Node := Root.FindNode('Viewer');
if Assigned(Node) then
@ -3824,9 +3876,6 @@ begin
SetAttr(Node, 'Enabled', gIgnoreListFileEnabled);
SetValue(Node, 'IgnoreListFile', gIgnoreListFile);
{ Directories HotList }
gDirectoryHotlist.SaveToXml(gConfig, Root, TRUE);
{ Viewer }
Node := FindNode(Root, 'Viewer',True);
SetValue(Node, 'PreviewVisible',gPreviewVisible);