diff --git a/components/codetools/ide/ppulistdlg.pas b/components/codetools/ide/ppulistdlg.pas index 6a118815b8..7cd762f09a 100644 --- a/components/codetools/ide/ppulistdlg.pas +++ b/components/codetools/ide/ppulistdlg.pas @@ -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 diff --git a/ide/buildmanager.pas b/ide/buildmanager.pas index 4c4bfef4ee..557fd8328c 100644 --- a/ide/buildmanager.pas +++ b/ide/buildmanager.pas @@ -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 diff --git a/ide/codehelp.pas b/ide/codehelp.pas index 00045139ea..533962495b 100644 --- a/ide/codehelp.pas +++ b/ide/codehelp.pas @@ -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 diff --git a/ide/debugmanager.pas b/ide/debugmanager.pas index 8005546ea9..4e134cd3ca 100644 --- a/ide/debugmanager.pas +++ b/ide/debugmanager.pas @@ -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; diff --git a/ide/frames/buildmodeseditor.pas b/ide/frames/buildmodeseditor.pas index 20f65e3219..ff3bb183fb 100644 --- a/ide/frames/buildmodeseditor.pas +++ b/ide/frames/buildmodeseditor.pas @@ -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); diff --git a/ide/frames/project_application_options.pas b/ide/frames/project_application_options.pas index 94967add67..836dd749a1 100644 --- a/ide/frames/project_application_options.pas +++ b/ide/frames/project_application_options.pas @@ -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); diff --git a/ide/main.pp b/ide/main.pp index 7122c2cbde..0d00a29adc 100644 --- a/ide/main.pp +++ b/ide/main.pp @@ -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 diff --git a/ide/project.pp b/ide/project.pp index 8d5b57911c..a8ea28a635 100644 --- a/ide/project.pp +++ b/ide/project.pp @@ -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; diff --git a/ide/projectdefs.pas b/ide/projectdefs.pas index 2898257aba..0ba8b063b7 100644 --- a/ide/projectdefs.pas +++ b/ide/projectdefs.pas @@ -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;'); diff --git a/ide/projectinspector.pas b/ide/projectinspector.pas index a5aac5cb17..c635cac584 100644 --- a/ide/projectinspector.pas +++ b/ide/projectinspector.pas @@ -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]); diff --git a/ideintf/projectintf.pas b/ideintf/projectintf.pas index e27120dae3..573602cf02 100644 --- a/ideintf/projectintf.pas +++ b/ideintf/projectintf.pas @@ -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); diff --git a/packager/pkgmanager.pas b/packager/pkgmanager.pas index b9675d4f2d..0abd43dea3 100644 --- a/packager/pkgmanager.pas +++ b/packager/pkgmanager.pas @@ -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);