mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
feat: expose nativeTheme.shouldUseDarkColorsForSystemIntegratedUI (#46438)
feat: expose shouldUseDarkColorsForSystemIntegratedUI Closes https://github.com/electron/electron/issues/46429. Refs https://github.com/electron/electron/pull/19735. This PR adds a new API `shouldUseDarkColorsForSystemIntegratedUI` to the `nativeTheme` module. This API returns a boolean indicating whether the system is using dark colors for system integrated UI elements. This is useful for applications that want to adapt their UI to match the system theme, especially for those that use system integrated UI elements like the shell theme or taskbar appearance.
This commit is contained in:
@@ -63,6 +63,10 @@ bool NativeTheme::ShouldUseHighContrastColors() {
|
||||
return ui_theme_->UserHasContrastPreference();
|
||||
}
|
||||
|
||||
bool NativeTheme::ShouldUseDarkColorsForSystemIntegratedUI() {
|
||||
return ui_theme_->ShouldUseDarkColorsForSystemIntegratedUI();
|
||||
}
|
||||
|
||||
bool NativeTheme::InForcedColorsMode() {
|
||||
return ui_theme_->InForcedColorsMode();
|
||||
}
|
||||
@@ -109,6 +113,8 @@ gin::ObjectTemplateBuilder NativeTheme::GetObjectTemplateBuilder(
|
||||
&NativeTheme::SetThemeSource)
|
||||
.SetProperty("shouldUseHighContrastColors",
|
||||
&NativeTheme::ShouldUseHighContrastColors)
|
||||
.SetProperty("shouldUseDarkColorsForSystemIntegratedUI",
|
||||
&NativeTheme::ShouldUseDarkColorsForSystemIntegratedUI)
|
||||
.SetProperty("shouldUseInvertedColorScheme",
|
||||
&NativeTheme::ShouldUseInvertedColorScheme)
|
||||
.SetProperty("inForcedColorsMode", &NativeTheme::InForcedColorsMode)
|
||||
|
||||
@@ -48,6 +48,7 @@ class NativeTheme final : public gin::Wrappable<NativeTheme>,
|
||||
ui::NativeTheme::ThemeSource GetThemeSource() const;
|
||||
bool ShouldUseDarkColors();
|
||||
bool ShouldUseHighContrastColors();
|
||||
bool ShouldUseDarkColorsForSystemIntegratedUI();
|
||||
bool ShouldUseInvertedColorScheme();
|
||||
bool InForcedColorsMode();
|
||||
bool GetPrefersReducedTransparency();
|
||||
|
||||
Reference in New Issue
Block a user