diff --git a/src/Theme.cpp b/src/Theme.cpp index 56da2af35..dd4f0f2e2 100644 --- a/src/Theme.cpp +++ b/src/Theme.cpp @@ -62,8 +62,6 @@ can't be. #include "Theme.h" - - #include #include #include @@ -80,6 +78,16 @@ can't be. #include "MemoryX.h" #include "widgets/AudacityMessageBox.h" +#ifdef EXPERIMENTAL_DA +bool useDATheme = true; +#else +bool useDATheme = false; +#endif + +#ifdef __WXMSW__ +#include +#endif + // JKC: First get the MAC specific images. // As we've disabled USE_AQUA_THEME, we need to name each file we use. // @@ -210,6 +218,41 @@ Theme::~Theme(void) { } +#ifdef __WXMSW__ +int Theme::CheckWindowsAppTheme() { + int defaultTheme; + long value; + + wxRegKey key( + wxRegKey::HKCU, + "Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize" + ); + + bool valueAccessed = key.QueryValue("AppsUseLightTheme", &value); + + defaultTheme = 1; // "light" until proven "dark" + + if (valueAccessed == true && value == 0) { + // System uses dark theme + defaultTheme = 2; // "dark" + } + + return defaultTheme; +} +#endif + +int Theme::ChooseDefaultTheme() +{ + if (useDATheme = true) { + return 2; + } + +#ifdef __WXMSW__ + return CheckWindowsAppTheme(); +#else + return 1; +#endif +} void Theme::EnsureInitialised() { @@ -1292,39 +1335,30 @@ void auStaticText::OnPaint(wxPaintEvent & WXUNUSED(evt)) dc.DrawText( GetLabel(), 0,0); } -constexpr int defaultTheme = -#ifdef EXPERIMENTAL_DA - 2 // "dark" -#else - 1 // "light" -#endif -; - ChoiceSetting GUITheme{ - wxT("/GUI/Theme"), - { - ByColumns, - { - /* i18n-hint: describing the "classic" or traditional - appearance of older versions of Audacity */ - XO("Classic") , - /* i18n-hint: Light meaning opposite of dark */ - XO("Light") , - XO("Dark") , - /* i18n-hint: greater difference between foreground and - background colors */ - XO("High Contrast") , - /* i18n-hint: user defined */ - XO("Custom") , - }, - { - wxT("classic") , - wxT("light") , - wxT("dark") , - wxT("high-contrast") , - wxT("custom") , - } - }, - defaultTheme + wxT("/GUI/Theme"), + { + ByColumns, + { + /* i18n-hint: describing the "classic" or traditional + appearance of older versions of Audacity */ + XO("Classic"), + /* i18n-hint: Light meaning opposite of dark */ + XO("Light"), + XO("Dark"), + /* i18n-hint: greater difference between foreground and + background colors */ + XO("High Contrast"), + /* i18n-hint: user defined */ + XO("Custom"), + }, + { + wxT("classic"), + wxT("light"), + wxT("dark"), + wxT("high-contrast"), + wxT("custom"), + } + }, + theTheme.ChooseDefaultTheme() }; - diff --git a/src/Theme.h b/src/Theme.h index ea49902ca..a34161523 100644 --- a/src/Theme.h +++ b/src/Theme.h @@ -167,6 +167,8 @@ public: public: ~Theme(void); public: + int ChooseDefaultTheme(); + int CheckWindowsAppTheme(); void EnsureInitialised() override; void RegisterImages(); void RegisterColours();