You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
RnQ/RnQ/menusUnit.pas

78 lines
2.1 KiB
Plaintext

{
This file is part of R&Q.
Under same license
}
unit menusUnit;
{$I RnQConfig.inc}
interface
uses
Classes, Menus, RnQMenu;
{$I NoRTTI.inc}
procedure addGroupsToMenu(own: Tcomponent; mi: Tmenuitem; action: TnotifyEvent; pAddOut: Boolean);
procedure createFavMenu(root: Tmenuitem; action: TnotifyEvent);
implementation
uses
SysUtils, shlObj,
RDUtils, RnQSysUtils, RnQLangs, RnQPics, globalLib, utilLib;
procedure addGroupsToMenu(own: Tcomponent; mi: Tmenuitem; action: TnotifyEvent; pAddOut: Boolean);
var
I: Integer;
ss: TStringList;
begin
mi.clear;
if pAddOut then
begin
AddToMenu(mi, getTranslation('Out of groups'), PIC_OUT_OF_GROUPS, False, action).tag := 2000;
AddToMenu(mi, '-', '', False);
end;
ss := Tstringlist.Create;
groups.AddGroupsToList(ss, pAddOut);
ss.sort;
for I := 0 to ss.count - 1 do
with AddToMenu(mi, ss[I], PIC_CLOSE_GROUP, False, action, False) do
begin
CanTranslate := False;
tag := Integer(ss.objects[I]);
end;
ss.free;
applyCommonSettings(own);
// mi.Enabled := true;
end; // addGroupsToMenu
procedure createFavMenuFrom(path: String; root: Tmenuitem; action: TnotifyEvent);
var
sr: TSearchRec;
Begin
path := IncludeTrailingPathDelimiter(path);
if findFirst(path + '*.*', faDirectory, sr) = 0 then
repeat
if sr.attr and faDirectory <> 0 then
begin
if (sr.name = '.') or (sr.name = '..') then
continue;
createFavMenuFrom(path + sr.name, AddToMenu(root, dupAmpersand(sr.name), PIC_CLOSE_GROUP, False), action);
continue;
end;
if compareText(copy(sr.name, Length(sr.name) - 3, 4), '.url') = 0 then
begin
AddToMenu(root, dupAmpersand(copy(sr.name, 1, Length(sr.name) - 4)), PIC_URL, False, action).Hint := path + sr.name;
end;
until findNext(sr) <> 0;
findClose(sr);
end; // createFavMenuFrom
procedure createFavMenu(root: Tmenuitem; action: TnotifyEvent);
begin
createFavMenuFrom(getSpecialFolder(CSIDL_FAVORITES), root, action)
end;
end.