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:
parent
f2300d89cc
commit
5d33f2abd1
|
@ -2,11 +2,13 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
#include <cstdio>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#include <cstdio>
|
|
||||||
|
#include <winrt/Windows.UI.ViewManagement.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
|
@ -244,6 +246,20 @@ int main(int argc, char* argv[])
|
||||||
DolphinAnalytics::Instance().ReportDolphinStart("qt");
|
DolphinAnalytics::Instance().ReportDolphinStart("qt");
|
||||||
|
|
||||||
MainWindow win{std::move(boot), static_cast<const char*>(options.get("movie"))};
|
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());
|
Settings::Instance().SetCurrentUserStyle(Settings::Instance().GetCurrentUserStyle());
|
||||||
win.Show();
|
win.Show();
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,8 @@
|
||||||
#include "VideoCommon/NetPlayChatUI.h"
|
#include "VideoCommon/NetPlayChatUI.h"
|
||||||
#include "VideoCommon/NetPlayGolfUI.h"
|
#include "VideoCommon/NetPlayGolfUI.h"
|
||||||
|
|
||||||
|
static bool s_system_dark = false;
|
||||||
|
|
||||||
Settings::Settings()
|
Settings::Settings()
|
||||||
{
|
{
|
||||||
qRegisterMetaType<Core::State>();
|
qRegisterMetaType<Core::State>();
|
||||||
|
@ -125,6 +127,16 @@ QString Settings::GetCurrentUserStyle() const
|
||||||
return QFileInfo(GetQSettings().value(QStringLiteral("userstyle/path")).toString()).fileName();
|
return QFileInfo(GetQSettings().value(QStringLiteral("userstyle/path")).toString()).fileName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Settings::SetSystemDark(bool dark)
|
||||||
|
{
|
||||||
|
s_system_dark = dark;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Settings::IsSystemDark()
|
||||||
|
{
|
||||||
|
return s_system_dark;
|
||||||
|
}
|
||||||
|
|
||||||
// Calling this before the main window has been created breaks the style of some widgets.
|
// Calling this before the main window has been created breaks the style of some widgets.
|
||||||
void Settings::SetCurrentUserStyle(const QString& stylesheet_name)
|
void Settings::SetCurrentUserStyle(const QString& stylesheet_name)
|
||||||
{
|
{
|
||||||
|
|
|
@ -52,6 +52,8 @@ public:
|
||||||
|
|
||||||
// UI
|
// UI
|
||||||
void SetThemeName(const QString& theme_name);
|
void SetThemeName(const QString& theme_name);
|
||||||
|
void SetSystemDark(bool dark);
|
||||||
|
bool IsSystemDark();
|
||||||
void SetCurrentUserStyle(const QString& stylesheet_name);
|
void SetCurrentUserStyle(const QString& stylesheet_name);
|
||||||
QString GetCurrentUserStyle() const;
|
QString GetCurrentUserStyle() const;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue