mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-06-14 08:06:36 +00:00
fix: Preferences
menu enablement defect
Manually update the menus when executing the command. Also disabled the menu when the settings dialog is opened. closes #1735 Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
This commit is contained in:
parent
32f0426f01
commit
ed8ed15168
@ -127,7 +127,7 @@ import { PreferencesContribution as TheiaPreferencesContribution } from '@theia/
|
|||||||
import { PreferencesContribution } from './theia/preferences/preferences-contribution';
|
import { PreferencesContribution } from './theia/preferences/preferences-contribution';
|
||||||
import { QuitApp } from './contributions/quit-app';
|
import { QuitApp } from './contributions/quit-app';
|
||||||
import { SketchControl } from './contributions/sketch-control';
|
import { SketchControl } from './contributions/sketch-control';
|
||||||
import { Settings } from './contributions/settings';
|
import { OpenSettings } from './contributions/open-settings';
|
||||||
import { WorkspaceCommandContribution } from './theia/workspace/workspace-commands';
|
import { WorkspaceCommandContribution } from './theia/workspace/workspace-commands';
|
||||||
import { WorkspaceDeleteHandler as TheiaWorkspaceDeleteHandler } from '@theia/workspace/lib/browser/workspace-delete-handler';
|
import { WorkspaceDeleteHandler as TheiaWorkspaceDeleteHandler } from '@theia/workspace/lib/browser/workspace-delete-handler';
|
||||||
import { WorkspaceDeleteHandler } from './theia/workspace/workspace-delete-handler';
|
import { WorkspaceDeleteHandler } from './theia/workspace/workspace-delete-handler';
|
||||||
@ -691,7 +691,7 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
|||||||
Contribution.configure(bind, EditContributions);
|
Contribution.configure(bind, EditContributions);
|
||||||
Contribution.configure(bind, QuitApp);
|
Contribution.configure(bind, QuitApp);
|
||||||
Contribution.configure(bind, SketchControl);
|
Contribution.configure(bind, SketchControl);
|
||||||
Contribution.configure(bind, Settings);
|
Contribution.configure(bind, OpenSettings);
|
||||||
Contribution.configure(bind, BurnBootloader);
|
Contribution.configure(bind, BurnBootloader);
|
||||||
Contribution.configure(bind, BuiltInExamples);
|
Contribution.configure(bind, BuiltInExamples);
|
||||||
Contribution.configure(bind, LibraryExamples);
|
Contribution.configure(bind, LibraryExamples);
|
||||||
|
@ -1,32 +1,37 @@
|
|||||||
|
import { nls } from '@theia/core/lib/common/nls';
|
||||||
import { inject, injectable } from '@theia/core/shared/inversify';
|
import { inject, injectable } from '@theia/core/shared/inversify';
|
||||||
|
import { MainMenuManager } from '../../common/main-menu-manager';
|
||||||
|
import type { Settings } from '../dialogs/settings/settings';
|
||||||
|
import { SettingsDialog } from '../dialogs/settings/settings-dialog';
|
||||||
|
import { ArduinoMenus } from '../menu/arduino-menus';
|
||||||
import {
|
import {
|
||||||
Command,
|
Command,
|
||||||
MenuModelRegistry,
|
|
||||||
CommandRegistry,
|
CommandRegistry,
|
||||||
SketchContribution,
|
|
||||||
KeybindingRegistry,
|
KeybindingRegistry,
|
||||||
|
MenuModelRegistry,
|
||||||
|
SketchContribution,
|
||||||
} from './contribution';
|
} from './contribution';
|
||||||
import { ArduinoMenus } from '../menu/arduino-menus';
|
|
||||||
import { Settings as Preferences } from '../dialogs/settings/settings';
|
|
||||||
import { SettingsDialog } from '../dialogs/settings/settings-dialog';
|
|
||||||
import { nls } from '@theia/core/lib/common';
|
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export class Settings extends SketchContribution {
|
export class OpenSettings extends SketchContribution {
|
||||||
@inject(SettingsDialog)
|
@inject(SettingsDialog)
|
||||||
protected readonly settingsDialog: SettingsDialog;
|
private readonly settingsDialog: SettingsDialog;
|
||||||
|
@inject(MainMenuManager)
|
||||||
|
private readonly menuManager: MainMenuManager;
|
||||||
|
|
||||||
protected settingsOpened = false;
|
private settingsOpened = false;
|
||||||
|
|
||||||
override registerCommands(registry: CommandRegistry): void {
|
override registerCommands(registry: CommandRegistry): void {
|
||||||
registry.registerCommand(Settings.Commands.OPEN, {
|
registry.registerCommand(OpenSettings.Commands.OPEN, {
|
||||||
execute: async () => {
|
execute: async () => {
|
||||||
let settings: Preferences | undefined = undefined;
|
let settings: Settings | undefined = undefined;
|
||||||
try {
|
try {
|
||||||
this.settingsOpened = true;
|
this.settingsOpened = true;
|
||||||
|
this.menuManager.update();
|
||||||
settings = await this.settingsDialog.open();
|
settings = await this.settingsDialog.open();
|
||||||
} finally {
|
} finally {
|
||||||
this.settingsOpened = false;
|
this.settingsOpened = false;
|
||||||
|
this.menuManager.update();
|
||||||
}
|
}
|
||||||
if (settings) {
|
if (settings) {
|
||||||
await this.settingsService.update(settings);
|
await this.settingsService.update(settings);
|
||||||
@ -41,7 +46,7 @@ export class Settings extends SketchContribution {
|
|||||||
|
|
||||||
override registerMenus(registry: MenuModelRegistry): void {
|
override registerMenus(registry: MenuModelRegistry): void {
|
||||||
registry.registerMenuAction(ArduinoMenus.FILE__PREFERENCES_GROUP, {
|
registry.registerMenuAction(ArduinoMenus.FILE__PREFERENCES_GROUP, {
|
||||||
commandId: Settings.Commands.OPEN.id,
|
commandId: OpenSettings.Commands.OPEN.id,
|
||||||
label:
|
label:
|
||||||
nls.localize(
|
nls.localize(
|
||||||
'vscode/preferences.contribution/preferences',
|
'vscode/preferences.contribution/preferences',
|
||||||
@ -57,13 +62,13 @@ export class Settings extends SketchContribution {
|
|||||||
|
|
||||||
override registerKeybindings(registry: KeybindingRegistry): void {
|
override registerKeybindings(registry: KeybindingRegistry): void {
|
||||||
registry.registerKeybinding({
|
registry.registerKeybinding({
|
||||||
command: Settings.Commands.OPEN.id,
|
command: OpenSettings.Commands.OPEN.id,
|
||||||
keybinding: 'CtrlCmd+,',
|
keybinding: 'CtrlCmd+,',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export namespace Settings {
|
export namespace OpenSettings {
|
||||||
export namespace Commands {
|
export namespace Commands {
|
||||||
export const OPEN: Command = {
|
export const OPEN: Command = {
|
||||||
id: 'arduino-settings-open',
|
id: 'arduino-settings-open',
|
Loading…
x
Reference in New Issue
Block a user