mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-06-13 00:58:29 +02:00
DolphinQt: Switch dark/light theme when Windows theme changes.
This commit is contained in:
@ -19,6 +19,8 @@
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include <winrt/Windows.UI.ViewManagement.h>
|
||||
|
||||
#include <QTabBar>
|
||||
#include <QToolButton>
|
||||
#endif
|
||||
@ -127,6 +129,22 @@ QString Settings::GetCurrentUserStyle() const
|
||||
return QFileInfo(GetQSettings().value(QStringLiteral("userstyle/path")).toString()).fileName();
|
||||
}
|
||||
|
||||
void Settings::UpdateSystemDark()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
// Check if the system is set to dark mode so we can set the default theme and window
|
||||
// decorations accordingly.
|
||||
{
|
||||
using namespace winrt::Windows::UI::ViewManagement;
|
||||
const UISettings settings;
|
||||
const auto& color = settings.GetColorValue(UIColorType::Foreground);
|
||||
|
||||
const bool is_system_dark = 5 * color.G + 2 * color.R + color.B > 8 * 128;
|
||||
Settings::Instance().SetSystemDark(is_system_dark);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Settings::SetSystemDark(bool dark)
|
||||
{
|
||||
s_system_dark = dark;
|
||||
|
Reference in New Issue
Block a user