mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 21:41:35 +02:00
IDE: Move adding default initial recent projects out from EnvironmentOptions.
This commit is contained in:
parent
967034aff5
commit
b99f4dc28d
@ -376,7 +376,7 @@ end;
|
|||||||
|
|
||||||
constructor TBuildManager.Create(AOwner: TComponent);
|
constructor TBuildManager.Create(AOwner: TComponent);
|
||||||
begin
|
begin
|
||||||
EnvironmentOptions := TEnvironmentOptions.Create(Application.ExeName);
|
EnvironmentOptions := TEnvironmentOptions.Create;
|
||||||
IDEEnvironmentOptions := EnvironmentOptions;
|
IDEEnvironmentOptions := EnvironmentOptions;
|
||||||
EnvironmentOptions.IsGlobalMode:=@EnvironmentOptionsIsGlobalMode;
|
EnvironmentOptions.IsGlobalMode:=@EnvironmentOptionsIsGlobalMode;
|
||||||
|
|
||||||
|
@ -286,7 +286,7 @@ begin
|
|||||||
AFilename:=SaveDialog.Filename;
|
AFilename:=SaveDialog.Filename;
|
||||||
if ExtractFileExt(AFilename)='' then
|
if ExtractFileExt(AFilename)='' then
|
||||||
AFilename:=AFilename+'.lds';
|
AFilename:=AFilename+'.lds';
|
||||||
AnEnvironmentOptions := TEnvironmentOptions.Create(Application.ExeName);
|
AnEnvironmentOptions := TEnvironmentOptions.Create;
|
||||||
try
|
try
|
||||||
AnEnvironmentOptions.Filename := AFilename;
|
AnEnvironmentOptions.Filename := AFilename;
|
||||||
DoSaveSettings(AnEnvironmentOptions);
|
DoSaveSettings(AnEnvironmentOptions);
|
||||||
@ -323,7 +323,7 @@ begin
|
|||||||
+'|'+dlgFilterAll+' ('+GetAllFilesMask+')|' + GetAllFilesMask;
|
+'|'+dlgFilterAll+' ('+GetAllFilesMask+')|' + GetAllFilesMask;
|
||||||
if OpenDialog.Execute then
|
if OpenDialog.Execute then
|
||||||
begin
|
begin
|
||||||
AnEnvironmentOptions := TEnvironmentOptions.Create(Application.ExeName);
|
AnEnvironmentOptions := TEnvironmentOptions.Create;
|
||||||
try
|
try
|
||||||
AnEnvironmentOptions.Filename := OpenDialog.Filename;
|
AnEnvironmentOptions.Filename := OpenDialog.Filename;
|
||||||
AnEnvironmentOptions.Load(true);
|
AnEnvironmentOptions.Load(true);
|
||||||
|
@ -1219,6 +1219,7 @@
|
|||||||
<Unit>
|
<Unit>
|
||||||
<Filename Value="helpoptions.pas"/>
|
<Filename Value="helpoptions.pas"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
|
<UnitName Value="HelpOptions"/>
|
||||||
</Unit>
|
</Unit>
|
||||||
<Unit>
|
<Unit>
|
||||||
<Filename Value="findinfilesdlg.pas"/>
|
<Filename Value="findinfilesdlg.pas"/>
|
||||||
|
@ -1248,8 +1248,9 @@ begin
|
|||||||
CreateConfig;
|
CreateConfig;
|
||||||
Load(false);
|
Load(false);
|
||||||
end;
|
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
|
if Application.HasOption('language') then
|
||||||
begin
|
begin
|
||||||
debugln('Hint: (lazarus) [TMainIDE.LoadGlobalOptions] overriding language with command line: ',
|
debugln('Hint: (lazarus) [TMainIDE.LoadGlobalOptions] overriding language with command line: ',
|
||||||
|
@ -247,7 +247,6 @@ type
|
|||||||
|
|
||||||
TEnvironmentOptions = class(TIDEEnvironmentOptions)
|
TEnvironmentOptions = class(TIDEEnvironmentOptions)
|
||||||
private
|
private
|
||||||
FExePath: string; // ExtractFilePath(Application.ExeName)
|
|
||||||
FFppkgCheck: boolean;
|
FFppkgCheck: boolean;
|
||||||
fRegisteredSubConfig: TObjectList;
|
fRegisteredSubConfig: TObjectList;
|
||||||
// config file
|
// config file
|
||||||
@ -307,7 +306,7 @@ type
|
|||||||
FNewProjectTemplateAtStart: string;
|
FNewProjectTemplateAtStart: string;
|
||||||
FMultipleInstances: TIDEMultipleInstancesOption;
|
FMultipleInstances: TIDEMultipleInstancesOption;
|
||||||
// Prevent repopulating Recent project files menu with example projects if it was already cleared up.
|
// Prevent repopulating Recent project files menu with example projects if it was already cleared up.
|
||||||
FAlreadyPopulatedRecentFiles : Boolean;
|
FAlreadyPopulatedRecentFiles: Boolean;
|
||||||
//other recent settings
|
//other recent settings
|
||||||
FLastEventMethodCCResult: TCodeCreationDlgResult;
|
FLastEventMethodCCResult: TCodeCreationDlgResult;
|
||||||
FLastVariableCCResult: TCodeCreationDlgResult;
|
FLastVariableCCResult: TCodeCreationDlgResult;
|
||||||
@ -371,7 +370,7 @@ type
|
|||||||
function SubConfigCount: integer;
|
function SubConfigCount: integer;
|
||||||
property SubConfig[Index: Integer]: TIDESubOptions read GetSubConfig;
|
property SubConfig[Index: Integer]: TIDESubOptions read GetSubConfig;
|
||||||
public
|
public
|
||||||
constructor Create(AExeName: string);
|
constructor Create;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
procedure Load(OnlyDesktop: boolean);
|
procedure Load(OnlyDesktop: boolean);
|
||||||
procedure Save(OnlyDesktop: boolean);
|
procedure Save(OnlyDesktop: boolean);
|
||||||
@ -477,8 +476,8 @@ type
|
|||||||
write FNewProjectTemplateAtStart;
|
write FNewProjectTemplateAtStart;
|
||||||
property MultipleInstances: TIDEMultipleInstancesOption read FMultipleInstances
|
property MultipleInstances: TIDEMultipleInstancesOption read FMultipleInstances
|
||||||
write FMultipleInstances;
|
write FMultipleInstances;
|
||||||
property FileDialogFilter: string read FFileDialogFilter write FFileDialogFilter;
|
property AlreadyPopulatedRecentFiles: Boolean read FAlreadyPopulatedRecentFiles
|
||||||
|
write FAlreadyPopulatedRecentFiles;
|
||||||
// other recent settings
|
// other recent settings
|
||||||
property LastEventMethodCCResult: TCodeCreationDlgResult
|
property LastEventMethodCCResult: TCodeCreationDlgResult
|
||||||
read FLastEventMethodCCResult write FLastEventMethodCCResult;
|
read FLastEventMethodCCResult write FLastEventMethodCCResult;
|
||||||
@ -516,8 +515,9 @@ type
|
|||||||
// comboboxes
|
// comboboxes
|
||||||
property DropDownCount: Integer read FDropDownCount write FDropDownCount;
|
property DropDownCount: Integer read FDropDownCount write FDropDownCount;
|
||||||
// default template for each 'new item' category: Name=Path, Value=TemplateName
|
// 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 NewFormTemplate: string read FNewFormTemplate write FNewFormTemplate;
|
||||||
|
property NewUnitTemplate: string read FNewUnitTemplate write FNewUnitTemplate;
|
||||||
|
property FileDialogFilter: string read FFileDialogFilter write FFileDialogFilter;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
@ -658,12 +658,11 @@ end;
|
|||||||
|
|
||||||
{ TEnvironmentOptions }
|
{ TEnvironmentOptions }
|
||||||
|
|
||||||
constructor TEnvironmentOptions.Create(AExeName: string);
|
constructor TEnvironmentOptions.Create;
|
||||||
var
|
var
|
||||||
o: TEnvOptParseType;
|
o: TEnvOptParseType;
|
||||||
begin
|
begin
|
||||||
inherited Create;
|
inherited Create;
|
||||||
FExePath := ExtractFilePath(AExeName);
|
|
||||||
fRegisteredSubConfig := TObjectList.Create(False);
|
fRegisteredSubConfig := TObjectList.Create(False);
|
||||||
for o:=low(FParseValues) to high(FParseValues) do
|
for o:=low(FParseValues) to high(FParseValues) do
|
||||||
FParseValues[o].ParseStamp:=CTInvalidChangeStamp;
|
FParseValues[o].ParseStamp:=CTInvalidChangeStamp;
|
||||||
@ -943,18 +942,6 @@ end;
|
|||||||
|
|
||||||
procedure TEnvironmentOptions.Load(OnlyDesktop: boolean);
|
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);
|
procedure LoadPascalFileExt(const Path: string);
|
||||||
begin
|
begin
|
||||||
fPascalFileExtension:=PascalExtToType(FXMLCfg.GetValue(
|
fPascalFileExtension:=PascalExtToType(FXMLCfg.GetValue(
|
||||||
@ -971,7 +958,7 @@ procedure TEnvironmentOptions.Load(OnlyDesktop: boolean);
|
|||||||
CCResult.Location:=CreateCodeLocationNameToLocation(FXMLCfg.GetValue(
|
CCResult.Location:=CreateCodeLocationNameToLocation(FXMLCfg.GetValue(
|
||||||
Path+'/Location',CreateCodeLocationNames[cclLocal]));
|
Path+'/Location',CreateCodeLocationNames[cclLocal]));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
Path, CurPath: String;
|
Path, CurPath: String;
|
||||||
i: Integer;
|
i: Integer;
|
||||||
@ -1052,16 +1039,6 @@ begin
|
|||||||
FUseUnitDlgOptions.AllUnits:=FXMLCfg.GetValue(Path+'Recent/UseUnitDlg/AllUnits',False);
|
FUseUnitDlgOptions.AllUnits:=FXMLCfg.GetValue(Path+'Recent/UseUnitDlg/AllUnits',False);
|
||||||
FUseUnitDlgOptions.AddToImplementation:=FXMLCfg.GetValue(Path+'Recent/UseUnitDlg/AddToImplementation',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
|
// external tools
|
||||||
if Assigned(fExternalUserTools) then
|
if Assigned(fExternalUserTools) then
|
||||||
fExternalUserTools.Load(FConfigStore,Path+'ExternalTools/');
|
fExternalUserTools.Load(FConfigStore,Path+'ExternalTools/');
|
||||||
|
@ -32,7 +32,7 @@ unit SourceFileManager;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, typinfo, math, fpjson, Laz_AVL_Tree,
|
Classes, SysUtils, TypInfo, Math, fpjson, Laz_AVL_Tree,
|
||||||
// LCL
|
// LCL
|
||||||
Controls, Forms, Dialogs, LCLIntf, LCLType, LclStrConsts,
|
Controls, Forms, Dialogs, LCLIntf, LCLType, LclStrConsts,
|
||||||
LResources, LCLMemManager,
|
LResources, LCLMemManager,
|
||||||
@ -52,7 +52,7 @@ uses
|
|||||||
IdeIntfStrConsts, ObjectInspector, SrcEditorIntf, EditorSyntaxHighlighterDef,
|
IdeIntfStrConsts, ObjectInspector, SrcEditorIntf, EditorSyntaxHighlighterDef,
|
||||||
UnitResources, ComponentReg, InputHistory,
|
UnitResources, ComponentReg, InputHistory,
|
||||||
// IdeConfig
|
// IdeConfig
|
||||||
EnvironmentOpts, SearchPathProcs, TransferMacros,
|
EnvironmentOpts, SearchPathProcs, TransferMacros, RecentListProcs,
|
||||||
// IDE
|
// IDE
|
||||||
IDEProcs, DialogProcs, IDEProtocol, LazarusIDEStrConsts, NewDialog,
|
IDEProcs, DialogProcs, IDEProtocol, LazarusIDEStrConsts, NewDialog,
|
||||||
NewProjectDlg, MainBase, MainBar, MainIntf, Project, ProjectDefs,
|
NewProjectDlg, MainBase, MainBar, MainIntf, Project, ProjectDefs,
|
||||||
@ -223,6 +223,7 @@ function FindSourceFileImpl(const AFilename, BaseDirectory: string;
|
|||||||
function FindUnitsOfOwnerImpl(TheOwner: TObject; Flags: TFindUnitsOfOwnerFlags): TStrings;
|
function FindUnitsOfOwnerImpl(TheOwner: TObject; Flags: TFindUnitsOfOwnerFlags): TStrings;
|
||||||
// project
|
// project
|
||||||
function AddActiveUnitToProject: TModalResult;
|
function AddActiveUnitToProject: TModalResult;
|
||||||
|
procedure AddDefaultRecentProjects;
|
||||||
function AddUnitToProject(const AEditor: TSourceEditorInterface): TModalResult;
|
function AddUnitToProject(const AEditor: TSourceEditorInterface): TModalResult;
|
||||||
function RemoveFromProjectDialog: TModalResult;
|
function RemoveFromProjectDialog: TModalResult;
|
||||||
function InitNewProject(ProjectDesc: TProjectDescriptor): TModalResult;
|
function InitNewProject(ProjectDesc: TProjectDescriptor): TModalResult;
|
||||||
@ -1773,6 +1774,35 @@ begin
|
|||||||
Result := AddUnitToProject(nil);
|
Result := AddUnitToProject(nil);
|
||||||
end;
|
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;
|
function AddUnitToProject(const AEditor: TSourceEditorInterface): TModalResult;
|
||||||
var
|
var
|
||||||
ActiveSourceEditor: TSourceEditor;
|
ActiveSourceEditor: TSourceEditor;
|
||||||
|
Loading…
Reference in New Issue
Block a user