Skip to content

Commit a91d176

Browse files
author
César Cardoso
committed
feature/open-external-in-cubmenus-init
1 parent 5262768 commit a91d176

5 files changed

Lines changed: 69 additions & 30 deletions

File tree

Src/Consts/C4D.Wizard.Consts.pas

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ TC4DConsts = class
136136
OPEN_EXTERNAL_INI_Order = 'Order';
137137
OPEN_EXTERNAL_INI_Shortcut = 'Shortcut';
138138
OPEN_EXTERNAL_INI_IconHas = 'IconHas';
139+
OPEN_EXTERNAL_INI_GuidMenuParent = 'GuidMenuParent';
139140
OPEN_EXTERNAL_INI_PREFIX_IMG = 'OPEN_EXTERNAL_IMG_';
140141

141142
//TOOLBAR BRANCH

Src/IDE/MainMenu/C4D.Wizard.IDE.MainMenu.OpenExternal.pas

Lines changed: 48 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ TC4DWizardIDEMainMenuOpenExternal = class(TInterfacedObject, IC4DWizardIDEMain
2020
FMenuItemOpenExternal: TMenuItem;
2121
FList: TObjectList<TC4DWizardOpenExternal>;
2222
procedure CreateItemMenuMain;
23-
procedure CreateSubMenu(const AName: string; const ACaption: string; const AOnClick: TNotifyEvent); overload;
24-
procedure CreateSubMenu(const AC4DWizardOpenExternal: TC4DWizardOpenExternal); overload;
23+
function CreateSubMenu(const AMenuItemParent: TMenuItem; const AName: string; const ACaption: string; const AOnClick: TNotifyEvent): TMenuItem; overload;
24+
function CreateSubMenu(const AMenuItemParent: TMenuItem; const AC4DWizardOpenExternal: TC4DWizardOpenExternal): TMenuItem; overload;
2525
procedure CustomizeClick(Sender: TObject);
2626
procedure ItemMenuClick(Sender: TObject);
2727
procedure CreateMenuItensList;
@@ -63,13 +63,11 @@ destructor TC4DWizardIDEMainMenuOpenExternal.Destroy;
6363
function TC4DWizardIDEMainMenuOpenExternal.CreateMenusOpenExternal: IC4DWizardIDEMainMenuOpenExternal;
6464
begin
6565
Self.CreateItemMenuMain;
66-
Self.CreateSubMenu('C4DOpenExternalMenuItemCad1', 'Customize...', Self.CustomizeClick);
67-
Self.CreateSubMenu('C4DOpenExternalSeparator01', '-', {$IF CompilerVersion = 30.0} TNotifyEvent(nil) {$ELSE} nil {$ENDIF});
66+
Self.CreateSubMenu(FMenuItemOpenExternal, 'C4DOpenExternalMenuItemCad1', 'Customize...', Self.CustomizeClick);
67+
Self.CreateSubMenu(FMenuItemOpenExternal, 'C4DOpenExternalSeparator01', '-', {$IF CompilerVersion = 30.0} TNotifyEvent(nil) {$ELSE} nil {$ENDIF});
6868

6969
FList.Clear;
70-
TC4DWizardOpenExternalModel
71-
.New
72-
.ReadIniFile(
70+
TC4DWizardOpenExternalModel.New.ReadIniFile(
7371
procedure(AC4DWizardOpenExternal: TC4DWizardOpenExternal)
7472
var
7573
LC4DWizardOpenExternal: TC4DWizardOpenExternal;
@@ -85,6 +83,8 @@ function TC4DWizardIDEMainMenuOpenExternal.CreateMenusOpenExternal: IC4DWizardID
8583
LC4DWizardOpenExternal.Order := AC4DWizardOpenExternal.Order;
8684
LC4DWizardOpenExternal.Shortcut := AC4DWizardOpenExternal.Shortcut;
8785
LC4DWizardOpenExternal.IconHas := AC4DWizardOpenExternal.IconHas;
86+
LC4DWizardOpenExternal.GuidMenuParent := AC4DWizardOpenExternal.GuidMenuParent;
87+
LC4DWizardOpenExternal.Created := False;
8888
FList.Add(LC4DWizardOpenExternal);
8989
end);
9090
Self.CreateMenuItensList;
@@ -95,6 +95,11 @@ procedure TC4DWizardIDEMainMenuOpenExternal.CreateMenuItensList;
9595
LItem: TC4DWizardOpenExternal;
9696
LListOrder: TList<Integer>;
9797
I: Integer;
98+
LMenuItem: TMenuItem;
99+
100+
I2: Integer;
101+
LItem2: TC4DWizardOpenExternal;
102+
LMenuItem2: TMenuItem;
98103
begin
99104
if(FList.Count <= 0)then
100105
Exit;
@@ -106,17 +111,38 @@ procedure TC4DWizardIDEMainMenuOpenExternal.CreateMenuItensList;
106111
LListOrder.Add(LItem.Order);
107112

108113
LListOrder.Sort;
114+
115+
//PRIMEIRO COLOCA OS PARENT (PAIS)
109116
for I in LListOrder do
110117
for LItem in FList do
118+
begin
111119
if(LItem.Order = I)then
112-
Self.CreateSubMenu(LItem);
120+
if(not LItem.Created)and(LITem.GuidMenuParent.Trim.IsEmpty)then
121+
begin
122+
LMenuItem := Self.CreateSubMenu(FMenuItemOpenExternal, LItem);
123+
LItem.Created := True;
124+
125+
//**
126+
for I2 in LListOrder do
127+
for LItem2 in FList do
128+
begin
129+
if(LItem2.Order = I2)then
130+
if(not LItem2.Created)and(LItem2.GuidMenuParent.Trim = LITem.Guid.Trim)then
131+
begin
132+
LMenuItem2 := Self.CreateSubMenu(LMenuItem, LItem2);
133+
LItem2.Created := True;
134+
end;
135+
end;
136+
//**
137+
end;
138+
end;
113139
finally
114140
LListOrder.Free;
115141
end;
116142

117143
for LItem in FList do
118144
if(LItem.Order = 0)then
119-
Self.CreateSubMenu(LItem);
145+
Self.CreateSubMenu(FMenuItemOpenExternal, LItem);
120146
end;
121147

122148
procedure TC4DWizardIDEMainMenuOpenExternal.CreateItemMenuMain;
@@ -128,36 +154,33 @@ procedure TC4DWizardIDEMainMenuOpenExternal.CreateItemMenuMain;
128154
FMenuItemParent.Add(FMenuItemOpenExternal);
129155
end;
130156

131-
procedure TC4DWizardIDEMainMenuOpenExternal.CustomizeClick(Sender: TObject);
132-
begin
133-
C4DWizardOpenExternalViewShow;
134-
end;
135-
136-
procedure TC4DWizardIDEMainMenuOpenExternal.CreateSubMenu(const AName: string; const ACaption: string; const AOnClick: TNotifyEvent);
157+
function TC4DWizardIDEMainMenuOpenExternal.CreateSubMenu(const AMenuItemParent: TMenuItem; const AName: string; const ACaption: string; const AOnClick: TNotifyEvent): TMenuItem;
137158
var
138159
LMenuItem: TMenuItem;
139160
begin
140-
LMenuItem := TMenuItem.Create(FMenuItemOpenExternal);
161+
LMenuItem := TMenuItem.Create(AMenuItemParent);
141162
LMenuItem.Name := AName;
142163
LMenuItem.Caption := ACaption;
143164
LMenuItem.OnClick := AOnClick;
144165
LMenuItem.Hint := '';
145166
LMenuItem.ImageIndex := -1;
146-
FMenuItemOpenExternal.Add(LMenuItem);
167+
AMenuItemParent.Add(LMenuItem);
168+
Result := LMenuItem;
147169
end;
148170

149-
procedure TC4DWizardIDEMainMenuOpenExternal.CreateSubMenu(const AC4DWizardOpenExternal: TC4DWizardOpenExternal);
171+
function TC4DWizardIDEMainMenuOpenExternal.CreateSubMenu(const AMenuItemParent: TMenuItem; const AC4DWizardOpenExternal: TC4DWizardOpenExternal): TMenuItem;
150172
var
151173
LMenuItem: TMenuItem;
152174
begin
153-
LMenuItem := TMenuItem.Create(FMenuItemOpenExternal);
175+
LMenuItem := TMenuItem.Create(AMenuItemParent);
154176
LMenuItem.Name := 'C4DOpenExternalItemMenu' + TC4DWizardUtils.IncInt(FCont).Tostring;
155177
LMenuItem.Caption := AC4DWizardOpenExternal.Description;
156178
LMenuItem.OnClick := Self.ItemMenuClick;
157179
LMenuItem.Hint := AC4DWizardOpenExternal.Path + TC4DConsts.OPEN_EXTERNAL_Separator_PARAMETERS + AC4DWizardOpenExternal.Parameters;
158180
LMenuItem.Shortcut := TextToShortCut(AC4DWizardOpenExternal.Shortcut);
159181
LMenuItem.ImageIndex := TC4DWizardOpenExternalUtils.GetImageIndexIfExists(AC4DWizardOpenExternal);
160-
FMenuItemOpenExternal.Add(LMenuItem);
182+
AMenuItemParent.Add(LMenuItem);
183+
Result := LMenuItem;
161184
end;
162185

163186
procedure TC4DWizardIDEMainMenuOpenExternal.ItemMenuClick(Sender: TObject);
@@ -171,4 +194,9 @@ procedure TC4DWizardIDEMainMenuOpenExternal.ItemMenuClick(Sender: TObject);
171194
TC4DWizardOpenExternalUtils.ClickFromString(LMenuItem.Hint);
172195
end;
173196

197+
procedure TC4DWizardIDEMainMenuOpenExternal.CustomizeClick(Sender: TObject);
198+
begin
199+
C4DWizardOpenExternalViewShow;
200+
end;
201+
174202
end.

Src/IDE/ToolBars/C4D.Wizard.IDE.ToolBars.Utilities.pas

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ procedure TC4DWizardIDEToolBarsUtilities.OpenExternalFillList;
273273
LC4DWizardOpenExternal.Order := AC4DWizardOpenExternal.Order;
274274
LC4DWizardOpenExternal.Shortcut := AC4DWizardOpenExternal.Shortcut;
275275
LC4DWizardOpenExternal.IconHas := AC4DWizardOpenExternal.IconHas;
276+
LC4DWizardOpenExternal.GuidMenuParent := AC4DWizardOpenExternal.GuidMenuParent;
276277
FList.Add(LC4DWizardOpenExternal);
277278
end);
278279
end;

Src/OpenExternal/C4D.Wizard.OpenExternal.Model.pas

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ function TC4DWizardOpenExternalModel.WriteInIniFile(AC4DWizardOpenExternal: TC4D
6262
LIniFile.WriteInteger(AC4DWizardOpenExternal.Guid, TC4DConsts.OPEN_EXTERNAL_INI_Order, AC4DWizardOpenExternal.Order);
6363
LIniFile.Writestring(AC4DWizardOpenExternal.Guid, TC4DConsts.OPEN_EXTERNAL_INI_Shortcut, AC4DWizardOpenExternal.Shortcut);
6464
LIniFile.WriteBool(AC4DWizardOpenExternal.Guid, TC4DConsts.OPEN_EXTERNAL_INI_IconHas, AC4DWizardOpenExternal.IconHas);
65+
LIniFile.Writestring(AC4DWizardOpenExternal.Guid, TC4DConsts.OPEN_EXTERNAL_INI_GuidMenuParent, AC4DWizardOpenExternal.GuidMenuParent);
6566
finally
6667
LIniFile.Free;
6768
end;
@@ -97,15 +98,16 @@ function TC4DWizardOpenExternalModel.ReadGuidInIniFile(AGuid: string): TC4DWizar
9798
LIniFile := Self.GetIniFile;
9899
try
99100
Result.Guid := AGuid;
100-
Result.Description := LIniFile.Readstring(AGuid, TC4DConsts.OPEN_EXTERNAL_INI_Description, '');
101-
Result.Path := LIniFile.Readstring(AGuid, TC4DConsts.OPEN_EXTERNAL_INI_Path, '');
102-
Result.Parameters := LIniFile.Readstring(AGuid, TC4DConsts.OPEN_EXTERNAL_INI_Parameters, '');
103-
Result.Kind := TC4DWizardUtils.StrToOpenExternalKind(LIniFile.Readstring(AGuid, TC4DConsts.OPEN_EXTERNAL_INI_Kind, ''));
101+
Result.Description := LIniFile.ReadString(AGuid, TC4DConsts.OPEN_EXTERNAL_INI_Description, '');
102+
Result.Path := LIniFile.ReadString(AGuid, TC4DConsts.OPEN_EXTERNAL_INI_Path, '');
103+
Result.Parameters := LIniFile.ReadString(AGuid, TC4DConsts.OPEN_EXTERNAL_INI_Parameters, '');
104+
Result.Kind := TC4DWizardUtils.StrToOpenExternalKind(LIniFile.ReadString(AGuid, TC4DConsts.OPEN_EXTERNAL_INI_Kind, ''));
104105
Result.Visible := LIniFile.ReadBool(AGuid, TC4DConsts.OPEN_EXTERNAL_INI_Visible, True);
105106
Result.VisibleInToolBarUtilities := LIniFile.ReadBool(AGuid, TC4DConsts.OPEN_EXTERNAL_INI_VisibleInToolBarUtilities, False);
106107
Result.Order := LIniFile.ReadInteger(AGuid, TC4DConsts.OPEN_EXTERNAL_INI_Order, 0);
107-
Result.Shortcut := LIniFile.Readstring(AGuid, TC4DConsts.OPEN_EXTERNAL_INI_Shortcut, '');
108+
Result.Shortcut := LIniFile.ReadString(AGuid, TC4DConsts.OPEN_EXTERNAL_INI_Shortcut, '');
108109
Result.IconHas := LIniFile.ReadBool(AGuid, TC4DConsts.OPEN_EXTERNAL_INI_IconHas, False);
110+
Result.GuidMenuParent := LIniFile.ReadString(AGuid, TC4DConsts.OPEN_EXTERNAL_INI_GuidMenuParent, '');
109111
finally
110112
LIniFile.Free;
111113
end;
@@ -130,15 +132,16 @@ procedure TC4DWizardOpenExternalModel.ReadIniFile(AProc: TProc<TC4DWizardOpenExt
130132
LC4DWizardOpenExternal := TC4DWizardOpenExternal.Create;
131133
try
132134
LC4DWizardOpenExternal.Guid := LSessaoStr;
133-
LC4DWizardOpenExternal.Description := LIniFile.Readstring(LSessaoStr, TC4DConsts.OPEN_EXTERNAL_INI_Description, '');
134-
LC4DWizardOpenExternal.Path := LIniFile.Readstring(LSessaoStr, TC4DConsts.OPEN_EXTERNAL_INI_Path, '');
135-
LC4DWizardOpenExternal.Parameters := LIniFile.Readstring(LSessaoStr, TC4DConsts.OPEN_EXTERNAL_INI_Parameters, '');
136-
LC4DWizardOpenExternal.Kind := TC4DWizardUtils.StrToOpenExternalKind(LIniFile.Readstring(LSessaoStr, TC4DConsts.OPEN_EXTERNAL_INI_Kind, ''));
135+
LC4DWizardOpenExternal.Description := LIniFile.ReadString(LSessaoStr, TC4DConsts.OPEN_EXTERNAL_INI_Description, '');
136+
LC4DWizardOpenExternal.Path := LIniFile.ReadString(LSessaoStr, TC4DConsts.OPEN_EXTERNAL_INI_Path, '');
137+
LC4DWizardOpenExternal.Parameters := LIniFile.ReadString(LSessaoStr, TC4DConsts.OPEN_EXTERNAL_INI_Parameters, '');
138+
LC4DWizardOpenExternal.Kind := TC4DWizardUtils.StrToOpenExternalKind(LIniFile.ReadString(LSessaoStr, TC4DConsts.OPEN_EXTERNAL_INI_Kind, ''));
137139
LC4DWizardOpenExternal.Visible := LIniFile.ReadBool(LSessaoStr, TC4DConsts.OPEN_EXTERNAL_INI_Visible, True);
138140
LC4DWizardOpenExternal.VisibleInToolBarUtilities := LIniFile.ReadBool(LSessaoStr, TC4DConsts.OPEN_EXTERNAL_INI_VisibleInToolBarUtilities, False);
139141
LC4DWizardOpenExternal.Order := LIniFile.ReadInteger(LSessaoStr, TC4DConsts.OPEN_EXTERNAL_INI_Order, 0);
140-
LC4DWizardOpenExternal.Shortcut := LIniFile.Readstring(LSessaoStr, TC4DConsts.OPEN_EXTERNAL_INI_Shortcut, '');
142+
LC4DWizardOpenExternal.Shortcut := LIniFile.ReadString(LSessaoStr, TC4DConsts.OPEN_EXTERNAL_INI_Shortcut, '');
141143
LC4DWizardOpenExternal.IconHas := LIniFile.ReadBool(LSessaoStr, TC4DConsts.OPEN_EXTERNAL_INI_IconHas, False);
144+
LC4DWizardOpenExternal.GuidMenuParent := LIniFile.ReadString(LSessaoStr, TC4DConsts.OPEN_EXTERNAL_INI_GuidMenuParent, '');
142145
AProc(LC4DWizardOpenExternal);
143146
finally
144147
LC4DWizardOpenExternal.Free;

Src/OpenExternal/C4D.Wizard.OpenExternal.pas

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ TC4DWizardOpenExternal = class
1818
FVisible: Boolean;
1919
FVisibleInToolBarUtilities: Boolean;
2020
FIconHas: Boolean;
21+
FGuidMenuParent: string;
22+
FCreated: Boolean;
2123
public
2224
property Guid: string read FGuid write FGuid;
2325
property Description: string read FDescription write FDescription;
@@ -29,6 +31,8 @@ TC4DWizardOpenExternal = class
2931
property Visible: Boolean read FVisible write FVisible;
3032
property VisibleInToolBarUtilities: Boolean read FVisibleInToolBarUtilities write FVisibleInToolBarUtilities;
3133
property IconHas: Boolean read FIconHas write FIconHas;
34+
property GuidMenuParent: string read FGuidMenuParent write FGuidMenuParent;
35+
property Created: Boolean read FCreated write FCreated;
3236
procedure Clear;
3337
constructor Create;
3438
end;
@@ -52,6 +56,8 @@ procedure TC4DWizardOpenExternal.Clear;
5256
FVisible := False;
5357
FVisibleInToolBarUtilities := False;
5458
FIconHas := False;
59+
FGuidMenuParent := '';
60+
FCreated := False;
5561
end;
5662

5763
end.

0 commit comments

Comments
 (0)