DolphinQt: On Windows, detect whether the system is using a dark theme.

Co-authored-by: FearlessTobi <thm.frey@gmail.com>
This commit is contained in:
Admiral H. Curtiss 2023-07-31 00:27:48 +02:00 committed by Nayla Hanegan
parent badf39a467
commit 1983af9fb1
No known key found for this signature in database
GPG key ID: 3075216CED0DB01D
3 changed files with 31 additions and 1 deletions

View file

@ -2,11 +2,13 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#ifdef _WIN32
#include <cstdio>
#include <string>
#include <vector>
#include <Windows.h>
#include <cstdio>
#include <winrt/Windows.UI.ViewManagement.h>
#endif
#ifdef __linux__
@ -258,6 +260,20 @@ int main(int argc, char* argv[])
DolphinAnalytics::Instance().ReportDolphinStart("qt");
MainWindow win{std::move(boot), static_cast<const char*>(options.get("movie"))};
#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
Settings::Instance().SetCurrentUserStyle(Settings::Instance().GetCurrentUserStyle());
win.Show();