mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-07-18 16:56:33 +00:00
Live change of theme from Preferences dropdown (#1296)
This commit is contained in:
parent
54db9bbce8
commit
aebec0f942
@ -201,12 +201,7 @@ export class SettingsComponent extends React.Component<
|
|||||||
<div className="flex-line">
|
<div className="flex-line">
|
||||||
<select
|
<select
|
||||||
className="theia-select"
|
className="theia-select"
|
||||||
value={
|
value={ThemeService.get().getCurrentTheme().label}
|
||||||
ThemeService.get()
|
|
||||||
.getThemes()
|
|
||||||
.find(({ id }) => id === this.state.themeId)?.label ||
|
|
||||||
nls.localize('arduino/common/unknown', 'Unknown')
|
|
||||||
}
|
|
||||||
onChange={this.themeDidChange}
|
onChange={this.themeDidChange}
|
||||||
>
|
>
|
||||||
{ThemeService.get()
|
{ThemeService.get()
|
||||||
@ -591,6 +586,9 @@ export class SettingsComponent extends React.Component<
|
|||||||
const theme = ThemeService.get().getThemes()[selectedIndex];
|
const theme = ThemeService.get().getThemes()[selectedIndex];
|
||||||
if (theme) {
|
if (theme) {
|
||||||
this.setState({ themeId: theme.id });
|
this.setState({ themeId: theme.id });
|
||||||
|
if (ThemeService.get().getCurrentTheme().id !== theme.id) {
|
||||||
|
ThemeService.get().setCurrentTheme(theme.id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ import { SettingsComponent } from './settings-component';
|
|||||||
import { AsyncLocalizationProvider } from '@theia/core/lib/common/i18n/localization';
|
import { AsyncLocalizationProvider } from '@theia/core/lib/common/i18n/localization';
|
||||||
import { AdditionalUrls } from '../../../common/protocol';
|
import { AdditionalUrls } from '../../../common/protocol';
|
||||||
import { AbstractDialog } from '../../theia/dialogs/dialogs';
|
import { AbstractDialog } from '../../theia/dialogs/dialogs';
|
||||||
|
import { ThemeService } from '@theia/core/lib/browser/theming';
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export class SettingsWidget extends ReactWidget {
|
export class SettingsWidget extends ReactWidget {
|
||||||
@ -118,6 +119,17 @@ export class SettingsDialog extends AbstractDialog<Promise<Settings>> {
|
|||||||
|
|
||||||
this.widget.activate();
|
this.widget.activate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override async open(): Promise<Promise<Settings> | undefined> {
|
||||||
|
const themeIdBeforeOpen = ThemeService.get().getCurrentTheme().id;
|
||||||
|
const result = await super.open();
|
||||||
|
if (!result) {
|
||||||
|
if (ThemeService.get().getCurrentTheme().id !== themeIdBeforeOpen) {
|
||||||
|
ThemeService.get().setCurrentTheme(themeIdBeforeOpen);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class AdditionalUrlsDialog extends AbstractDialog<string[]> {
|
export class AdditionalUrlsDialog extends AbstractDialog<string[]> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user