IDE: resolve macros in project title

git-svn-id: trunk@35044 -
This commit is contained in:
mattias 2012-01-31 00:22:13 +00:00
parent 476ec1506e
commit c9ffd2f60c
12 changed files with 50 additions and 51 deletions

View File

@ -520,11 +520,7 @@ begin
FItems.FreeAndClear;
// caption
s:='';
if AProject.Title<>'' then
s:=AProject.Title
else
s:=ExtractFileNameOnly(AProject.ProjectInfoFile);
s:=AProject.GetDefaultTitle;
Caption:=Format(crsPPUFilesOfProject, [s]);
// ScopeLabel

View File

@ -1123,7 +1123,7 @@ begin
TargetExeName := Project1.CompilerOptions.CreateTargetFilename(
Project1.MainFilename);
if not (CreateApplicationBundle(TargetExeName, Project1.Title, True) in
if not (CreateApplicationBundle(TargetExeName, Project1.GetTitle, True) in
[mrOk, mrIgnore]) then
Exit;
if not (CreateAppBundleSymbolicLink(TargetExeName, True) in [mrOk, mrIgnore]) then

View File

@ -1203,7 +1203,7 @@ begin
AProject:=TLazProject(NewOwner);
BaseDir:=ExtractFilePath(AProject.ProjectInfoFile);
if AProject.FPDocPaths='' then
AProject.FPDocPaths:=SelectNewFPDocPaths(AProject.ShortDescription,BaseDir);
AProject.FPDocPaths:=SelectNewFPDocPaths(AProject.GetTitleOrName,BaseDir);
FPDocPaths:=AProject.FPDocPaths;
FPDocPackageName:=GetFPDocPackageNameByOwner(AProject);
end else if NewOwner is TLazPackage then begin

View File

@ -878,7 +878,7 @@ procedure TDebugManager.DebuggerException(Sender: TObject;
function GetTitle: String;
begin
Result := Project1.Title;
Result := Project1.GetTitle;
if Result = '' then
Result := ExtractFileName(FDebugger.FileName);
end;

View File

@ -473,9 +473,7 @@ function TBuildModesEditorFrame.GetDialogCaption: string;
begin
if AProject<>nil then
begin
Result := aProject.Title;
if Result = '' then
Result := ExtractFilenameOnly(aProject.ProjectInfoFile);
Result := aProject.GetTitleOrName;
Result:=Format(dlgProjectOptionsFor, [Result]);
if AProject.BuildModes.Count>1 then
Result:=Result+', '+copy(AProject.ActiveBuildMode.GetCaption,1,12);

View File

@ -74,7 +74,7 @@ begin
TargetExeName := AProject.CompilerOptions.CreateTargetFilename(
AProject.MainFilename);
if not (CreateApplicationBundle(TargetExeName, AProject.Title, True) in
if not (CreateApplicationBundle(TargetExeName, AProject.GetTitle, True) in
[mrOk, mrIgnore]) then
begin
MessageDlg(lisCCOErrorCaption, Format(
@ -215,7 +215,7 @@ begin
FProject := AOptions as TProject;
with FProject do
begin
TitleEdit.Text := Title;
TitleEdit.Text := Title2;
UseAppBundleCheckBox.Checked := UseAppBundle;
UseXPManifestCheckBox.Checked := TProjectXPManifest(ProjResources[TProjectXPManifest]).UseManifest;
DpiAwareCheckBox.Checked := TProjectXPManifest(ProjResources[TProjectXPManifest]).DpiAware;
@ -235,7 +235,7 @@ var
begin
with AOptions as TProject do
begin
Title := TitleEdit.Text;
Title2 := TitleEdit.Text;
AStream := GetIconAsStream;
try
TProjectIcon(ProjResources[TProjectIcon]).SetStream(AStream);

View File

@ -4994,6 +4994,7 @@ var
function SetTitle: Boolean;
var
OldTitle: String;
NewTitle: String;
begin
Result := True;
if (AProject.MainUnitID < 0) or
@ -5003,8 +5004,9 @@ var
if (OldTitle = '') and AProject.TitleIsDefault then
Exit;
if (OldTitle <> AProject.Title) and (not AProject.TitleIsDefault) then
if not CodeToolBoss.SetApplicationTitleStatement(AProject.MainUnitInfo.Source, AProject.Title) then
NewTitle:=AProject.GetTitle;
if (OldTitle <> NewTitle) and (not AProject.TitleIsDefault) then
if not CodeToolBoss.SetApplicationTitleStatement(AProject.MainUnitInfo.Source, NewTitle) then
begin
MessageDlg(lisProjOptsError,
Format(lisUnableToChangeProjectTitleInSource, [#13, CodeToolBoss.
@ -8189,7 +8191,7 @@ begin
if AFilename='' then
AFilename:=ExtractFileName(Project1.MainFilename);
if AFilename='' then
AFilename:=Trim(Project1.Title);
AFilename:=Trim(Project1.GetTitle);
if AFilename='' then
AFilename:='project1';
Ext := LowerCase(ExtractFileExt(AFilename));
@ -8396,7 +8398,7 @@ begin
// change title
if TitleWasDefault then begin
Project1.Title:=Project1.GetDefaultTitle;
Project1.Title2:=Project1.GetDefaultTitle;
// title does not need to be removed from source, because it was default
end;
@ -11980,7 +11982,7 @@ begin
Project1.ProjResources.DoAfterBuild(AReason, Project1.IsVirtual);
// add success message
MessagesView.AddMsg(Format(lisProjectSuccessfullyBuilt, ['"',
Project1.ShortDescription, '"']),'',-1);
Project1.GetTitleOrName, '"']),'',-1);
CompileProgress.Ready(lisInfoBuildSuccess);
finally
// check sources

View File

@ -899,8 +899,7 @@ type
procedure RestoreBuildModes;
// title
function GetDefaultTitle: string;
function GetTitleOrName: string;
function GetTitle: string; override;
function TitleIsDefault(Fuzzy: boolean = false): boolean;
function IDAsString: string;
function IDAsWord: string;
@ -2572,7 +2571,7 @@ begin
UpdateProjectDirectory;
FPublishOptions:=TPublishProjectOptions.Create(Self);
FRunParameters:=TRunParamsOptions.Create;
Title := '';
Title2 := '';
FUnitList := TFPList.Create; // list of TUnitInfo
FResources := TProjectResources.Create(Self);
@ -2849,7 +2848,7 @@ begin
xmlconfig.SetValue(Path+'General/MainUnit/Value', MainUnitID); // always write a value to support opening by older IDEs (<=0.9.28). This can be changed in a few released.
xmlconfig.SetDeleteValue(Path+'General/AutoCreateForms/Value',
AutoCreateForms,true);
xmlconfig.SetDeleteValue(Path+'General/Title/Value', Title,'');
xmlconfig.SetDeleteValue(Path+'General/Title/Value', Title2,'');
xmlconfig.SetDeleteValue(Path+'General/UseAppBundle/Value', UseAppBundle, True);
// fpdoc
@ -3057,21 +3056,16 @@ begin
ActiveBuildMode:=BuildModes[0];
end;
function TProject.GetDefaultTitle: string;
function TProject.GetTitle: string;
begin
Result:=ExtractFilenameOnly(ProjectInfoFile);
end;
function TProject.GetTitleOrName: string;
begin
Result:=Title;
if Result='' then Result:=GetDefaultTitle;
Result:=Title2;
MacroEngine.SubstituteStr(Result);
end;
function TProject.TitleIsDefault(Fuzzy: boolean): boolean;
begin
Result:=(Title='') or (Title=GetDefaultTitle)
or (Fuzzy and (SysUtils.CompareText(Title,GetDefaultTitle)=0));
Result:=(Title2='') or (Title2=GetDefaultTitle)
or (Fuzzy and (SysUtils.CompareText(Title2,GetDefaultTitle)=0));
end;
function TProject.IDAsString: string;
@ -3421,7 +3415,7 @@ begin
// automatically fixes broken lpi files.
if not LoadParts then begin
NewMainUnitID := xmlconfig.GetValue(Path+'General/MainUnit/Value', 0);
Title := xmlconfig.GetValue(Path+'General/Title/Value', '');
Title2 := xmlconfig.GetValue(Path+'General/Title/Value', '');
UseAppBundle := xmlconfig.GetValue(Path+'General/UseAppBundle/Value', True);
AutoCreateForms := xmlconfig.GetValue(
Path+'General/AutoCreateForms/Value', true);
@ -3758,7 +3752,7 @@ begin
ClearSourceDirectories;
UpdateProjectDirectory;
FPublishOptions.Clear;
Title := '';
Title2 := '';
Modified := false;
SessionModified := false;
@ -4329,10 +4323,8 @@ begin
OldProjectInfoFile:=fProjectInfoFile;
fProjectInfoFile:=NewProjectInfoFile;
DefaultTitle:=ExtractFileNameOnly(OldProjectInfoFile);
if (CompareText(Title,DefaultTitle)=0)
or (OldProjectInfoFile='') or (Title='') then begin
Title:=DefaultTitle;
end;
if TitleIsDefault(true) then
Title2:=DefaultTitle;
UpdateProjectDirectory;
UpdateSessionFilename;
if Assigned(OnChangeProjectInfoFile) then
@ -6107,7 +6099,7 @@ end;
function TProjectCompilerOptions.GetOwnerName: string;
begin
Result:=LazProject.Title;
Result:=LazProject.GetTitleOrName;
if Result='' then Result:=ExtractFilename(LazProject.ProjectInfoFile);
end;

View File

@ -1672,7 +1672,7 @@ begin
If (T<>'') then
begin
AProject.Flags:=AProject.Flags+[pfMainUnitHasTitleStatement];
AProject.Title:=T;
AProject.Title2:=T;
NewSource.Add(' Application.Title:='''+T+''';');
end;
NewSource.Add(' Application.Run;');

View File

@ -861,7 +861,7 @@ begin
if LazProject=nil then
Caption:=lisMenuProjectInspector
else begin
NewCaption:=LazProject.Title;
NewCaption:=LazProject.GetTitle;
if NewCaption='' then
NewCaption:=ExtractFilenameOnly(LazProject.ProjectInfoFile);
Caption:=Format(lisProjInspProjectInspector, [NewCaption]);

View File

@ -424,7 +424,6 @@ type
procedure RemoveUnit(Index: integer; RemoveFromUsesSection: boolean = true); virtual; abstract;
procedure AddSrcPath(const SrcPathAddition: string); virtual; abstract;
procedure AddPackageDependency(const PackageName: string); virtual; abstract;
function ShortDescription: string;
procedure ClearModifieds(ClearUnits: boolean);
function FindFile(const AFilename: string;
SearchFlags: TProjectFileSearchFlags): TLazProjectFile; virtual; abstract;
@ -434,12 +433,16 @@ type
procedure ConvertFromLPIFilename(var AFilename: string); virtual; abstract;
procedure LoadDefaultIcon; virtual;
function GetFPDocPackageName: string;
function GetTitle: string; virtual; abstract; // Title with macros resolved
function GetDefaultTitle: string; // extract name from lpi file name
function GetTitleOrName: string; // GetTitle, if this is '' then GetDefaultTitle
function ShortDescription: string; deprecated; // since 0.9.31, use GetTitleOrName instead
public
property MainFileID: Integer read GetMainFileID write SetMainFileID;
property Files[Index: integer]: TLazProjectFile read GetFiles;
property FileCount: integer read GetFileCount;
property MainFile: TLazProjectFile read GetMainFile;
property Title: String read FTitle write SetTitle;
property Title2: String read FTitle write SetTitle;
property Flags: TProjectFlags read FFlags write SetFlags;
property ExecutableType: TProjectExecutableType read FExecutableType
write SetExecutableType;// read from MainFile, not saved to lpi
@ -1006,7 +1009,7 @@ end;
function TProjectDescriptor.InitProject(AProject: TLazProject): TModalResult;
begin
AProject.Title:='project1';
AProject.Title2:='project1';
AProject.Flags:=Flags;
Result:=mrOk;
end;
@ -1130,10 +1133,7 @@ end;
function TLazProject.ShortDescription: string;
begin
if Title<>'' then
Result:=Title
else
Result:=ExtractFileNameOnly(ProjectInfoFile);
Result:=GetTitleOrName;
end;
procedure TLazProject.ClearModifieds(ClearUnits: boolean);
@ -1160,6 +1160,17 @@ begin
Result:=ExtractFileNameOnly(ProjectInfoFile);
end;
function TLazProject.GetDefaultTitle: string;
begin
Result:=ExtractFileNameOnly(ProjectInfoFile);
end;
function TLazProject.GetTitleOrName: string;
begin
Result:=GetTitle;
if Result='' then Result:=GetDefaultTitle;
end;
{ TLazProjectFile }
procedure TLazProjectFile.SetIsPartOfProject(const AValue: boolean);

View File

@ -2821,7 +2821,7 @@ var
if UnitOwner is TProject then begin
PackageAdditions:=Format(
lisPkgMangAddingNewDependencyForProjectPackage, [PackageAdditions,
TProject(UnitOwner).Title, RequiredPackage.Name, #13#13]);
TProject(UnitOwner).GetTitle, RequiredPackage.Name, #13#13]);
end else if UnitOwner is TLazPackage then begin
PackageAdditions:=Format(
lisPkgMangAddingNewDependencyForPackagePackage, [PackageAdditions,
@ -2858,7 +2858,7 @@ var
RequiredPackage:=TLazPackage(MissingDependencies.Objects[i]);
RequiredPackage:=TLazPackage(RedirectPackageDependency(RequiredPackage));
if UnitOwner is TProject then begin
DebugLn('TPkgManager.AddUnitDependenciesForComponentClasses Adding Project Dependency ',TProject(UnitOwner).Title,' -> ',RequiredPackage.Name);
DebugLn('TPkgManager.AddUnitDependenciesForComponentClasses Adding Project Dependency ',TProject(UnitOwner).GetTitle,' -> ',RequiredPackage.Name);
AddProjectDependency(TProject(UnitOwner),RequiredPackage);
end else if UnitOwner is TLazPackage then begin
DebugLn('TPkgManager.AddUnitDependenciesForComponentClasses Adding Package Dependency ',TLazPackage(UnitOwner).Name,' -> ',RequiredPackage.Name);