summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorAdmiral H. Curtiss <pikachu025@gmail.com>2023-08-01 19:52:36 +0200
committerAdmiral H. Curtiss <pikachu025@gmail.com>2023-08-12 16:54:54 +0200
commitd725aaa5bcb6760522997a3ba43676c88b341d63 (patch)
tree66d6ea998911dc6fb7e81b2658b2189986592916 /Source
parent250d5f55deb0febb9ea94090332bbbbd91d1af5c (diff)
DolphinQt: Set the application palette to a matching one when the Windows dark theme is in use.
Diffstat (limited to 'Source')
-rw-r--r--Source/Core/DolphinQt/Main.cpp1
-rw-r--r--Source/Core/DolphinQt/Settings.cpp34
-rw-r--r--Source/Core/DolphinQt/Settings.h1
3 files changed, 34 insertions, 2 deletions
diff --git a/Source/Core/DolphinQt/Main.cpp b/Source/Core/DolphinQt/Main.cpp
index aa1697c6a7..3cf943b17b 100644
--- a/Source/Core/DolphinQt/Main.cpp
+++ b/Source/Core/DolphinQt/Main.cpp
@@ -246,6 +246,7 @@ int main(int argc, char* argv[])
DolphinAnalytics::Instance().ReportDolphinStart("qt");
MainWindow win{std::move(boot), static_cast<const char*>(options.get("movie"))};
+ Settings::Instance().InitDefaultPalette();
Settings::Instance().UpdateSystemDark();
Settings::Instance().SetCurrentUserStyle(Settings::Instance().GetCurrentUserStyle());
win.Show();
diff --git a/Source/Core/DolphinQt/Settings.cpp b/Source/Core/DolphinQt/Settings.cpp
index e35be9a8ba..3c4461db1c 100644
--- a/Source/Core/DolphinQt/Settings.cpp
+++ b/Source/Core/DolphinQt/Settings.cpp
@@ -4,19 +4,21 @@
#include "DolphinQt/Settings.h"
#include <atomic>
+#include <memory>
#include <QApplication>
+#include <QColor>
#include <QDir>
#include <QFile>
#include <QFileInfo>
#include <QFontDatabase>
+#include <QPalette>
#include <QRadioButton>
#include <QSize>
+#include <QStyle>
#include <QWidget>
#ifdef _WIN32
-#include <memory>
-
#include <fmt/format.h>
#include <winrt/Windows.UI.ViewManagement.h>
@@ -50,6 +52,7 @@
#include "VideoCommon/NetPlayGolfUI.h"
static bool s_system_dark = false;
+static std::unique_ptr<QPalette> s_default_palette;
Settings::Settings()
{
@@ -129,6 +132,11 @@ QString Settings::GetCurrentUserStyle() const
return QFileInfo(GetQSettings().value(QStringLiteral("userstyle/path")).toString()).fileName();
}
+void Settings::InitDefaultPalette()
+{
+ s_default_palette = std::make_unique<QPalette>(qApp->palette());
+}
+
void Settings::UpdateSystemDark()
{
#ifdef _WIN32
@@ -183,6 +191,28 @@ void Settings::SetCurrentUserStyle(const QString& stylesheet_name)
QFile file(QStringLiteral(":/dolphin_dark_win/dark.qss"));
if (file.open(QFile::ReadOnly))
stylesheet_contents = QString::fromUtf8(file.readAll().data());
+
+ QPalette palette = qApp->style()->standardPalette();
+ palette.setColor(QPalette::Window, QColor(32, 32, 32));
+ palette.setColor(QPalette::WindowText, QColor(220, 220, 220));
+ palette.setColor(QPalette::Base, QColor(32, 32, 32));
+ palette.setColor(QPalette::AlternateBase, QColor(48, 48, 48));
+ palette.setColor(QPalette::PlaceholderText, QColor(126, 126, 126));
+ palette.setColor(QPalette::Text, QColor(220, 220, 220));
+ palette.setColor(QPalette::Button, QColor(48, 48, 48));
+ palette.setColor(QPalette::ButtonText, QColor(220, 220, 220));
+ palette.setColor(QPalette::BrightText, QColor(255, 255, 255));
+ palette.setColor(QPalette::Highlight, QColor(0, 120, 215));
+ palette.setColor(QPalette::HighlightedText, QColor(255, 255, 255));
+ palette.setColor(QPalette::Link, QColor(100, 160, 220));
+ palette.setColor(QPalette::LinkVisited, QColor(100, 160, 220));
+ qApp->setPalette(palette);
+ }
+ else
+ {
+ // reset any palette changes that may exist from a previously set dark mode
+ if (s_default_palette)
+ qApp->setPalette(*s_default_palette);
}
}
#endif
diff --git a/Source/Core/DolphinQt/Settings.h b/Source/Core/DolphinQt/Settings.h
index 1e1e4b1d7e..b95b768250 100644
--- a/Source/Core/DolphinQt/Settings.h
+++ b/Source/Core/DolphinQt/Settings.h
@@ -52,6 +52,7 @@ public:
// UI
void SetThemeName(const QString& theme_name);
+ void InitDefaultPalette();
void UpdateSystemDark();
void SetSystemDark(bool dark);
bool IsSystemDark();