|
| 1 | +unit C4D.Wizard.IDE.MainMenu.VsCodeIntegration; |
| 2 | + |
| 3 | +interface |
| 4 | + |
| 5 | +uses |
| 6 | + System.SysUtils, |
| 7 | + System.Classes, |
| 8 | + VCL.Menus; |
| 9 | + |
| 10 | +type |
| 11 | + IC4DWizardIDEMainMenuVsCodeIntegration = interface |
| 12 | + ['{9B729013-F7A2-4B98-AC35-994E236682A0}'] |
| 13 | + function Process: IC4DWizardIDEMainMenuVsCodeIntegration; |
| 14 | + end; |
| 15 | + |
| 16 | + TC4DWizardIDEMainMenuVsCodeIntegration = class(TInterfacedObject, IC4DWizardIDEMainMenuVsCodeIntegration) |
| 17 | + private |
| 18 | + FMenuItemC4D: TMenuItem; |
| 19 | + FMenuItemVsCodeIntegration: TMenuItem; |
| 20 | + procedure AddMenuVsCodeIntegration; |
| 21 | + procedure AddSubMenuItemOpen; |
| 22 | + procedure AddSubMenuInstallDelphiLSP; |
| 23 | + procedure AddSeparator(AName: string); |
| 24 | + function GetShortcutOpenInVsCode: string; |
| 25 | + protected |
| 26 | + function Process: IC4DWizardIDEMainMenuVsCodeIntegration; |
| 27 | + public |
| 28 | + class function New(AMenuItemParent: TMenuItem): IC4DWizardIDEMainMenuVsCodeIntegration; |
| 29 | + constructor Create(AMenuItemParent: TMenuItem); |
| 30 | + end; |
| 31 | + |
| 32 | +implementation |
| 33 | + |
| 34 | +uses |
| 35 | + C4D.Wizard.Consts, |
| 36 | + C4D.Wizard.Utils, |
| 37 | + C4D.Wizard.IDE.ImageListMain, |
| 38 | + C4D.Wizard.IDE.MainMenu.Clicks, |
| 39 | + C4D.Wizard.Settings.Model; |
| 40 | + |
| 41 | +class function TC4DWizardIDEMainMenuVsCodeIntegration.New(AMenuItemParent: TMenuItem): IC4DWizardIDEMainMenuVsCodeIntegration; |
| 42 | +begin |
| 43 | + Result := Self.Create(AMenuItemParent); |
| 44 | +end; |
| 45 | + |
| 46 | +constructor TC4DWizardIDEMainMenuVsCodeIntegration.Create(AMenuItemParent: TMenuItem); |
| 47 | +begin |
| 48 | + FMenuItemC4D := AMenuItemParent; |
| 49 | +end; |
| 50 | + |
| 51 | +function TC4DWizardIDEMainMenuVsCodeIntegration.Process: IC4DWizardIDEMainMenuVsCodeIntegration; |
| 52 | +begin |
| 53 | + Self.AddMenuVsCodeIntegration; |
| 54 | + Self.AddSubMenuItemOpen; |
| 55 | + Self.AddSeparator('C4DVsCodeIntegrationSeparator01'); |
| 56 | + Self.AddSubMenuInstallDelphiLSP; |
| 57 | +end; |
| 58 | + |
| 59 | +procedure TC4DWizardIDEMainMenuVsCodeIntegration.AddSeparator(AName: string); |
| 60 | +var |
| 61 | + LMenuItem: TMenuItem; |
| 62 | +begin |
| 63 | + LMenuItem := TMenuItem.Create(FMenuItemVsCodeIntegration); |
| 64 | + LMenuItem.Name := AName; |
| 65 | + LMenuItem.Caption := '-'; |
| 66 | + LMenuItem.ImageIndex := -1; |
| 67 | + LMenuItem.OnClick := nil; |
| 68 | + FMenuItemVsCodeIntegration.Add(LMenuItem); |
| 69 | +end; |
| 70 | + |
| 71 | +procedure TC4DWizardIDEMainMenuVsCodeIntegration.AddMenuVsCodeIntegration; |
| 72 | +begin |
| 73 | + FMenuItemVsCodeIntegration := TMenuItem.Create(FMenuItemC4D); |
| 74 | + FMenuItemVsCodeIntegration.Name := TC4DConsts.MENU_IDE_VSCODE_INTEGRATION_NAME; |
| 75 | + FMenuItemVsCodeIntegration.Caption := TC4DConsts.MENU_IDE_VSCODE_INTEGRATION_CAPTION; |
| 76 | + FMenuItemVsCodeIntegration.ImageIndex := TC4DWizardIDEImageListMain.GetInstance.ImgIndexVsCode; |
| 77 | + FMenuItemC4D.Add(FMenuItemVsCodeIntegration); |
| 78 | +end; |
| 79 | + |
| 80 | +procedure TC4DWizardIDEMainMenuVsCodeIntegration.AddSubMenuItemOpen; |
| 81 | +var |
| 82 | + LMenuItem: TMenuItem; |
| 83 | +begin |
| 84 | + LMenuItem := TMenuItem.Create(FMenuItemVsCodeIntegration); |
| 85 | + LMenuItem.Name := TC4DConsts.MENU_IDE_VSCODE_INTEGRATION_OPEN_NAME; |
| 86 | + LMenuItem.Caption := TC4DConsts.MENU_IDE_VSCODE_INTEGRATION_OPEN_CAPTION; |
| 87 | + LMenuItem.ImageIndex := TC4DWizardIDEImageListMain.GetInstance.ImgIndexVsCode; |
| 88 | + LMenuItem.OnClick := TC4DWizardIDEMainMenuClicks.VsCodeIntegrationOpenInVsCodeClick; |
| 89 | + LMenuItem.ShortCut := TextToShortCut(TC4DWizardUtils.RemoveSpacesAll(Self.GetShortcutOpenInVsCode)); |
| 90 | + FMenuItemVsCodeIntegration.Add(LMenuItem); |
| 91 | +end; |
| 92 | + |
| 93 | +procedure TC4DWizardIDEMainMenuVsCodeIntegration.AddSubMenuInstallDelphiLSP; |
| 94 | +var |
| 95 | + LMenuItem: TMenuItem; |
| 96 | +begin |
| 97 | + LMenuItem := TMenuItem.Create(FMenuItemVsCodeIntegration); |
| 98 | + LMenuItem.Name := TC4DConsts.MENU_IDE_VSCODE_INTEGRATION_INSTALL_DELPHILSP_NAME; |
| 99 | + LMenuItem.Caption := TC4DConsts.MENU_IDE_VSCODE_INTEGRATION_INSTALL_DELPHILSP_CAPTION; |
| 100 | + LMenuItem.ImageIndex := TC4DWizardIDEImageListMain.GetInstance.ImgIndexImport; |
| 101 | + LMenuItem.OnClick := TC4DWizardIDEMainMenuClicks.VsCodeIntegrationInstallDelphiLSPClick; |
| 102 | + FMenuItemVsCodeIntegration.Add(LMenuItem); |
| 103 | +end; |
| 104 | + |
| 105 | +function TC4DWizardIDEMainMenuVsCodeIntegration.GetShortcutOpenInVsCode: string; |
| 106 | +begin |
| 107 | + Result := ''; |
| 108 | + if(C4DWizardSettingsModel.ShortcutVsCodeIntegrationOpenUse)and(not C4DWizardSettingsModel.ShortcutVsCodeIntegrationOpen.Trim.IsEmpty)then |
| 109 | + Result := C4DWizardSettingsModel.ShortcutVsCodeIntegrationOpen.Trim; |
| 110 | +end; |
| 111 | + |
| 112 | +end. |
0 commit comments