mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-15 02:40:03 +02:00
IDE/Toolbar: Add "headers" for groups of recent items in dropdown list of the "Open..." toolbar button
This commit is contained in:
parent
7f3bc4ae79
commit
5deb19a52d
@ -1360,6 +1360,9 @@ resourcestring
|
|||||||
dlgMaxRecentFiles = 'Files';
|
dlgMaxRecentFiles = 'Files';
|
||||||
dlgMaxRecentProjs = 'Projects';
|
dlgMaxRecentProjs = 'Projects';
|
||||||
dlgMaxRecentPacks = 'Packages';
|
dlgMaxRecentPacks = 'Packages';
|
||||||
|
dlgRecentProjects = 'Recent Projects:';
|
||||||
|
dlgRecentPackages = 'Recent Packages:';
|
||||||
|
dlgRecentFiles = 'Recent Files:';
|
||||||
dlgMaxRecentHint = 'Value 0 means unlimited.';
|
dlgMaxRecentHint = 'Value 0 means unlimited.';
|
||||||
dlgLazarusDir = 'Lazarus directory (default for all projects)';
|
dlgLazarusDir = 'Lazarus directory (default for all projects)';
|
||||||
lisLazarusDirHint = 'Lazarus sources. This path is relative to primary config directory (%s).';
|
lisLazarusDirHint = 'Lazarus sources. This path is relative to primary config directory (%s).';
|
||||||
|
@ -534,12 +534,31 @@ procedure TOpenFileToolButton.RefreshMenu(Sender: TObject);
|
|||||||
AMenuItem.ImageIndex := LoadProjectIconIntoImages(AFileName, DropdownMenu.Images, FIndex);
|
AMenuItem.ImageIndex := LoadProjectIconIntoImages(AFileName, DropdownMenu.Images, FIndex);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure AddFiles(List: TStringList; MaxCount: integer; const AOnClick: TNotifyEvent);
|
procedure AddHeader(const ACaption: string);
|
||||||
|
var
|
||||||
|
AMenuItem: TOpenFileMenuItem;
|
||||||
|
begin
|
||||||
|
AMenuItem := TOpenFileMenuItem.Create(DropdownMenu);
|
||||||
|
AMenuItem.Caption := ACaption;
|
||||||
|
AMenuItem.Enabled := false;
|
||||||
|
DropdownMenu.Items.Add(AMenuItem);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure AddRecentItemsGroup(List: TStringList; MaxCount: integer; const AOnClick: TNotifyEvent; const AHeader: string);
|
||||||
var
|
var
|
||||||
i: integer;
|
i: integer;
|
||||||
begin
|
begin
|
||||||
|
if List.Count <= 0 then
|
||||||
|
exit;
|
||||||
|
// separator
|
||||||
|
if DropdownMenu.Items.Count > 0 then
|
||||||
|
DropdownMenu.Items.AddSeparator;
|
||||||
|
// header
|
||||||
|
AddHeader(AHeader);
|
||||||
|
// value 0 means unlimited
|
||||||
if MaxCount <= 0 then
|
if MaxCount <= 0 then
|
||||||
MaxCount := List.Count;
|
MaxCount := List.Count;
|
||||||
|
// files
|
||||||
for i := 0 to Min(MaxCount, List.Count) - 1 do
|
for i := 0 to Min(MaxCount, List.Count) - 1 do
|
||||||
AddFile(List[i], AOnClick);
|
AddFile(List[i], AOnClick);
|
||||||
end;
|
end;
|
||||||
@ -548,11 +567,9 @@ begin
|
|||||||
with EnvironmentOptions do
|
with EnvironmentOptions do
|
||||||
begin
|
begin
|
||||||
DropdownMenu.Items.Clear;
|
DropdownMenu.Items.Clear;
|
||||||
AddFiles(RecentProjectFiles, MaxRecentProjectFiles, @mnuProjectFile);
|
AddRecentItemsGroup(RecentProjectFiles, MaxRecentProjectFiles, @mnuProjectFile, dlgRecentProjects);
|
||||||
DropdownMenu.Items.AddSeparator;
|
AddRecentItemsGroup(RecentPackageFiles, MaxRecentPackageFiles, @mnuPackageFile, dlgRecentPackages);
|
||||||
AddFiles(RecentPackageFiles, MaxRecentPackageFiles, @mnuPackageFile);
|
AddRecentItemsGroup(RecentOpenFiles, MaxRecentOpenFiles, @mnuOpenFile, dlgRecentFiles);
|
||||||
DropdownMenu.Items.AddSeparator;
|
|
||||||
AddFiles(RecentOpenFiles, MaxRecentOpenFiles, @mnuOpenFile);
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user