diff --git a/src/vs/platform/theme/electron-main/themeMainService.ts b/src/vs/platform/theme/electron-main/themeMainService.ts index 1b9511f46cb149..f3883e61ab0d12 100644 --- a/src/vs/platform/theme/electron-main/themeMainService.ts +++ b/src/vs/platform/theme/electron-main/themeMainService.ts @@ -22,6 +22,8 @@ const THEME_STORAGE_KEY = 'theme'; const THEME_BG_STORAGE_KEY = 'themeBackground'; const THEME_WINDOW_SPLASH = 'windowSplash'; +const SYSTEM_COLOR_THEME = 'window.systemColorTheme'; + export const IThemeMainService = createDecorator('themeMainService'); export interface IThemeMainService { @@ -50,7 +52,7 @@ export class ThemeMainService extends Disposable implements IThemeMainService { // System Theme this._register(this.configurationService.onDidChangeConfiguration(e => { - if (e.affectsConfiguration('window.systemColorTheme')) { + if (e.affectsConfiguration(SYSTEM_COLOR_THEME)) { this.updateSystemColorTheme(); } })); @@ -61,7 +63,7 @@ export class ThemeMainService extends Disposable implements IThemeMainService { } private updateSystemColorTheme(): void { - switch (this.configurationService.getValue<'default' | 'auto' | 'light' | 'dark'>('window.systemColorTheme')) { + switch (this.configurationService.getValue<'default' | 'auto' | 'light' | 'dark'>(SYSTEM_COLOR_THEME)) { case 'dark': nativeTheme.themeSource = 'dark'; break; diff --git a/src/vs/workbench/contrib/themes/browser/themes.contribution.ts b/src/vs/workbench/contrib/themes/browser/themes.contribution.ts index ea5dbe2d820eea..d44b1da44df4e2 100644 --- a/src/vs/workbench/contrib/themes/browser/themes.contribution.ts +++ b/src/vs/workbench/contrib/themes/browser/themes.contribution.ts @@ -423,14 +423,14 @@ registerAction2(class extends Action2 { }); } - private getTitle(colorScheme: ColorScheme | undefined): string | undefined { + private getTitle(colorScheme: ColorScheme | undefined): string { switch (colorScheme) { - case ColorScheme.DARK: return localize('themes.selectTheme.darkScheme', "Select Color Theme for Dark Mode"); - case ColorScheme.LIGHT: return localize('themes.selectTheme.lightScheme', "Select Color Theme for Light Mode"); + case ColorScheme.DARK: return localize('themes.selectTheme.darkScheme', "Select Color Theme for Dark OS System Theme"); + case ColorScheme.LIGHT: return localize('themes.selectTheme.lightScheme', "Select Color Theme for Light OS System Theme"); case ColorScheme.HIGH_CONTRAST_DARK: return localize('themes.selectTheme.darkHC', "Select Color Theme for Dark High Contrast Mode"); case ColorScheme.HIGH_CONTRAST_LIGHT: return localize('themes.selectTheme.lightHC', "Select Color Theme for Light High Contrast Mode"); default: - return undefined; + return localize('themes.selectTheme.default', "Select Color Theme for all OS System Themes"); } } @@ -443,15 +443,15 @@ registerAction2(class extends Action2 { let modeConfigureToggle; if (preferredColorScheme) { modeConfigureToggle = new Toggle({ - title: 'Automatic Mode Switching is Enabled. Click to configure.', + title: localize('themes.configure.switchingEnabled', 'Configure themes for other OS system themes.'), icon: Codicon.colorMode, isChecked: false, ...defaultToggleStyles }); } else { modeConfigureToggle = new Toggle({ - title: 'Click to configure automatic mode switching.', - icon: Codicon.gear, + title: localize('themes.configure.switchingDisabled', 'Configure themes switching based on the OS system theme.'), + icon: Codicon.colorMode, isChecked: false, ...defaultToggleStyles }); @@ -460,7 +460,7 @@ registerAction2(class extends Action2 { const options = { installMessage: localize('installColorThemes', "Install Additional Color Themes..."), browseMessage: '$(plus) ' + localize('browseColorThemes', "Browse Additional Color Themes..."), - placeholderMessage: this.getTitle(preferredColorScheme) ?? 'Select Color Theme (Mode Switching Disabled)', + placeholderMessage: this.getTitle(preferredColorScheme), marketplaceTag: 'category:themes', toggles: [modeConfigureToggle], onToggle: async (toggle, picker) => { diff --git a/src/vs/workbench/services/themes/browser/workbenchThemeService.ts b/src/vs/workbench/services/themes/browser/workbenchThemeService.ts index 16c115223e0f1e..e31472e7dade33 100644 --- a/src/vs/workbench/services/themes/browser/workbenchThemeService.ts +++ b/src/vs/workbench/services/themes/browser/workbenchThemeService.ts @@ -254,6 +254,7 @@ export class WorkbenchThemeService extends Disposable implements IWorkbenchTheme || e.affectsConfiguration(ThemeSettings.PREFERRED_HC_LIGHT_THEME) || e.affectsConfiguration(ThemeSettings.DETECT_COLOR_SCHEME) || e.affectsConfiguration(ThemeSettings.DETECT_HC) + || e.affectsConfiguration(ThemeSettings.SYSTEM_COLOR_THEME) ) { this.restoreColorTheme(); } diff --git a/src/vs/workbench/services/themes/common/themeConfiguration.ts b/src/vs/workbench/services/themes/common/themeConfiguration.ts index e02375efbb8f0b..2eae6094e0116c 100644 --- a/src/vs/workbench/services/themes/common/themeConfiguration.ts +++ b/src/vs/workbench/services/themes/common/themeConfiguration.ts @@ -12,7 +12,7 @@ import { IJSONSchema } from 'vs/base/common/jsonSchema'; import { textmateColorsSchemaId, textmateColorGroupSchemaId } from 'vs/workbench/services/themes/common/colorThemeSchema'; import { workbenchColorsSchemaId } from 'vs/platform/theme/common/colorRegistry'; import { tokenStylingSchemaId } from 'vs/platform/theme/common/tokenClassificationRegistry'; -import { ThemeSettings, IWorkbenchColorTheme, IWorkbenchFileIconTheme, IColorCustomizations, ITokenColorCustomizations, IWorkbenchProductIconTheme, ISemanticTokenColorCustomizations, ThemeSettingTarget, ThemeSettingDefaults } from 'vs/workbench/services/themes/common/workbenchThemeService'; +import { ThemeSettings, IWorkbenchColorTheme, IWorkbenchFileIconTheme, IColorCustomizations, ITokenColorCustomizations, IWorkbenchProductIconTheme, ISemanticTokenColorCustomizations, ThemeSettingTarget, ThemeSettingDefaults, ENABLE_SYSTEM_COLOR_SCHEME_SETTING } from 'vs/workbench/services/themes/common/workbenchThemeService'; import { IConfigurationService, ConfigurationTarget } from 'vs/platform/configuration/common/configuration'; import { isWeb } from 'vs/base/common/platform'; import { ColorScheme } from 'vs/platform/theme/common/theme'; @@ -25,7 +25,7 @@ const colorThemeSettingEnum: string[] = []; const colorThemeSettingEnumItemLabels: string[] = []; const colorThemeSettingEnumDescriptions: string[] = []; -function formatSettingAsLink(str: string) { +export function formatSettingAsLink(str: string) { return `\`#${str}#\``; } @@ -33,7 +33,7 @@ export const COLOR_THEME_CONFIGURATION_SETTINGS_TAG = 'colorThemeConfiguration'; const colorThemeSettingSchema: IConfigurationPropertySchema = { type: 'string', - description: nls.localize({ key: 'colorTheme', comment: ['{0} will become a link to another setting.'] }, "Specifies the color theme used in the workbench if {0} is not enabled.", formatSettingAsLink(ThemeSettings.DETECT_COLOR_SCHEME)), + markdownDescription: nls.localize({ key: 'colorTheme', comment: ['{0} will become a link to another setting.'] }, "Specifies the color theme used in the workbench when {0} is not enabled.", formatSettingAsLink(ThemeSettings.DETECT_COLOR_SCHEME)), default: isWeb ? ThemeSettingDefaults.COLOR_THEME_LIGHT : ThemeSettingDefaults.COLOR_THEME_DARK, tags: [COLOR_THEME_CONFIGURATION_SETTINGS_TAG], enum: colorThemeSettingEnum, @@ -43,7 +43,7 @@ const colorThemeSettingSchema: IConfigurationPropertySchema = { }; const preferredDarkThemeSettingSchema: IConfigurationPropertySchema = { type: 'string', // - markdownDescription: nls.localize({ key: 'preferredDarkColorTheme', comment: ['{0} will become a link to another setting.'] }, 'Specifies the color theme for dark OS appearance when {0} is enabled.', formatSettingAsLink(ThemeSettings.DETECT_COLOR_SCHEME)), + markdownDescription: nls.localize({ key: 'preferredDarkColorTheme', comment: ['{0} will become a link to another setting.'] }, 'Specifies the color theme when the system color is dark and {0} is enabled.', formatSettingAsLink(ThemeSettings.DETECT_COLOR_SCHEME)), default: ThemeSettingDefaults.COLOR_THEME_DARK, tags: [COLOR_THEME_CONFIGURATION_SETTINGS_TAG], enum: colorThemeSettingEnum, @@ -53,7 +53,7 @@ const preferredDarkThemeSettingSchema: IConfigurationPropertySchema = { }; const preferredLightThemeSettingSchema: IConfigurationPropertySchema = { type: 'string', - markdownDescription: nls.localize({ key: 'preferredLightColorTheme', comment: ['{0} will become a link to another setting.'] }, 'Specifies the color theme for light OS appearance when {0} is enabled.', formatSettingAsLink(ThemeSettings.DETECT_COLOR_SCHEME)), + markdownDescription: nls.localize({ key: 'preferredLightColorTheme', comment: ['{0} will become a link to another setting.'] }, 'Specifies the color theme when the system color is light and {0} is enabled.', formatSettingAsLink(ThemeSettings.DETECT_COLOR_SCHEME)), default: ThemeSettingDefaults.COLOR_THEME_LIGHT, tags: [COLOR_THEME_CONFIGURATION_SETTINGS_TAG], enum: colorThemeSettingEnum, @@ -63,7 +63,7 @@ const preferredLightThemeSettingSchema: IConfigurationPropertySchema = { }; const preferredHCDarkThemeSettingSchema: IConfigurationPropertySchema = { type: 'string', - markdownDescription: nls.localize({ key: 'preferredHCDarkColorTheme', comment: ['{0} will become a link to another setting.'] }, 'Specifies the color theme used in high contrast dark mode when {0} is enabled.', formatSettingAsLink(ThemeSettings.DETECT_HC)), + markdownDescription: nls.localize({ key: 'preferredHCDarkColorTheme', comment: ['{0} will become a link to another setting.'] }, 'Specifies the color theme when in high contrast dark mode and {0} is enabled.', formatSettingAsLink(ThemeSettings.DETECT_HC)), default: ThemeSettingDefaults.COLOR_THEME_HC_DARK, tags: [COLOR_THEME_CONFIGURATION_SETTINGS_TAG], enum: colorThemeSettingEnum, @@ -73,7 +73,7 @@ const preferredHCDarkThemeSettingSchema: IConfigurationPropertySchema = { }; const preferredHCLightThemeSettingSchema: IConfigurationPropertySchema = { type: 'string', - markdownDescription: nls.localize({ key: 'preferredHCLightColorTheme', comment: ['{0} will become a link to another setting.'] }, 'Specifies the color theme used in high contrast light mode when {0} is enabled.', formatSettingAsLink(ThemeSettings.DETECT_HC)), + markdownDescription: nls.localize({ key: 'preferredHCLightColorTheme', comment: ['{0} will become a link to another setting.'] }, 'Specifies the color theme when in high contrast light mode and {0} is enabled.', formatSettingAsLink(ThemeSettings.DETECT_HC)), default: ThemeSettingDefaults.COLOR_THEME_HC_LIGHT, tags: [COLOR_THEME_CONFIGURATION_SETTINGS_TAG], enum: colorThemeSettingEnum, @@ -83,7 +83,10 @@ const preferredHCLightThemeSettingSchema: IConfigurationPropertySchema = { }; const detectColorSchemeSettingSchema: IConfigurationPropertySchema = { type: 'boolean', - markdownDescription: nls.localize({ key: 'detectColorScheme', comment: ['{0} and {1} will become links to other settings.'] }, 'If set, automatically switch to the preferred color theme based on the OS color mode. If the OS mode is dark, the theme specified at {0} is used, for light {1}.', formatSettingAsLink(ThemeSettings.PREFERRED_DARK_THEME), formatSettingAsLink(ThemeSettings.PREFERRED_LIGHT_THEME)), + markdownDescription: + nls.localize({ key: 'detectColorScheme', comment: ['{0} and {1} will become links to other settings.'] }, 'If enabled, will automatically select a color theme based on the OS system color. If the OS system color is dark, the theme specified at {0} is used, else {1}.', formatSettingAsLink(ThemeSettings.PREFERRED_DARK_THEME), formatSettingAsLink(ThemeSettings.PREFERRED_LIGHT_THEME)) + + (ENABLE_SYSTEM_COLOR_SCHEME_SETTING ? nls.localize({ key: 'detectColorSchemeSys', comment: ['{0} will become a link to another setting.'] }, '\n\nThis setting is ignored if {0} is configured.', formatSettingAsLink(ThemeSettings.SYSTEM_COLOR_THEME)) : ''), + default: false, tags: [COLOR_THEME_CONFIGURATION_SETTINGS_TAG], }; @@ -313,7 +316,7 @@ export class ThemeConfiguration { if (this.configurationService.getValue(ThemeSettings.DETECT_HC) && this.hostColorService.highContrast) { return this.hostColorService.dark ? ColorScheme.HIGH_CONTRAST_DARK : ColorScheme.HIGH_CONTRAST_LIGHT; } - if (this.configurationService.getValue(ThemeSettings.DETECT_COLOR_SCHEME)) { + if (this.configurationService.getValue(ThemeSettings.DETECT_COLOR_SCHEME) && (!ENABLE_SYSTEM_COLOR_SCHEME_SETTING || this.configurationService.getValue(ThemeSettings.SYSTEM_COLOR_THEME) === 'default')) { return this.hostColorService.dark ? ColorScheme.DARK : ColorScheme.LIGHT; } return undefined; diff --git a/src/vs/workbench/services/themes/common/workbenchThemeService.ts b/src/vs/workbench/services/themes/common/workbenchThemeService.ts index ae489d7fdb4f1b..75e91502e5d23a 100644 --- a/src/vs/workbench/services/themes/common/workbenchThemeService.ts +++ b/src/vs/workbench/services/themes/common/workbenchThemeService.ts @@ -11,6 +11,7 @@ import { ConfigurationTarget } from 'vs/platform/configuration/common/configurat import { isBoolean, isString } from 'vs/base/common/types'; import { IconContribution, IconDefinition } from 'vs/platform/theme/common/iconRegistry'; import { ColorScheme } from 'vs/platform/theme/common/theme'; +import { isLinux } from 'vs/base/common/platform'; export const IWorkbenchThemeService = refineServiceDecorator(IThemeService); @@ -38,9 +39,13 @@ export enum ThemeSettings { PREFERRED_HC_DARK_THEME = 'workbench.preferredHighContrastColorTheme', /* id kept for compatibility reasons */ PREFERRED_HC_LIGHT_THEME = 'workbench.preferredHighContrastLightColorTheme', DETECT_COLOR_SCHEME = 'window.autoDetectColorScheme', - DETECT_HC = 'window.autoDetectHighContrast' + DETECT_HC = 'window.autoDetectHighContrast', + + SYSTEM_COLOR_THEME = 'window.systemColorTheme' } +export const ENABLE_SYSTEM_COLOR_SCHEME_SETTING = !isLinux; + export enum ThemeSettingDefaults { COLOR_THEME_DARK = 'Default Dark Modern', COLOR_THEME_LIGHT = 'Default Light Modern', diff --git a/src/vs/workbench/services/themes/electron-sandbox/themes.contribution.ts b/src/vs/workbench/services/themes/electron-sandbox/themes.contribution.ts index 9589110363f81e..c72665de49a3db 100644 --- a/src/vs/workbench/services/themes/electron-sandbox/themes.contribution.ts +++ b/src/vs/workbench/services/themes/electron-sandbox/themes.contribution.ts @@ -6,24 +6,26 @@ import { localize } from 'vs/nls'; import { Registry } from 'vs/platform/registry/common/platform'; import { IConfigurationRegistry, Extensions as ConfigurationExtensions, ConfigurationScope } from 'vs/platform/configuration/common/configurationRegistry'; -import { isLinux } from 'vs/base/common/platform'; +import { ENABLE_SYSTEM_COLOR_SCHEME_SETTING, ThemeSettings } from 'vs/workbench/services/themes/common/workbenchThemeService'; +import { COLOR_THEME_CONFIGURATION_SETTINGS_TAG, formatSettingAsLink } from 'vs/workbench/services/themes/common/themeConfiguration'; const configurationRegistry = Registry.as(ConfigurationExtensions.Configuration); configurationRegistry.registerConfiguration({ - 'properties': { - 'window.systemColorTheme': { - 'type': 'string', - 'enum': ['default', 'auto', 'light', 'dark'], - 'enumDescriptions': [ + properties: { + [ThemeSettings.SYSTEM_COLOR_THEME]: { + type: 'string', + enum: ['default', 'matchColorTheme', 'light', 'dark'], + enumDescriptions: [ localize('window.systemColorTheme.default', "System color theme matches the configured OS theme."), - localize('window.systemColorTheme.auto', "Enforce a light system color theme when a light workbench color theme is configured and the same for configured dark workbench color themes."), + localize('window.systemColorTheme.matchColorTheme', "Enforce a light system color theme when a light workbench color theme is configured and the same for configured dark workbench color themes."), localize('window.systemColorTheme.light', "Enforce a light system color theme."), localize('window.systemColorTheme.dark', "Enforce a dark system color theme."), ], - 'markdownDescription': localize('window.systemColorTheme', "The system color theme applies to native UI elements such as native dialogs, menus and title bar. Even if your OS is configured in light appearance mode, you can select a dark system color theme for the window. You can also configure to automatically adjust based on the `#workbench.colorTheme#` setting."), - 'default': 'default', - 'included': !isLinux, // not supported on Linux (https://github.com/electron/electron/issues/28887) - 'scope': ConfigurationScope.APPLICATION + markdownDescription: localize({ key: 'window.systemColorTheme', comment: ['{0} and {1} will become links to other settings.'] }, "Overrides the system color theme that is used for native UI elements such as native dialogs, menus and title bar. Even if your OS is configured in light appearance mode, you can select a dark system color theme for the window. You can also configure to automatically adjust based on the {0} setting. Note: Using this setting will disable {1}", formatSettingAsLink(ThemeSettings.COLOR_THEME), formatSettingAsLink(ThemeSettings.DETECT_COLOR_SCHEME)), + default: 'default', + included: ENABLE_SYSTEM_COLOR_SCHEME_SETTING, + scope: ConfigurationScope.APPLICATION, + tags: [COLOR_THEME_CONFIGURATION_SETTINGS_TAG], } } });