|
1 |
| -import { inject, injectable } from '@theia/core/shared/inversify'; |
| 1 | +import { injectable } from '@theia/core/shared/inversify'; |
2 | 2 | import {
|
3 | 3 | Contribution,
|
4 | 4 | Command,
|
5 | 5 | MenuModelRegistry,
|
6 | 6 | KeybindingRegistry,
|
7 | 7 | } from './contribution';
|
8 |
| -import { ArduinoMenus, PlaceholderMenuNode } from '../menu/arduino-menus'; |
9 |
| -import { |
10 |
| - CommandRegistry, |
11 |
| - DisposableCollection, |
12 |
| - MaybePromise, |
13 |
| - nls, |
14 |
| -} from '@theia/core/lib/common'; |
15 |
| - |
| 8 | +import { ArduinoMenus } from '../menu/arduino-menus'; |
| 9 | +import { CommandRegistry, MaybePromise, nls } from '@theia/core/lib/common'; |
16 | 10 | import { Settings } from '../dialogs/settings/settings';
|
17 |
| -import { MainMenuManager } from '../../common/main-menu-manager'; |
18 | 11 | import debounce = require('lodash.debounce');
|
19 | 12 |
|
20 | 13 | @injectable()
|
21 | 14 | export class InterfaceScale extends Contribution {
|
22 |
| - @inject(MenuModelRegistry) |
23 |
| - private readonly menuRegistry: MenuModelRegistry; |
24 |
| - |
25 |
| - @inject(MainMenuManager) |
26 |
| - private readonly mainMenuManager: MainMenuManager; |
27 |
| - |
28 |
| - private readonly menuActionsDisposables = new DisposableCollection(); |
29 | 15 | private fontScalingEnabled: InterfaceScale.FontScalingEnabled = {
|
30 | 16 | increase: true,
|
31 | 17 | decrease: true,
|
@@ -62,63 +48,22 @@ export class InterfaceScale extends Contribution {
|
62 | 48 | }
|
63 | 49 |
|
64 | 50 | override registerMenus(registry: MenuModelRegistry): void {
|
65 |
| - this.menuActionsDisposables.dispose(); |
66 |
| - const increaseFontSizeMenuAction = { |
| 51 | + registry.registerMenuAction(ArduinoMenus.EDIT__FONT_CONTROL_GROUP, { |
67 | 52 | commandId: InterfaceScale.Commands.INCREASE_FONT_SIZE.id,
|
68 | 53 | label: nls.localize(
|
69 | 54 | 'arduino/editor/increaseFontSize',
|
70 | 55 | 'Increase Font Size'
|
71 | 56 | ),
|
72 | 57 | order: '0',
|
73 |
| - }; |
74 |
| - const decreaseFontSizeMenuAction = { |
| 58 | + }); |
| 59 | + registry.registerMenuAction(ArduinoMenus.EDIT__FONT_CONTROL_GROUP, { |
75 | 60 | commandId: InterfaceScale.Commands.DECREASE_FONT_SIZE.id,
|
76 | 61 | label: nls.localize(
|
77 | 62 | 'arduino/editor/decreaseFontSize',
|
78 | 63 | 'Decrease Font Size'
|
79 | 64 | ),
|
80 | 65 | order: '1',
|
81 |
| - }; |
82 |
| - |
83 |
| - if (this.fontScalingEnabled.increase) { |
84 |
| - this.menuActionsDisposables.push( |
85 |
| - registry.registerMenuAction( |
86 |
| - ArduinoMenus.EDIT__FONT_CONTROL_GROUP, |
87 |
| - increaseFontSizeMenuAction |
88 |
| - ) |
89 |
| - ); |
90 |
| - } else { |
91 |
| - this.menuActionsDisposables.push( |
92 |
| - registry.registerMenuNode( |
93 |
| - ArduinoMenus.EDIT__FONT_CONTROL_GROUP, |
94 |
| - new PlaceholderMenuNode( |
95 |
| - ArduinoMenus.EDIT__FONT_CONTROL_GROUP, |
96 |
| - increaseFontSizeMenuAction.label, |
97 |
| - { order: increaseFontSizeMenuAction.order } |
98 |
| - ) |
99 |
| - ) |
100 |
| - ); |
101 |
| - } |
102 |
| - if (this.fontScalingEnabled.decrease) { |
103 |
| - this.menuActionsDisposables.push( |
104 |
| - this.menuRegistry.registerMenuAction( |
105 |
| - ArduinoMenus.EDIT__FONT_CONTROL_GROUP, |
106 |
| - decreaseFontSizeMenuAction |
107 |
| - ) |
108 |
| - ); |
109 |
| - } else { |
110 |
| - this.menuActionsDisposables.push( |
111 |
| - this.menuRegistry.registerMenuNode( |
112 |
| - ArduinoMenus.EDIT__FONT_CONTROL_GROUP, |
113 |
| - new PlaceholderMenuNode( |
114 |
| - ArduinoMenus.EDIT__FONT_CONTROL_GROUP, |
115 |
| - decreaseFontSizeMenuAction.label, |
116 |
| - { order: decreaseFontSizeMenuAction.order } |
117 |
| - ) |
118 |
| - ) |
119 |
| - ); |
120 |
| - } |
121 |
| - this.mainMenuManager.update(); |
| 66 | + }); |
122 | 67 | }
|
123 | 68 |
|
124 | 69 | private updateFontScalingEnabled(): void {
|
@@ -153,7 +98,7 @@ export class InterfaceScale extends Contribution {
|
153 | 98 | );
|
154 | 99 | if (isChanged) {
|
155 | 100 | this.fontScalingEnabled = fontScalingEnabled;
|
156 |
| - this.registerMenus(this.menuRegistry); |
| 101 | + this.menuManager.update(); |
157 | 102 | }
|
158 | 103 | }
|
159 | 104 |
|
|
0 commit comments