{ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ Author: Mattias Gaertner Abstract: Miscellaneous options of the lazarus IDE. } unit MiscOptions; {$mode objfpc}{$H+} interface uses Classes, SysUtils, BuildLazDialog, LazConf, IDEProcs, XMLCfg; type TMiscellaneousOptions = class private fBuildLazOpts: TBuildLazarusOptions; fFilename: string; function GetFilename: string; public constructor Create; destructor Destroy; override; procedure Load; procedure Save; property BuildLazOpts: TBuildLazarusOptions read fBuildLazOpts write fBuildLazOpts; property Filename: string read GetFilename; end; var MiscellaneousOptions: TMiscellaneousOptions; implementation const MiscOptsFilename = 'miscellaneousoptions.xml'; MiscOptsVersion = 1; { TMiscellaneousOptions } constructor TMiscellaneousOptions.Create; begin inherited Create; BuildLazOpts:=TBuildLazarusOptions.Create; end; destructor TMiscellaneousOptions.Destroy; begin BuildLazOpts.Free; inherited Destroy; end; function TMiscellaneousOptions.GetFilename: string; var ConfFileName: string; begin if fFilename='' then begin ConfFileName:=SetDirSeparators(GetPrimaryConfigPath+'/'+MiscOptsFilename); CopySecondaryConfigFile(MiscOptsFilename); if (not FileExists(ConfFileName)) then begin writeln('Note: miscellaneous options file not found - using defaults'); end; FFilename:=ConfFilename; end; Result:=fFilename; end; procedure TMiscellaneousOptions.Load; var XMLConfig: TXMLConfig; FileVersion: integer; begin try XMLConfig:=TXMLConfig.Create(GetFilename); except writeln('Error: unable to open miscellaneous options "',GetFilename,'"'); exit; end; try try FileVersion:=XMLConfig.GetValue('MiscellaneousOptions/Version/Value',0); if FileVersion