mirror of
https://github.com/cookiengineer/audacity
synced 2025-10-14 06:31:15 +02:00
Decide default theme on Windows based on the system theme
wxWidgets provides an easy way to read registry values, apparently. Instead of forcing the user to switch their theme so that it corresponds to the system theme, it'd be a better idea to just do that for them. What this change does not do: If the user changes the system theme after Tenacity is initially configured, the theme won't change. Some additional style-related changes were also made. Signed-off-by: Panagiotis Vasilopoulos <hello@alwayslivid.com>
This commit is contained in:
@@ -62,8 +62,6 @@ can't be.
|
||||
|
||||
#include "Theme.h"
|
||||
|
||||
|
||||
|
||||
#include <wx/wxprec.h>
|
||||
#include <wx/dcclient.h>
|
||||
#include <wx/image.h>
|
||||
@@ -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.
|
||||
//
|
||||
@@ -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,14 +1335,6 @@ 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"),
|
||||
{
|
||||
@@ -1325,6 +1360,5 @@ ChoiceSetting GUITheme{
|
||||
wxT("custom"),
|
||||
}
|
||||
},
|
||||
defaultTheme
|
||||
theTheme.ChooseDefaultTheme()
|
||||
};
|
||||
|
||||
|
@@ -167,6 +167,8 @@ public:
|
||||
public:
|
||||
~Theme(void);
|
||||
public:
|
||||
int ChooseDefaultTheme();
|
||||
int CheckWindowsAppTheme();
|
||||
void EnsureInitialised() override;
|
||||
void RegisterImages();
|
||||
void RegisterColours();
|
||||
|
Reference in New Issue
Block a user