DolphinQt: Switch dark/light theme when Windows theme changes.

This commit is contained in:
Admiral H. Curtiss 2023-07-31 23:22:53 +02:00
parent e2fb8fab2f
commit 250d5f55de
No known key found for this signature in database
GPG key ID: F051B4C4044F33FB
5 changed files with 49 additions and 16 deletions

View file

@ -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;