Skip to content
This repository was archived by the owner on Dec 18, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 70 additions & 36 deletions src/Theme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ can't be.

#include "Theme.h"



#include <wx/wxprec.h>
#include <wx/dcclient.h>
#include <wx/image.h>
Expand All @@ -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 <wx/msw/registry.h>
#endif

// JKC: First get the MAC specific images.
// As we've disabled USE_AQUA_THEME, we need to name each file we use.
//
Expand Down Expand Up @@ -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()
{
Expand Down Expand Up @@ -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()
};

2 changes: 2 additions & 0 deletions src/Theme.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ class TENACITY_DLL_API Theme final : public ThemeBase
public:
~Theme(void);
public:
int ChooseDefaultTheme();
int CheckWindowsAppTheme();
void EnsureInitialised() override;
void RegisterImages();
void RegisterColours();
Expand Down