mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-05-06 08:52:59 +02:00
IDE: load desktops: check file version when loading old data, cleaning up old data
git-svn-id: trunk@49806 -
This commit is contained in:
parent
aebdc634cf
commit
c36aa6da8e
@ -1778,29 +1778,34 @@ begin
|
|||||||
FDesktops.Clear;
|
FDesktops.Clear;
|
||||||
FDesktops.SetConfig(FXMLCfg, FConfigStore);
|
FDesktops.SetConfig(FXMLCfg, FConfigStore);
|
||||||
CurPath := 'Desktops/';
|
CurPath := 'Desktops/';
|
||||||
|
FActiveDesktopName := '';
|
||||||
if FXMLCfg.HasPath(CurPath, True) then
|
if FXMLCfg.HasPath(CurPath, True) then
|
||||||
begin
|
begin
|
||||||
// New path under Desktops/. Default=1 forces reading default values always.
|
// Default=1 forces reading default values always.
|
||||||
FDebugDesktopName := FXMLCfg.GetValue(CurPath+'DebugDesktop', '');
|
FDebugDesktopName := FXMLCfg.GetValue(CurPath+'DebugDesktop', '');
|
||||||
|
FActiveDesktopName := FXMLCfg.GetValue(CurPath+'ActiveDesktop', '');
|
||||||
j := FXMLCfg.GetValue(CurPath+'Count', 1);
|
j := FXMLCfg.GetValue(CurPath+'Count', 1);
|
||||||
for i := 1 to j do
|
for i := 1 to j do
|
||||||
FDesktops.AddFromCfg(CurPath+'Desktop'+IntToStr(i)+'/');
|
FDesktops.AddFromCfg(CurPath+'Desktop'+IntToStr(i)+'/');
|
||||||
|
end;
|
||||||
|
|
||||||
FActiveDesktopName := FXMLCfg.GetValue(CurPath+'ActiveDesktop', '');
|
if FFileVersion<109 then begin
|
||||||
end else
|
//load old default desktop - backwards compatibility - or create a new default desktop
|
||||||
FActiveDesktopName := '';
|
CurPath := 'Desktop/'; // New place: Desktop/
|
||||||
|
if not FXMLCfg.HasPath(CurPath, True) then
|
||||||
//load default desktop - backwards compatibility - or create a new default desktop
|
CurPath := Path+'Desktop/'; // Old place: EnvironmentOptions/Desktop/
|
||||||
CurPath := 'Desktop/'; // New place: Desktop/
|
if FXMLCfg.HasPath(CurPath, True) or//default desktop exists in the settings
|
||||||
if not FXMLCfg.HasPath(CurPath, True) then
|
((ActiveDesktop.IDECoolBarOptions.ToolBars.Count = 0) and
|
||||||
CurPath := Path+'Desktop/'; // Old place: EnvironmentOptions/Desktop/
|
(ActiveDesktop.FIDEDialogLayoutList.Count = 0))//desktop is empty, load it to recreate!
|
||||||
if FXMLCfg.HasPath(CurPath, True) or//default desktop exists in the settings
|
then
|
||||||
((ActiveDesktop.IDECoolBarOptions.ToolBars.Count = 0) and
|
begin
|
||||||
(ActiveDesktop.FIDEDialogLayoutList.Count = 0))//desktop is empty, load it to recreate!
|
ActiveDesktop.SetConfig(FXMLCfg, FConfigStore);
|
||||||
then
|
ActiveDesktop.Load(CurPath);
|
||||||
begin
|
end;
|
||||||
ActiveDesktop.SetConfig(FXMLCfg, FConfigStore);
|
end;
|
||||||
ActiveDesktop.Load(CurPath);
|
if FFileVersion<=109 then begin
|
||||||
|
FXMLCfg.DeletePath('Desktop');
|
||||||
|
FXMLCfg.DeletePath(CurPath+'Desktop');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Desktop.Assign(ActiveDesktop, False);
|
Desktop.Assign(ActiveDesktop, False);
|
||||||
@ -2107,13 +2112,10 @@ begin
|
|||||||
FDesktops[i].Save(CurPath+'Desktop'+IntToStr(i+1)+'/');
|
FDesktops[i].Save(CurPath+'Desktop'+IntToStr(i+1)+'/');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
FXMLCfg.DeletePath('Desktop/');
|
|
||||||
|
|
||||||
FXMLCfg.Flush;
|
FXMLCfg.Flush;
|
||||||
FileUpdated;
|
FileUpdated;
|
||||||
except
|
except
|
||||||
on E: Exception do begin
|
on E: Exception do begin
|
||||||
// ToDo
|
|
||||||
DebugLn('[TEnvironmentOptions.Save] error writing "',Filename,'": ',E.Message);
|
DebugLn('[TEnvironmentOptions.Save] error writing "',Filename,'": ',E.Message);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -2465,7 +2467,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function TEnvironmentOptions.GetActiveDesktop: TDesktopOpt;
|
function TEnvironmentOptions.GetActiveDesktop: TDesktopOpt;
|
||||||
procedure _UseDefault;
|
|
||||||
|
procedure ChooseDefault;
|
||||||
begin
|
begin
|
||||||
//use default desktop name
|
//use default desktop name
|
||||||
if Assigned(IDEDockMaster) then
|
if Assigned(IDEDockMaster) then
|
||||||
@ -2473,19 +2476,20 @@ function TEnvironmentOptions.GetActiveDesktop: TDesktopOpt;
|
|||||||
else
|
else
|
||||||
FActiveDesktopName := 'default';
|
FActiveDesktopName := 'default';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
if FActiveDesktopName <> '' then
|
if FActiveDesktopName <> '' then
|
||||||
begin
|
begin
|
||||||
Result := FDesktops.Find(FActiveDesktopName);
|
Result := FDesktops.Find(FActiveDesktopName);
|
||||||
if Assigned(Result) and Result.Compatible then//the selected desktop is supported (docked/docked)
|
if Assigned(Result) and Result.Compatible then
|
||||||
Exit;
|
Exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
//the selected desktop is unsupported (docked/undocked)
|
//the selected desktop is unsupported (docked/undocked)
|
||||||
// -> use default
|
// -> use default
|
||||||
_UseDefault;
|
ChooseDefault;
|
||||||
Result := FDesktops.Find(FActiveDesktopName);
|
Result := FDesktops.Find(FActiveDesktopName);
|
||||||
if Assigned(Result) and Result.Compatible then//the default desktop exists and is supported
|
if Assigned(Result) and Result.Compatible then
|
||||||
Exit;
|
Exit;
|
||||||
|
|
||||||
//recreate desktop with ActiveDesktopName
|
//recreate desktop with ActiveDesktopName
|
||||||
|
Loading…
Reference in New Issue
Block a user