diff --git a/ide/buildmanager.pas b/ide/buildmanager.pas index caed447da4..b019ee0a63 100644 --- a/ide/buildmanager.pas +++ b/ide/buildmanager.pas @@ -376,7 +376,7 @@ end; constructor TBuildManager.Create(AOwner: TComponent); begin - EnvironmentOptions := TEnvironmentOptions.Create(Application.ExeName); + EnvironmentOptions := TEnvironmentOptions.Create; IDEEnvironmentOptions := EnvironmentOptions; EnvironmentOptions.IsGlobalMode:=@EnvironmentOptionsIsGlobalMode; diff --git a/ide/frames/desktop_options.pas b/ide/frames/desktop_options.pas index 8938a99ae0..78c356af0e 100644 --- a/ide/frames/desktop_options.pas +++ b/ide/frames/desktop_options.pas @@ -286,7 +286,7 @@ begin AFilename:=SaveDialog.Filename; if ExtractFileExt(AFilename)='' then AFilename:=AFilename+'.lds'; - AnEnvironmentOptions := TEnvironmentOptions.Create(Application.ExeName); + AnEnvironmentOptions := TEnvironmentOptions.Create; try AnEnvironmentOptions.Filename := AFilename; DoSaveSettings(AnEnvironmentOptions); @@ -323,7 +323,7 @@ begin +'|'+dlgFilterAll+' ('+GetAllFilesMask+')|' + GetAllFilesMask; if OpenDialog.Execute then begin - AnEnvironmentOptions := TEnvironmentOptions.Create(Application.ExeName); + AnEnvironmentOptions := TEnvironmentOptions.Create; try AnEnvironmentOptions.Filename := OpenDialog.Filename; AnEnvironmentOptions.Load(true); diff --git a/ide/lazarus.lpi b/ide/lazarus.lpi index d7b0d5a5a1..0df46ec03b 100644 --- a/ide/lazarus.lpi +++ b/ide/lazarus.lpi @@ -1219,6 +1219,7 @@ + diff --git a/ide/main.pp b/ide/main.pp index 7227108a37..5c074fe090 100644 --- a/ide/main.pp +++ b/ide/main.pp @@ -1248,8 +1248,9 @@ begin CreateConfig; Load(false); end; + AddDefaultRecentProjects; // Add some initial recent projects. - // read language and lazarusdir paramters, needed for translation + // read language and lazarusdir parameters, needed for translation if Application.HasOption('language') then begin debugln('Hint: (lazarus) [TMainIDE.LoadGlobalOptions] overriding language with command line: ', diff --git a/ide/packages/ideconfig/environmentopts.pp b/ide/packages/ideconfig/environmentopts.pp index d8e9db8f26..2b0112d8c1 100644 --- a/ide/packages/ideconfig/environmentopts.pp +++ b/ide/packages/ideconfig/environmentopts.pp @@ -247,7 +247,6 @@ type TEnvironmentOptions = class(TIDEEnvironmentOptions) private - FExePath: string; // ExtractFilePath(Application.ExeName) FFppkgCheck: boolean; fRegisteredSubConfig: TObjectList; // config file @@ -307,7 +306,7 @@ type FNewProjectTemplateAtStart: string; FMultipleInstances: TIDEMultipleInstancesOption; // Prevent repopulating Recent project files menu with example projects if it was already cleared up. - FAlreadyPopulatedRecentFiles : Boolean; + FAlreadyPopulatedRecentFiles: Boolean; //other recent settings FLastEventMethodCCResult: TCodeCreationDlgResult; FLastVariableCCResult: TCodeCreationDlgResult; @@ -371,7 +370,7 @@ type function SubConfigCount: integer; property SubConfig[Index: Integer]: TIDESubOptions read GetSubConfig; public - constructor Create(AExeName: string); + constructor Create; destructor Destroy; override; procedure Load(OnlyDesktop: boolean); procedure Save(OnlyDesktop: boolean); @@ -477,8 +476,8 @@ type write FNewProjectTemplateAtStart; property MultipleInstances: TIDEMultipleInstancesOption read FMultipleInstances write FMultipleInstances; - property FileDialogFilter: string read FFileDialogFilter write FFileDialogFilter; - + property AlreadyPopulatedRecentFiles: Boolean read FAlreadyPopulatedRecentFiles + write FAlreadyPopulatedRecentFiles; // other recent settings property LastEventMethodCCResult: TCodeCreationDlgResult read FLastEventMethodCCResult write FLastEventMethodCCResult; @@ -516,8 +515,9 @@ type // comboboxes property DropDownCount: Integer read FDropDownCount write FDropDownCount; // default template for each 'new item' category: Name=Path, Value=TemplateName - property NewUnitTemplate: string read FNewUnitTemplate write FNewUnitTemplate; property NewFormTemplate: string read FNewFormTemplate write FNewFormTemplate; + property NewUnitTemplate: string read FNewUnitTemplate write FNewUnitTemplate; + property FileDialogFilter: string read FFileDialogFilter write FFileDialogFilter; end; var @@ -658,12 +658,11 @@ end; { TEnvironmentOptions } -constructor TEnvironmentOptions.Create(AExeName: string); +constructor TEnvironmentOptions.Create; var o: TEnvOptParseType; begin inherited Create; - FExePath := ExtractFilePath(AExeName); fRegisteredSubConfig := TObjectList.Create(False); for o:=low(FParseValues) to high(FParseValues) do FParseValues[o].ParseStamp:=CTInvalidChangeStamp; @@ -943,18 +942,6 @@ end; procedure TEnvironmentOptions.Load(OnlyDesktop: boolean); - procedure AddRecentProjectInitial(aProjPath, aProjFile: string); - // Add a project to the list of recent projects if the project has write access. - // The check can be removed when the IDE allows compiling read-only projects. - var - WholeFilePath: String; - begin - aProjPath:=SwitchPathDelims(aProjPath, True); - WholeFilePath:=FExePath + aProjPath + aProjFile; - if FileIsWritable(aProjPath) and FileIsWritable(WholeFilePath) then - AddToRecentList(WholeFilePath,FRecentProjectFiles,FMaxRecentProjectFiles,rltFile); - end; - procedure LoadPascalFileExt(const Path: string); begin fPascalFileExtension:=PascalExtToType(FXMLCfg.GetValue( @@ -971,7 +958,7 @@ procedure TEnvironmentOptions.Load(OnlyDesktop: boolean); CCResult.Location:=CreateCodeLocationNameToLocation(FXMLCfg.GetValue( Path+'/Location',CreateCodeLocationNames[cclLocal])); end; - + var Path, CurPath: String; i: Integer; @@ -1052,16 +1039,6 @@ begin FUseUnitDlgOptions.AllUnits:=FXMLCfg.GetValue(Path+'Recent/UseUnitDlg/AllUnits',False); FUseUnitDlgOptions.AddToImplementation:=FXMLCfg.GetValue(Path+'Recent/UseUnitDlg/AddToImplementation',False); - // Add example projects to an empty project list if examples have write access - if (FRecentProjectFiles.count=0) and (not FAlreadyPopulatedRecentFiles) then begin - AddRecentProjectInitial('examples/jpeg/', 'jpegexample.lpi'); - AddRecentProjectInitial('examples/sprites/', 'spriteexample.lpi'); - AddRecentProjectInitial('examples/openglcontrol/', 'openglcontrol_demo.lpi'); - AddRecentProjectInitial('examples/imagelist/', 'project1.lpi'); - AddRecentProjectInitial('examples/', 'hello.lpi'); - FAlreadyPopulatedRecentFiles := True; - end; - // external tools if Assigned(fExternalUserTools) then fExternalUserTools.Load(FConfigStore,Path+'ExternalTools/'); diff --git a/ide/sourcefilemanager.pas b/ide/sourcefilemanager.pas index 8788b3bc8d..29a15434c4 100644 --- a/ide/sourcefilemanager.pas +++ b/ide/sourcefilemanager.pas @@ -32,7 +32,7 @@ unit SourceFileManager; interface uses - Classes, SysUtils, typinfo, math, fpjson, Laz_AVL_Tree, + Classes, SysUtils, TypInfo, Math, fpjson, Laz_AVL_Tree, // LCL Controls, Forms, Dialogs, LCLIntf, LCLType, LclStrConsts, LResources, LCLMemManager, @@ -52,7 +52,7 @@ uses IdeIntfStrConsts, ObjectInspector, SrcEditorIntf, EditorSyntaxHighlighterDef, UnitResources, ComponentReg, InputHistory, // IdeConfig - EnvironmentOpts, SearchPathProcs, TransferMacros, + EnvironmentOpts, SearchPathProcs, TransferMacros, RecentListProcs, // IDE IDEProcs, DialogProcs, IDEProtocol, LazarusIDEStrConsts, NewDialog, NewProjectDlg, MainBase, MainBar, MainIntf, Project, ProjectDefs, @@ -223,6 +223,7 @@ function FindSourceFileImpl(const AFilename, BaseDirectory: string; function FindUnitsOfOwnerImpl(TheOwner: TObject; Flags: TFindUnitsOfOwnerFlags): TStrings; // project function AddActiveUnitToProject: TModalResult; +procedure AddDefaultRecentProjects; function AddUnitToProject(const AEditor: TSourceEditorInterface): TModalResult; function RemoveFromProjectDialog: TModalResult; function InitNewProject(ProjectDesc: TProjectDescriptor): TModalResult; @@ -1773,6 +1774,35 @@ begin Result := AddUnitToProject(nil); end; +procedure AddRecentProject(aProjPath, aProjFile: string); +// Add a project to the list of recent projects if the project has write access. +// The check can be removed when the IDE allows compiling read-only projects. +var + WholeFilePath: String; +begin + aProjPath := SwitchPathDelims(aProjPath, True); + WholeFilePath := ExtractFilePath(Application.ExeName) + aProjPath + aProjFile; + if FileIsWritable(aProjPath) and FileIsWritable(WholeFilePath) then + with EnvironmentOptions do + AddToRecentList(WholeFilePath, RecentProjectFiles, MaxRecentProjectFiles, rltFile); +end; + +procedure AddDefaultRecentProjects; +begin + // Add some example projects to an empty project list. + with EnvironmentOptions do + if (RecentProjectFiles.Count=0) and not AlreadyPopulatedRecentFiles then + begin + DebugLn('AddDefaultRecentProjects: Adding default projects'); + AddRecentProject('examples/jpeg/', 'jpegexample.lpi'); + AddRecentProject('examples/sprites/', 'spriteexample.lpi'); + AddRecentProject('examples/openglcontrol/', 'openglcontrol_demo.lpi'); + AddRecentProject('examples/imagelist/', 'project1.lpi'); + AddRecentProject('examples/', 'hello.lpi'); + AlreadyPopulatedRecentFiles := True; + end; +end; + function AddUnitToProject(const AEditor: TSourceEditorInterface): TModalResult; var ActiveSourceEditor: TSourceEditor;