mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 23:59:07 +02:00
buildintf: added TProjectFileDescriptor.Initialized, IDE: newfile: set HasResources before calling Initialized
This commit is contained in:
parent
595a4673e4
commit
b9cfb64b7b
@ -123,6 +123,7 @@ type
|
|||||||
procedure UpdateDefaultPascalFileExtension(const DefPasExt: string); virtual;
|
procedure UpdateDefaultPascalFileExtension(const DefPasExt: string); virtual;
|
||||||
function Init(var {%H-}NewFilename: string; {%H-}NewOwner: TObject;
|
function Init(var {%H-}NewFilename: string; {%H-}NewOwner: TObject;
|
||||||
var {%H-}NewSource: string; {%H-}Quiet: boolean): TModalResult; virtual;
|
var {%H-}NewSource: string; {%H-}Quiet: boolean): TModalResult; virtual;
|
||||||
|
function Initialized({%H-}NewFile: TLazProjectFile): TModalResult; virtual; // ready to open in source editor
|
||||||
public
|
public
|
||||||
property Owner: TIDEProjPackBase read FOwner write FOwner; // project, package or nil
|
property Owner: TIDEProjPackBase read FOwner write FOwner; // project, package or nil
|
||||||
property Name: string read FName write SetName;
|
property Name: string read FName write SetName;
|
||||||
@ -1063,6 +1064,12 @@ begin
|
|||||||
Result:=mrOk;
|
Result:=mrOk;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TProjectFileDescriptor.Initialized(NewFile: TLazProjectFile
|
||||||
|
): TModalResult;
|
||||||
|
begin
|
||||||
|
Result:=mrOk;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TFileDescPascalUnit }
|
{ TFileDescPascalUnit }
|
||||||
|
|
||||||
constructor TFileDescPascalUnit.Create;
|
constructor TFileDescPascalUnit.Create;
|
||||||
|
@ -2178,6 +2178,28 @@ begin
|
|||||||
and (pfMainUnitHasUsesSectionForAllUnits in AProject.Flags));
|
and (pfMainUnitHasUsesSectionForAllUnits in AProject.Flags));
|
||||||
end;
|
end;
|
||||||
NewSrcEdit := Nil;
|
NewSrcEdit := Nil;
|
||||||
|
|
||||||
|
// Update HasResources property (if the .lfm file was created separately)
|
||||||
|
if (not NewUnitInfo.HasResources)
|
||||||
|
and FilenameIsPascalUnit(NewUnitInfo.Filename) then begin
|
||||||
|
//debugln('NewFile no HasResources ',NewUnitInfo.Filename);
|
||||||
|
LFMFilename:=ChangeFileExt(NewUnitInfo.Filename,'.lfm');
|
||||||
|
SearchFlags:=[];
|
||||||
|
if NewUnitInfo.IsPartOfProject then
|
||||||
|
Include(SearchFlags,pfsfOnlyProjectFiles);
|
||||||
|
if NewUnitInfo.IsVirtual then
|
||||||
|
Include(SearchFlags,pfsfOnlyVirtualFiles);
|
||||||
|
if (AProject.UnitInfoWithFilename(LFMFilename,SearchFlags)<>nil) then begin
|
||||||
|
//debugln('NewFile no HasResources ',NewUnitInfo.Filename,' ResourceFile exists');
|
||||||
|
NewUnitInfo.HasResources:=true;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
// call hook
|
||||||
|
Result:=NewFileDescriptor.Initialized(NewUnitInfo);
|
||||||
|
if Result<>mrOk then
|
||||||
|
exit(mrCancel);
|
||||||
|
|
||||||
if nfOpenInEditor in NewFlags then begin
|
if nfOpenInEditor in NewFlags then begin
|
||||||
// open a new sourceeditor
|
// open a new sourceeditor
|
||||||
SrcNoteBook := SourceEditorManager.ActiveOrNewSourceWindow;
|
SrcNoteBook := SourceEditorManager.ActiveOrNewSourceWindow;
|
||||||
@ -2271,22 +2293,6 @@ begin
|
|||||||
// do not open in editor
|
// do not open in editor
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// Update HasResources property (if the .lfm file was created separately)
|
|
||||||
if (not NewUnitInfo.HasResources)
|
|
||||||
and FilenameIsPascalUnit(NewUnitInfo.Filename) then begin
|
|
||||||
//debugln('NewFile no HasResources ',NewUnitInfo.Filename);
|
|
||||||
LFMFilename:=ChangeFileExt(NewUnitInfo.Filename,'.lfm');
|
|
||||||
SearchFlags:=[];
|
|
||||||
if NewUnitInfo.IsPartOfProject then
|
|
||||||
Include(SearchFlags,pfsfOnlyProjectFiles);
|
|
||||||
if NewUnitInfo.IsVirtual then
|
|
||||||
Include(SearchFlags,pfsfOnlyVirtualFiles);
|
|
||||||
if (AProject.UnitInfoWithFilename(LFMFilename,SearchFlags)<>nil) then begin
|
|
||||||
//debugln('NewFile no HasResources ',NewUnitInfo.Filename,' ResourceFile exists');
|
|
||||||
NewUnitInfo.HasResources:=true;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
if (nfAskForFilename in NewFlags) then begin
|
if (nfAskForFilename in NewFlags) then begin
|
||||||
// save and ask for filename
|
// save and ask for filename
|
||||||
NewUnitInfo.Modified:=true;
|
NewUnitInfo.Modified:=true;
|
||||||
|
Loading…
Reference in New Issue
Block a user