Skip to content

Commit b4d382f

Browse files
committed
move settings from sidebar to arduino pref panel
1 parent ac50205 commit b4d382f

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

arduino-ide-extension/src/browser/arduino-frontend-contribution.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ export class ArduinoFrontendContribution implements FrontendApplicationContribut
222222
webContents.setZoomLevel(event.newValue || 0);
223223
}
224224
});
225+
app.shell.leftPanelHandler.removeMenu('settings-menu');
225226
}
226227

227228
protected languageServerFqbn?: string;

arduino-ide-extension/src/browser/contributions/settings.ts

+16
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@ export class Settings extends SketchContribution {
3030
},
3131
isEnabled: () => !this.settingsOpened
3232
});
33+
registry.registerCommand(Settings.Commands.CLOSE, {
34+
execute: async () => {
35+
try {
36+
this.settingsDialog.close();
37+
} finally {
38+
this.settingsOpened = false;
39+
}
40+
},
41+
isEnabled: () => this.settingsOpened
42+
});
3343
}
3444

3545
registerMenus(registry: MenuModelRegistry): void {
@@ -56,5 +66,11 @@ export namespace Settings {
5666
label: 'Open Preferences...',
5767
category: 'Arduino'
5868
}
69+
70+
export const CLOSE: Command = {
71+
id: 'arduino-settings-close',
72+
label: 'Close Preferences...',
73+
category: 'Arduino'
74+
}
5975
}
6076
}

arduino-ide-extension/src/browser/settings.tsx

+18-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import { FileService } from '@theia/filesystem/lib/browser/file-service';
1313
import { ThemeService } from '@theia/core/lib/browser/theming';
1414
import { MaybePromise } from '@theia/core/lib/common/types';
1515
import { WindowService } from '@theia/core/lib/browser/window/window-service';
16+
import { CommandRegistry } from "@theia/core";
17+
import { CommonCommands } from '@theia/core/lib/browser/common-frontend-contribution';
1618
import { FileDialogService } from '@theia/filesystem/lib/browser/file-dialog/file-dialog-service';
1719
import { DisposableCollection } from '@theia/core/lib/common/disposable';
1820
import { FrontendApplicationStateService } from '@theia/core/lib/browser/frontend-application-state';
@@ -376,9 +378,18 @@ export class SettingsComponent extends React.Component<SettingsComponent.Props,
376378
onChange={this.additionalUrlsDidChange} />
377379
<i className='fa fa-window-restore theia-button shrink' onClick={this.editAdditionalUrlDidClick} />
378380
</div>
381+
382+
<div className='flex-line'>
383+
<button className='theia-button shrink' onClick={this.openExtendedSettings}>Extended Settings</button>
384+
</div>
379385
</div>;
380386
}
381387

388+
protected openExtendedSettings = (e: React.MouseEvent<HTMLElement>) => {
389+
this.props.commands.executeCommand(CommonCommands.OPEN_PREFERENCES.id);
390+
this.props.commands.executeCommand('arduino-settings-close');
391+
}
392+
382393
protected renderNetwork(): React.ReactNode {
383394
return <div className='content noselect'>
384395
<form>
@@ -662,6 +673,7 @@ export namespace SettingsComponent {
662673
readonly fileService: FileService;
663674
readonly fileDialogService: FileDialogService;
664675
readonly windowService: WindowService;
676+
readonly commands: CommandRegistry
665677
}
666678
export interface State extends Settings { }
667679
}
@@ -681,12 +693,17 @@ export class SettingsWidget extends ReactWidget {
681693
@inject(WindowService)
682694
protected readonly windowService: WindowService;
683695

696+
@inject(CommandRegistry)
697+
protected readonly commands: CommandRegistry;
698+
684699
protected render(): React.ReactNode {
685700
return <SettingsComponent
686701
settingsService={this.settingsService}
687702
fileService={this.fileService}
688703
fileDialogService={this.fileDialogService}
689-
windowService={this.windowService} />;
704+
windowService={this.windowService}
705+
commands={this.commands}
706+
/>;
690707
}
691708

692709
}

0 commit comments

Comments
 (0)