mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2026-01-06 12:00:32 +01:00
ide: project resources
- introduce TAbstractProjectResource as a base class for every project resource - move save/load resources code from to TProjectResources class - improve error handling - cleanup git-svn-id: trunk@16936 -
This commit is contained in:
parent
33c096ac18
commit
306d347cbf
@ -95,7 +95,7 @@ uses
|
||||
IDEProtocol,
|
||||
// compile
|
||||
Compiler, CompilerOptions, CompilerOptionsDlg, CheckCompilerOpts,
|
||||
ApplicationBundle, W32VersionInfo, ImExportCompilerOpts, InfoBuild,
|
||||
ApplicationBundle, ImExportCompilerOpts, InfoBuild,
|
||||
// projects
|
||||
Project, ProjectDefs, NewProjectDlg, ProjectOpts,
|
||||
PublishProjectDlg, ProjectInspector, PackageDefs,
|
||||
|
||||
@ -2061,9 +2061,7 @@ begin
|
||||
AutoCreateForms,true);
|
||||
xmlconfig.SetValue(Path+'General/TargetFileExt/Value',TargetFileExt);
|
||||
xmlconfig.SetDeleteValue(Path+'General/Title/Value', Title,'');
|
||||
xmlconfig.SetDeleteValue(Path+'General/Icon/Value', Resources.ProjectIcon.IconText, '');
|
||||
xmlconfig.SetDeleteValue(Path+'General/UseAppBundle/Value', UseAppBundle, True);
|
||||
xmlconfig.SetDeleteValue(Path+'General/UseXPManifest/Value', Resources.XPManifest.UseManifest, False);
|
||||
|
||||
// lazdoc
|
||||
xmlconfig.SetDeleteValue(Path+'LazDoc/Paths',
|
||||
@ -2074,27 +2072,8 @@ begin
|
||||
xmlconfig.SetDeleteValue(Path+'i18n/OutDir/Value',
|
||||
CreateRelativePath(POOutputDirectory,ProjectDirectory) , '');
|
||||
|
||||
// VersionInfo
|
||||
with Resources do
|
||||
begin
|
||||
xmlconfig.SetDeleteValue(Path+'VersionInfo/UseVersionInfo/Value', VersionInfo.UseVersionInfo,false);
|
||||
xmlconfig.SetDeleteValue(Path+'VersionInfo/AutoIncrementBuild/Value', VersionInfo.AutoIncrementBuild,false);
|
||||
xmlconfig.SetDeleteValue(Path+'VersionInfo/CurrentVersionNr/Value', VersionInfo.VersionNr,0);
|
||||
xmlconfig.SetDeleteValue(Path+'VersionInfo/CurrentMajorRevNr/Value', VersionInfo.MajorRevNr,0);
|
||||
xmlconfig.SetDeleteValue(Path+'VersionInfo/CurrentMinorRevNr/Value', VersionInfo.MinorRevNr,0);
|
||||
xmlconfig.SetDeleteValue(Path+'VersionInfo/CurrentBuildNr/Value', VersionInfo.BuildNr,0);
|
||||
xmlconfig.SetDeleteValue(Path+'VersionInfo/ProjectVersion/Value', VersionInfo.ProductVersionString,'1.0.0.0');
|
||||
xmlconfig.SetDeleteValue(Path+'VersionInfo/Language/Value', VersionInfo.HexLang,'0409');
|
||||
xmlconfig.SetDeleteValue(Path+'VersionInfo/CharSet/Value', VersionInfo.HexCharSet,'04E4');
|
||||
xmlconfig.SetDeleteValue(Path+'VersionInfo/Comments/Value', VersionInfo.CommentsString,'');
|
||||
xmlconfig.SetDeleteValue(Path+'VersionInfo/CompanyName/Value', VersionInfo.CompanyString,'');
|
||||
xmlconfig.SetDeleteValue(Path+'VersionInfo/FileDescription/Value', VersionInfo.DescriptionString,'');
|
||||
xmlconfig.SetDeleteValue(Path+'VersionInfo/InternalName/Value', VersionInfo.InternalNameString,'');
|
||||
xmlconfig.SetDeleteValue(Path+'VersionInfo/LegalCopyright/Value', VersionInfo.CopyrightString,'');
|
||||
xmlconfig.SetDeleteValue(Path+'VersionInfo/LegalTrademarks/Value', VersionInfo.TrademarksString,'');
|
||||
xmlconfig.SetDeleteValue(Path+'VersionInfo/OriginalFilename/Value', VersionInfo.OriginalFilenameString,'');
|
||||
xmlconfig.SetDeleteValue(Path+'VersionInfo/ProductName/Value', VersionInfo.ProdNameString,'');
|
||||
end;
|
||||
// Resources
|
||||
Resources.WriteToProjectFile(xmlconfig, Path);
|
||||
|
||||
// save custom data
|
||||
SaveStringToStringTree(xmlconfig,CustomData,Path+'CustomData/');
|
||||
@ -2465,9 +2444,7 @@ begin
|
||||
TargetFileExt := xmlconfig.GetValue(
|
||||
Path+'General/TargetFileExt/Value', GetExecutableExt);
|
||||
Title := xmlconfig.GetValue(Path+'General/Title/Value', '');
|
||||
Resources.ProjectIcon.IconText := xmlconfig.GetValue(Path+'General/Icon/Value', '');
|
||||
UseAppBundle := xmlconfig.GetValue(Path+'General/UseAppBundle/Value', True);
|
||||
Resources.XPManifest.UseManifest := xmlconfig.GetValue(Path+'General/UseXPManifest/Value', False);
|
||||
|
||||
// Lazdoc
|
||||
LazDocPaths := SwitchPathDelims(xmlconfig.GetValue(Path+'LazDoc/Paths', ''),
|
||||
@ -2488,27 +2465,8 @@ begin
|
||||
// Load the compiler options
|
||||
LoadCompilerOptions(XMLConfig,Path);
|
||||
|
||||
// VersionInfo
|
||||
with Resources do
|
||||
begin
|
||||
VersionInfo.UseVersionInfo := xmlconfig.GetValue(Path+'VersionInfo/UseVersionInfo/Value', False);
|
||||
VersionInfo.AutoIncrementBuild := xmlconfig.GetValue(Path+'VersionInfo/AutoIncrementBuild/Value', False);
|
||||
VersionInfo.VersionNr := xmlconfig.GetValue(Path+'VersionInfo/CurrentVersionNr/Value', 0);
|
||||
VersionInfo.MajorRevNr := xmlconfig.GetValue(Path+'VersionInfo/CurrentMajorRevNr/Value', 0);
|
||||
VersionInfo.MinorRevNr := xmlconfig.GetValue(Path+'VersionInfo/CurrentMinorRevNr/Value', 0);
|
||||
VersionInfo.BuildNr := xmlconfig.GetValue(Path+'VersionInfo/CurrentBuildNr/Value', 0);
|
||||
VersionInfo.ProductVersionString := xmlconfig.GetValue(Path+'VersionInfo/ProjectVersion/Value', '1.0.0.0');
|
||||
VersionInfo.HexLang := xmlconfig.GetValue(Path+'VersionInfo/Language/Value', '0409');
|
||||
VersionInfo.HexCharSet := xmlconfig.GetValue(Path+'VersionInfo/CharSet/Value', '04E4');
|
||||
VersionInfo.CommentsString := LineBreaksToSystemLineBreaks(xmlconfig.GetValue(Path+'VersionInfo/Comments/Value', ''));
|
||||
VersionInfo.CompanyString := LineBreaksToSystemLineBreaks(xmlconfig.GetValue(Path+'VersionInfo/CompanyName/Value', ''));
|
||||
VersionInfo.DescriptionString := LineBreaksToSystemLineBreaks(xmlconfig.GetValue(Path+'VersionInfo/FileDescription/Value', ''));
|
||||
VersionInfo.InternalNameString := LineBreaksToSystemLineBreaks(xmlconfig.GetValue(Path+'VersionInfo/InternalName/Value', ''));
|
||||
VersionInfo.CopyrightString := LineBreaksToSystemLineBreaks(xmlconfig.GetValue(Path+'VersionInfo/LegalCopyright/Value', ''));
|
||||
VersionInfo.TrademarksString := LineBreaksToSystemLineBreaks(xmlconfig.GetValue(Path+'VersionInfo/LegalTrademarks/Value', ''));
|
||||
VersionInfo.OriginalFilenameString := xmlconfig.GetValue(Path+'VersionInfo/OriginalFilename/Value', '');
|
||||
VersionInfo.ProdNameString := LineBreaksToSystemLineBreaks(xmlconfig.GetValue(Path+'VersionInfo/ProductName/Value', ''));
|
||||
end;
|
||||
// Resources
|
||||
Resources.ReadFromProjectFile(xmlconfig, Path);
|
||||
|
||||
// load custom data
|
||||
LoadStringToStringTree(xmlconfig,CustomData,Path+'CustomData/');
|
||||
|
||||
@ -41,30 +41,24 @@ uses
|
||||
type
|
||||
{ TProjectIcon }
|
||||
|
||||
TProjectIcon = class(TObject)
|
||||
TProjectIcon = class(TAbstractProjectResource)
|
||||
private
|
||||
FIconText: String;
|
||||
FModified: boolean;
|
||||
icoFileName: string;
|
||||
FOnModified: TNotifyEvent;
|
||||
procedure SetIconText(const AValue: String);
|
||||
procedure SetFileNames(const MainFilename: string);
|
||||
procedure SetModified(const AValue: Boolean);
|
||||
protected
|
||||
function GetAsHex: String;
|
||||
public
|
||||
constructor Create;
|
||||
constructor Create; override;
|
||||
|
||||
function GetStream: TStream;
|
||||
procedure SetStream(AStream: TStream);
|
||||
|
||||
function UpdateResources(AResources: TAbstractProjectResources; const MainFilename: string): Boolean;
|
||||
function UpdateResources(AResources: TAbstractProjectResources; const MainFilename: string): Boolean; override;
|
||||
function CreateIconFile: Boolean;
|
||||
|
||||
property IconText: String read FIconText write SetIconText;
|
||||
property Modified: boolean read FModified write SetModified;
|
||||
|
||||
property OnModified: TNotifyEvent read FOnModified write FOnModified;
|
||||
end;
|
||||
|
||||
implementation
|
||||
@ -176,6 +170,8 @@ var
|
||||
DefaultRes: TLResource;
|
||||
ResStream: TLazarusResourceStream;
|
||||
begin
|
||||
inherited Create;
|
||||
|
||||
FIconText := '';
|
||||
|
||||
// Load default icon
|
||||
@ -195,15 +191,6 @@ begin
|
||||
Modified := True;
|
||||
end;
|
||||
|
||||
procedure TProjectIcon.SetModified(const AValue: Boolean);
|
||||
begin
|
||||
if FModified = AValue then
|
||||
Exit;
|
||||
FModified := AValue;
|
||||
if Assigned(OnModified) then
|
||||
OnModified(Self);
|
||||
end;
|
||||
|
||||
function TProjectIcon.GetAsHex: String;
|
||||
var
|
||||
AStream: TStream;
|
||||
|
||||
@ -560,8 +560,11 @@ begin
|
||||
Project.Resources.VersionInfo.HexLang:=MSLanguageToHex(LanguageSelectionComboBox.Text);
|
||||
Project.Resources.VersionInfo.HexCharSet:=MSCharacterSetToHex(CharacterSetComboBox.Text);
|
||||
//debugln(['TProjectOptionsDialog.ProjectOptionsClose Project.Resources.Modified=',Project.Resources.Modified]);
|
||||
if Project.Resources.Modified and (Project.MainUnitID>=0) then
|
||||
Project.Resources.UpdateMainSourceFile(Project.MainFilename);
|
||||
if Project.Resources.Modified and (Project.MainUnitID >= 0) then
|
||||
begin
|
||||
if not Project.Resources.UpdateMainSourceFile(Project.MainFilename) then
|
||||
MessageDlg(Project.Resources.Messages.Text, mtWarning, [mbOk], 0);
|
||||
end;
|
||||
end;
|
||||
|
||||
IDEDialogLayoutList.SaveLayout(Self);
|
||||
|
||||
@ -37,9 +37,9 @@ unit ProjectResources;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, LCLProc, LResources, FileUtil,
|
||||
Classes, SysUtils, LCLProc, LResources, FileUtil, Laz_XMLCfg,
|
||||
ProjectResourcesIntf,
|
||||
W32VersionInfo, W32Manifest, ProjectIcon,
|
||||
W32VersionInfo, W32Manifest, ProjectIcon, IDEProcs,
|
||||
BasicCodeTools, CodeToolManager, CodeCache, CodeAtom;
|
||||
|
||||
type
|
||||
@ -67,7 +67,7 @@ type
|
||||
function Update: Boolean;
|
||||
procedure EmbeddedObjectModified(Sender: TObject);
|
||||
public
|
||||
constructor Create;
|
||||
constructor Create; override;
|
||||
destructor Destroy; override;
|
||||
|
||||
procedure AddSystemResource(const AResource: String); override;
|
||||
@ -80,6 +80,9 @@ type
|
||||
function HasSystemResources: Boolean;
|
||||
function HasLazarusResource: Boolean;
|
||||
|
||||
procedure WriteToProjectFile(AConfig: TXMLConfig; Path: String);
|
||||
procedure ReadFromProjectFile(AConfig: TXMLConfig; Path: String);
|
||||
|
||||
property VersionInfo: TProjectVersionInfo read FVersionInfo;
|
||||
property XPManifest: TProjectXPManifest read FXPManifest;
|
||||
property ProjectIcon: TProjectIcon read FProjectIcon;
|
||||
@ -149,6 +152,8 @@ end;
|
||||
|
||||
constructor TProjectResources.Create;
|
||||
begin
|
||||
inherited Create;
|
||||
|
||||
FInModified := False;
|
||||
|
||||
FSystemResources := TStringList.Create;
|
||||
@ -173,6 +178,7 @@ begin
|
||||
|
||||
FSystemResources.Free;
|
||||
FLazarusResources.Free;
|
||||
FMessages.Free;
|
||||
end;
|
||||
|
||||
procedure TProjectResources.AddSystemResource(const AResource: String);
|
||||
@ -195,6 +201,7 @@ procedure TProjectResources.Clear;
|
||||
begin
|
||||
FSystemResources.Clear;
|
||||
FLazarusResources.Clear;
|
||||
FMessages.Clear;
|
||||
end;
|
||||
|
||||
function TProjectResources.Regenerate(const AWorkingDir, MainFileName: String): Boolean;
|
||||
@ -239,13 +246,67 @@ begin
|
||||
Result := FLazarusResources.Count > 0;
|
||||
end;
|
||||
|
||||
procedure TProjectResources.WriteToProjectFile(AConfig: TXMLConfig; Path: String);
|
||||
begin
|
||||
// todo: further split by classes
|
||||
with AConfig do
|
||||
begin
|
||||
SetDeleteValue(Path+'General/Icon/Value', ProjectIcon.IconText, '');
|
||||
SetDeleteValue(Path+'General/UseXPManifest/Value', XPManifest.UseManifest, False);
|
||||
SetDeleteValue(Path+'VersionInfo/UseVersionInfo/Value', VersionInfo.UseVersionInfo,false);
|
||||
SetDeleteValue(Path+'VersionInfo/AutoIncrementBuild/Value', VersionInfo.AutoIncrementBuild,false);
|
||||
SetDeleteValue(Path+'VersionInfo/CurrentVersionNr/Value', VersionInfo.VersionNr,0);
|
||||
SetDeleteValue(Path+'VersionInfo/CurrentMajorRevNr/Value', VersionInfo.MajorRevNr,0);
|
||||
SetDeleteValue(Path+'VersionInfo/CurrentMinorRevNr/Value', VersionInfo.MinorRevNr,0);
|
||||
SetDeleteValue(Path+'VersionInfo/CurrentBuildNr/Value', VersionInfo.BuildNr,0);
|
||||
SetDeleteValue(Path+'VersionInfo/ProjectVersion/Value', VersionInfo.ProductVersionString,'1.0.0.0');
|
||||
SetDeleteValue(Path+'VersionInfo/Language/Value', VersionInfo.HexLang,'0409');
|
||||
SetDeleteValue(Path+'VersionInfo/CharSet/Value', VersionInfo.HexCharSet,'04E4');
|
||||
SetDeleteValue(Path+'VersionInfo/Comments/Value', VersionInfo.CommentsString,'');
|
||||
SetDeleteValue(Path+'VersionInfo/CompanyName/Value', VersionInfo.CompanyString,'');
|
||||
SetDeleteValue(Path+'VersionInfo/FileDescription/Value', VersionInfo.DescriptionString,'');
|
||||
SetDeleteValue(Path+'VersionInfo/InternalName/Value', VersionInfo.InternalNameString,'');
|
||||
SetDeleteValue(Path+'VersionInfo/LegalCopyright/Value', VersionInfo.CopyrightString,'');
|
||||
SetDeleteValue(Path+'VersionInfo/LegalTrademarks/Value', VersionInfo.TrademarksString,'');
|
||||
SetDeleteValue(Path+'VersionInfo/OriginalFilename/Value', VersionInfo.OriginalFilenameString,'');
|
||||
SetDeleteValue(Path+'VersionInfo/ProductName/Value', VersionInfo.ProdNameString,'');
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TProjectResources.ReadFromProjectFile(AConfig: TXMLConfig; Path: String);
|
||||
begin
|
||||
// todo: further split by classes
|
||||
with AConfig do
|
||||
begin
|
||||
ProjectIcon.IconText := GetValue(Path+'General/Icon/Value', '');
|
||||
XPManifest.UseManifest := GetValue(Path+'General/UseXPManifest/Value', False);
|
||||
VersionInfo.UseVersionInfo := GetValue(Path+'VersionInfo/UseVersionInfo/Value', False);
|
||||
VersionInfo.AutoIncrementBuild := GetValue(Path+'VersionInfo/AutoIncrementBuild/Value', False);
|
||||
VersionInfo.VersionNr := GetValue(Path+'VersionInfo/CurrentVersionNr/Value', 0);
|
||||
VersionInfo.MajorRevNr := GetValue(Path+'VersionInfo/CurrentMajorRevNr/Value', 0);
|
||||
VersionInfo.MinorRevNr := GetValue(Path+'VersionInfo/CurrentMinorRevNr/Value', 0);
|
||||
VersionInfo.BuildNr := GetValue(Path+'VersionInfo/CurrentBuildNr/Value', 0);
|
||||
VersionInfo.ProductVersionString := GetValue(Path+'VersionInfo/ProjectVersion/Value', '1.0.0.0');
|
||||
VersionInfo.HexLang := GetValue(Path+'VersionInfo/Language/Value', '0409');
|
||||
VersionInfo.HexCharSet := GetValue(Path+'VersionInfo/CharSet/Value', '04E4');
|
||||
VersionInfo.CommentsString := LineBreaksToSystemLineBreaks(GetValue(Path+'VersionInfo/Comments/Value', ''));
|
||||
VersionInfo.CompanyString := LineBreaksToSystemLineBreaks(GetValue(Path+'VersionInfo/CompanyName/Value', ''));
|
||||
VersionInfo.DescriptionString := LineBreaksToSystemLineBreaks(GetValue(Path+'VersionInfo/FileDescription/Value', ''));
|
||||
VersionInfo.InternalNameString := LineBreaksToSystemLineBreaks(GetValue(Path+'VersionInfo/InternalName/Value', ''));
|
||||
VersionInfo.CopyrightString := LineBreaksToSystemLineBreaks(GetValue(Path+'VersionInfo/LegalCopyright/Value', ''));
|
||||
VersionInfo.TrademarksString := LineBreaksToSystemLineBreaks(GetValue(Path+'VersionInfo/LegalTrademarks/Value', ''));
|
||||
VersionInfo.OriginalFilenameString := GetValue(Path+'VersionInfo/OriginalFilename/Value', '');
|
||||
VersionInfo.ProdNameString := LineBreaksToSystemLineBreaks(GetValue(Path+'VersionInfo/ProductName/Value', ''));
|
||||
end;
|
||||
end;
|
||||
|
||||
function TProjectResources.UpdateMainSourceFile(const AFilename: string): Boolean;
|
||||
var
|
||||
NewX, NewY, NewTopLine: integer;
|
||||
CodeBuf, NewCode: TCodeBuffer;
|
||||
Filename: String;
|
||||
begin
|
||||
Result := False;
|
||||
Result := True;
|
||||
if not Update then
|
||||
Exit;
|
||||
CodeBuf := CodeToolBoss.LoadFile(AFilename, False, False);
|
||||
@ -265,8 +326,9 @@ begin
|
||||
begin
|
||||
if not CodeToolBoss.RemoveDirective(NewCode, NewX,NewY,true) then
|
||||
begin
|
||||
Result := False;
|
||||
Messages.Add('Could not remove "{$R'+ Filename +'"} from main source!');
|
||||
debugln(['TProjectResources.UpdateMainSourceFile failed: removing resource directive']);
|
||||
// Messages.Add('Could not remove "{$R'+ Filename +'"} from main source!');
|
||||
end;
|
||||
end;
|
||||
end
|
||||
@ -276,8 +338,9 @@ begin
|
||||
if not CodeToolBoss.AddResourceDirective(CodeBuf,
|
||||
Filename,false,'{$IFDEF WINDOWS}{$R '+Filename+'}{$ENDIF}') then
|
||||
begin
|
||||
Result := False;
|
||||
Messages.Add('Could not add "{$R '+ Filename +'"} to main source!');
|
||||
debugln(['TProjectResources.UpdateMainSourceFile failed: adding resource directive']);
|
||||
// Messages.Add('Could not add "{$R '+ Filename +'"} to main source!');
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -293,8 +356,9 @@ begin
|
||||
begin
|
||||
if not CodeToolBoss.RemoveDirective(NewCode, NewX,NewY,true) then
|
||||
begin
|
||||
Result := False;
|
||||
Messages.Add('Could not remove "{$I '+ Filename +'"} from main source!');
|
||||
debugln(['TProjectResources.UpdateMainSourceFile removing include directive from main source failed']);
|
||||
// Messages.Add('Could not remove "{$I '+ Filename +'"} from main source!');
|
||||
Exit;
|
||||
end;
|
||||
end;
|
||||
@ -306,13 +370,13 @@ begin
|
||||
if not CodeToolBoss.AddIncludeDirective(CodeBuf,
|
||||
Filename,'{$I '+Filename+'}') then
|
||||
begin
|
||||
Result := False;
|
||||
Messages.Add('Could not add "{$I'+ Filename +'"} to main source!');
|
||||
debugln(['TProjectResources.UpdateMainSourceFile adding include directive to main source failed']);
|
||||
// Messages.Add('Could not add "{$I'+ Filename +'"} to main source!');
|
||||
Exit;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
@ -40,20 +40,14 @@ uses
|
||||
type
|
||||
{ TProjectXPManifest }
|
||||
|
||||
TProjectXPManifest = class(TObject)
|
||||
TProjectXPManifest = class(TAbstractProjectResource)
|
||||
private
|
||||
FModified: boolean;
|
||||
FUseManifest: boolean;
|
||||
FOnModified: TNotifyEvent;
|
||||
procedure SetUseManifest(const AValue: boolean);
|
||||
procedure SetModified(const AValue: Boolean);
|
||||
public
|
||||
function UpdateResources(AResources: TAbstractProjectResources; const MainFilename: string): Boolean;
|
||||
function UpdateResources(AResources: TAbstractProjectResources; const MainFilename: string): Boolean; override;
|
||||
|
||||
property UseManifest: boolean read FUseManifest write SetUseManifest;
|
||||
property Modified: boolean read FModified write SetModified;
|
||||
|
||||
property OnModified: TNotifyEvent read FOnModified write FOnModified;
|
||||
end;
|
||||
|
||||
implementation
|
||||
@ -100,14 +94,5 @@ begin
|
||||
AResources.AddSystemResource(sManifest);
|
||||
end;
|
||||
|
||||
procedure TProjectXPManifest.SetModified(const AValue: Boolean);
|
||||
begin
|
||||
if FModified = AValue then
|
||||
Exit;
|
||||
FModified := AValue;
|
||||
if Assigned(OnModified) then
|
||||
OnModified(Self);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
||||
@ -38,12 +38,12 @@ interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, Process, LCLProc, Controls, Forms, FileUtil,
|
||||
CodeToolManager, CodeCache, LazConf, projectresourcesintf;
|
||||
CodeToolManager, CodeCache, LazConf, ProjectResourcesIntf;
|
||||
|
||||
type
|
||||
{ TProjectVersionInfo }
|
||||
|
||||
TProjectVersionInfo = class(TObject)
|
||||
TProjectVersionInfo = class(TAbstractProjectResource)
|
||||
private
|
||||
FAutoIncrementBuild: boolean;
|
||||
FBuildNr: integer;
|
||||
@ -56,8 +56,6 @@ type
|
||||
FInternalNameString: string;
|
||||
FMajorRevNr: integer;
|
||||
FMinorRevNr: integer;
|
||||
FModified: boolean;
|
||||
FOnModified: TNotifyEvent;
|
||||
FOriginalFilenameString: string;
|
||||
FProdNameString: string;
|
||||
FProductVersionString: string;
|
||||
@ -79,7 +77,6 @@ type
|
||||
procedure SetInternalNameString(const AValue: string);
|
||||
procedure SetMajorRevNr(const AValue: integer);
|
||||
procedure SetMinorRevNr(const AValue: integer);
|
||||
procedure SetModified(const AValue: boolean);
|
||||
procedure SetOriginalFilenameString(const AValue: string);
|
||||
procedure SetProdNameString(const AValue: string);
|
||||
procedure SetProductVersionString(const AValue: string);
|
||||
@ -87,9 +84,7 @@ type
|
||||
procedure SetUseVersionInfo(const AValue: boolean);
|
||||
procedure SetVersionNr(const AValue: integer);
|
||||
public
|
||||
function UpdateResources(AResources: TAbstractProjectResources; const MainFilename: string): Boolean;
|
||||
|
||||
property Modified: boolean read FModified write SetModified;
|
||||
function UpdateResources(AResources: TAbstractProjectResources; const MainFilename: string): Boolean; override;
|
||||
|
||||
property UseVersionInfo: boolean read FUseVersionInfo write SetUseVersionInfo;
|
||||
property AutoIncrementBuild: boolean read FAutoIncrementBuild write SetAutoIncrementBuild;
|
||||
@ -108,8 +103,6 @@ type
|
||||
property OriginalFilenameString: string read FOriginalFilenameString write SetOriginalFilenameString;
|
||||
property ProdNameString: string read FProdNameString write SetProdNameString;
|
||||
property ProductVersionString: string read FProductVersionString write SetProductVersionString;
|
||||
|
||||
property OnModified: TNotifyEvent read FOnModified write FOnModified;
|
||||
end;
|
||||
|
||||
function MSLanguageToHex(const s: string): string;
|
||||
@ -473,13 +466,6 @@ begin
|
||||
Modified:=true;
|
||||
end;
|
||||
|
||||
procedure TProjectVersionInfo.SetModified(const AValue: boolean);
|
||||
begin
|
||||
if FModified=AValue then exit;
|
||||
FModified:=AValue;
|
||||
if Assigned(OnModified) then OnModified(Self);
|
||||
end;
|
||||
|
||||
procedure TProjectVersionInfo.SetOriginalFilenameString(const AValue: string);
|
||||
begin
|
||||
if FOriginalFilenameString=AValue then exit;
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
{ Copyright (C) 2004
|
||||
|
||||
{
|
||||
*****************************************************************************
|
||||
* *
|
||||
* See the file COPYING.modifiedLGPL.txt, included in this distribution, *
|
||||
@ -21,15 +20,64 @@ uses
|
||||
Classes, SysUtils;
|
||||
|
||||
type
|
||||
TAbstractProjectResources = class;
|
||||
|
||||
{ TAbstractProjectResource }
|
||||
TAbstractProjectResource = class
|
||||
protected
|
||||
FModified: boolean;
|
||||
FOnModified: TNotifyEvent;
|
||||
procedure SetModified(const AValue: boolean);
|
||||
public
|
||||
function UpdateResources(AResources: TAbstractProjectResources; const MainFilename: string): Boolean; virtual; abstract;
|
||||
|
||||
constructor Create; virtual;
|
||||
property Modified: boolean read FModified write SetModified;
|
||||
property OnModified: TNotifyEvent read FOnModified write FOnModified;
|
||||
end;
|
||||
|
||||
{ TAbstractProjectResources }
|
||||
|
||||
TAbstractProjectResources = class
|
||||
protected
|
||||
FMessages: TStringList;
|
||||
public
|
||||
constructor Create; virtual;
|
||||
destructor Destroy; override;
|
||||
|
||||
procedure AddSystemResource(const AResource: String); virtual; abstract;
|
||||
procedure AddLazarusResource(AResource: TStream; const ResourceName, ResourceType: String); virtual; abstract;
|
||||
|
||||
property Messages: TStringList read FMessages;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
{ TAbstractProjectResource }
|
||||
|
||||
procedure TAbstractProjectResource.SetModified(const AValue: boolean);
|
||||
begin
|
||||
if FModified=AValue then exit;
|
||||
FModified:=AValue;
|
||||
if Assigned(OnModified) then OnModified(Self);
|
||||
end;
|
||||
|
||||
constructor TAbstractProjectResource.Create;
|
||||
begin
|
||||
FModified := False;
|
||||
end;
|
||||
|
||||
{ TAbstractProjectResources }
|
||||
|
||||
constructor TAbstractProjectResources.Create;
|
||||
begin
|
||||
FMessages := TStringList.Create;
|
||||
end;
|
||||
|
||||
destructor TAbstractProjectResources.Destroy;
|
||||
begin
|
||||
FMessages.Free;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user