mirror of
https://github.com/cookiengineer/audacity
synced 2025-04-29 23:29:41 +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:
parent
5cb9586107
commit
e1b7073e29
106
src/Theme.cpp
106
src/Theme.cpp
@ -62,8 +62,6 @@ can't be.
|
|||||||
|
|
||||||
#include "Theme.h"
|
#include "Theme.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include <wx/wxprec.h>
|
#include <wx/wxprec.h>
|
||||||
#include <wx/dcclient.h>
|
#include <wx/dcclient.h>
|
||||||
#include <wx/image.h>
|
#include <wx/image.h>
|
||||||
@ -80,6 +78,16 @@ can't be.
|
|||||||
#include "MemoryX.h"
|
#include "MemoryX.h"
|
||||||
#include "widgets/AudacityMessageBox.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.
|
// JKC: First get the MAC specific images.
|
||||||
// As we've disabled USE_AQUA_THEME, we need to name each file we use.
|
// 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()
|
void Theme::EnsureInitialised()
|
||||||
{
|
{
|
||||||
@ -1292,39 +1335,30 @@ void auStaticText::OnPaint(wxPaintEvent & WXUNUSED(evt))
|
|||||||
dc.DrawText( GetLabel(), 0,0);
|
dc.DrawText( GetLabel(), 0,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr int defaultTheme =
|
|
||||||
#ifdef EXPERIMENTAL_DA
|
|
||||||
2 // "dark"
|
|
||||||
#else
|
|
||||||
1 // "light"
|
|
||||||
#endif
|
|
||||||
;
|
|
||||||
|
|
||||||
ChoiceSetting GUITheme{
|
ChoiceSetting GUITheme{
|
||||||
wxT("/GUI/Theme"),
|
wxT("/GUI/Theme"),
|
||||||
{
|
{
|
||||||
ByColumns,
|
ByColumns,
|
||||||
{
|
{
|
||||||
/* i18n-hint: describing the "classic" or traditional
|
/* i18n-hint: describing the "classic" or traditional
|
||||||
appearance of older versions of Audacity */
|
appearance of older versions of Audacity */
|
||||||
XO("Classic") ,
|
XO("Classic"),
|
||||||
/* i18n-hint: Light meaning opposite of dark */
|
/* i18n-hint: Light meaning opposite of dark */
|
||||||
XO("Light") ,
|
XO("Light"),
|
||||||
XO("Dark") ,
|
XO("Dark"),
|
||||||
/* i18n-hint: greater difference between foreground and
|
/* i18n-hint: greater difference between foreground and
|
||||||
background colors */
|
background colors */
|
||||||
XO("High Contrast") ,
|
XO("High Contrast"),
|
||||||
/* i18n-hint: user defined */
|
/* i18n-hint: user defined */
|
||||||
XO("Custom") ,
|
XO("Custom"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
wxT("classic") ,
|
wxT("classic"),
|
||||||
wxT("light") ,
|
wxT("light"),
|
||||||
wxT("dark") ,
|
wxT("dark"),
|
||||||
wxT("high-contrast") ,
|
wxT("high-contrast"),
|
||||||
wxT("custom") ,
|
wxT("custom"),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
defaultTheme
|
theTheme.ChooseDefaultTheme()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -167,6 +167,8 @@ public:
|
|||||||
public:
|
public:
|
||||||
~Theme(void);
|
~Theme(void);
|
||||||
public:
|
public:
|
||||||
|
int ChooseDefaultTheme();
|
||||||
|
int CheckWindowsAppTheme();
|
||||||
void EnsureInitialised() override;
|
void EnsureInitialised() override;
|
||||||
void RegisterImages();
|
void RegisterImages();
|
||||||
void RegisterColours();
|
void RegisterColours();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user