diff options
| author | cristian64 <cristian64@gmail.com> | 2025-09-03 20:58:33 +0100 |
|---|---|---|
| committer | cristian64 <cristian64@gmail.com> | 2025-11-14 19:21:58 +0000 |
| commit | 71e15c2875f36458c8f29ee160f01606967bcd13 (patch) | |
| tree | 03b31e049e8f5cb1842d290f60c008a0df3f1fd2 /Source/Core | |
| parent | ff9b8c4b9c24729be91cccee7aaa4de7cfa87d83 (diff) | |
DolphinQt: Add Fusion-based styles.
Fusion is one of the built-in styles that Qt ships with, and that is
generally supported in all platforms and handles custom color palettes
properly.
The color palettes have been borrowed from the Dolphin Memory Engine
buddy application.
The new styles are:
- **Fusion Light**
- **Fusion Dark Gray**
- **Fusion Dark**
A demo of each style on Windows:
| System | Light | Dark | Fusion Light | Fusion Dark Gray | Fusion Dark |
| ------ | ----- | ---- | ------------ | ---------------- | ----------- |
| <img width="1920" height="1080" alt="Dolphin Emulator System style" src="https://github.com/user-attachments/assets/7f55a19d-d9a1-43d1-a435-1e1d5b29abe2" /> | <img width="1920" height="1080" alt="Dolphin Emulator Light style" src="https://github.com/user-attachments/assets/4c70f2f9-16b8-4777-b72b-55b2dffcd1e4" /> | <img width="1920" height="1080" alt="Dolphin Emulator Dark style" src="https://github.com/user-attachments/assets/5e669477-d2a5-4d19-b2c5-a2ed9bb1e6fe" /> | <img width="1920" height="1080" alt="Dolphin Emulator Light Fusion style" src="https://github.com/user-attachments/assets/b1f95c47-0691-4809-bd74-99e913c17684" /> | <img width="1920" height="1080" alt="Dolphin Emulator Dark Gray Fusion style" src="https://github.com/user-attachments/assets/c9d30aa3-f941-4fc5-806f-d3fbd2cae0cc" /> | <img width="1920" height="1080" alt="Dolphin Emulator Dark Fusion style" src="https://github.com/user-attachments/assets/123d2125-e126-4e8c-aa42-793ded8ffacc" /> |
> [!NOTE]
> Notice that the **Light** and **Dark** styles remain available only on
> Windows due to limitations on how styles in the various platforms
> handle (or mishandle) custom color palettes.
> [!IMPORTANT]
> Due to [`KDE-511547`](https://bugs.kde.org/show_bug.cgi?id=511547),
> after having used Breeze (default style in Plasma systems), top tool
> bars in tools areas will lose their correct background color; a
> restart will be required in order to get the updated color in the main
> window.
>
> UPDATE: The issue has been fixed upstream and should be available in
> KDE Plama 6.5.3 and newer.
Diffstat (limited to 'Source/Core')
| -rw-r--r-- | Source/Core/DolphinQt/Settings.cpp | 167 | ||||
| -rw-r--r-- | Source/Core/DolphinQt/Settings.h | 5 | ||||
| -rw-r--r-- | Source/Core/DolphinQt/Settings/InterfacePane.cpp | 7 |
3 files changed, 171 insertions, 8 deletions
diff --git a/Source/Core/DolphinQt/Settings.cpp b/Source/Core/DolphinQt/Settings.cpp index 33295376f3..76363d8e10 100644 --- a/Source/Core/DolphinQt/Settings.cpp +++ b/Source/Core/DolphinQt/Settings.cpp @@ -160,6 +160,17 @@ bool Settings::IsThemeDark() void Settings::ApplyStyle() { const StyleType style_type = GetStyleType(); + + { + const bool use_fusion{style_type == StyleType::FusionLight || + style_type == StyleType::FusionDarkGray || + style_type == StyleType::FusionDark}; + static const QString s_initial_style_name{QApplication::style()->name()}; + const QString style_name{use_fusion ? QStringLiteral("fusion") : s_initial_style_name}; + if (QApplication::style()->name() != style_name) + QApplication::setStyle(style_name); + } + const QString stylesheet_name = GetUserStyleName(); QString stylesheet_contents; @@ -174,12 +185,155 @@ void Settings::ApplyStyle() stylesheet_contents = QString::fromUtf8(stylesheet.readAll().data()); } + QPalette palette; + + if (style_type == StyleType::FusionLight) + { + palette.setColor(QPalette::All, QPalette::Window, QColor(239, 239, 239)); + palette.setColor(QPalette::Disabled, QPalette::Window, QColor(239, 239, 239)); + palette.setColor(QPalette::All, QPalette::WindowText, QColor(0, 0, 0)); + palette.setColor(QPalette::Disabled, QPalette::WindowText, QColor(190, 190, 190)); + palette.setColor(QPalette::All, QPalette::Base, QColor(255, 255, 255)); + palette.setColor(QPalette::Disabled, QPalette::Base, QColor(239, 239, 239)); + palette.setColor(QPalette::All, QPalette::AlternateBase, QColor(247, 247, 247)); + palette.setColor(QPalette::Disabled, QPalette::AlternateBase, QColor(247, 247, 247)); + palette.setColor(QPalette::All, QPalette::ToolTipBase, QColor(255, 255, 220)); + palette.setColor(QPalette::Disabled, QPalette::ToolTipBase, QColor(255, 255, 220)); + palette.setColor(QPalette::All, QPalette::ToolTipText, QColor(0, 0, 0)); + palette.setColor(QPalette::Disabled, QPalette::ToolTipText, QColor(0, 0, 0)); + palette.setColor(QPalette::All, QPalette::PlaceholderText, QColor(119, 119, 119)); + palette.setColor(QPalette::Disabled, QPalette::PlaceholderText, QColor(119, 119, 119)); + palette.setColor(QPalette::All, QPalette::Text, QColor(0, 0, 0)); + palette.setColor(QPalette::Disabled, QPalette::Text, QColor(190, 190, 190)); + palette.setColor(QPalette::All, QPalette::Button, QColor(239, 239, 239)); + palette.setColor(QPalette::Disabled, QPalette::Button, QColor(239, 239, 239)); + palette.setColor(QPalette::All, QPalette::ButtonText, QColor(0, 0, 0)); + palette.setColor(QPalette::Disabled, QPalette::ButtonText, QColor(190, 190, 190)); + palette.setColor(QPalette::All, QPalette::BrightText, QColor(255, 255, 255)); + palette.setColor(QPalette::Disabled, QPalette::BrightText, QColor(255, 255, 255)); + palette.setColor(QPalette::All, QPalette::Light, QColor(255, 255, 255)); + palette.setColor(QPalette::Disabled, QPalette::Light, QColor(255, 255, 255)); + palette.setColor(QPalette::All, QPalette::Midlight, QColor(202, 202, 202)); + palette.setColor(QPalette::Disabled, QPalette::Midlight, QColor(202, 202, 202)); + palette.setColor(QPalette::All, QPalette::Dark, QColor(159, 159, 159)); + palette.setColor(QPalette::Disabled, QPalette::Dark, QColor(190, 190, 190)); + palette.setColor(QPalette::All, QPalette::Mid, QColor(184, 184, 184)); + palette.setColor(QPalette::Disabled, QPalette::Mid, QColor(184, 184, 184)); + palette.setColor(QPalette::All, QPalette::Shadow, QColor(118, 118, 118)); + palette.setColor(QPalette::Disabled, QPalette::Shadow, QColor(177, 177, 177)); + palette.setColor(QPalette::All, QPalette::Highlight, QColor(48, 140, 198)); + palette.setColor(QPalette::Disabled, QPalette::Highlight, QColor(145, 145, 145)); +#if QT_VERSION >= QT_VERSION_CHECK(6, 6, 0) + palette.setColor(QPalette::All, QPalette::Accent, QColor(48, 140, 198)); + palette.setColor(QPalette::Disabled, QPalette::Accent, QColor(145, 145, 145).darker()); +#endif + palette.setColor(QPalette::All, QPalette::HighlightedText, QColor(255, 255, 255)); + palette.setColor(QPalette::Disabled, QPalette::HighlightedText, QColor(255, 255, 255)); + palette.setColor(QPalette::All, QPalette::Link, QColor(0, 0, 255)); + palette.setColor(QPalette::Disabled, QPalette::Link, QColor(0, 0, 255)); + palette.setColor(QPalette::All, QPalette::LinkVisited, QColor(255, 0, 255)); + palette.setColor(QPalette::Disabled, QPalette::LinkVisited, QColor(255, 0, 255)); + } + else if (style_type == StyleType::FusionDarkGray) + { + palette.setColor(QPalette::All, QPalette::Window, QColor(50, 50, 50)); + palette.setColor(QPalette::Disabled, QPalette::Window, QColor(55, 55, 55)); + palette.setColor(QPalette::All, QPalette::WindowText, QColor(200, 200, 200)); + palette.setColor(QPalette::Disabled, QPalette::WindowText, QColor(108, 108, 108)); + palette.setColor(QPalette::All, QPalette::Base, QColor(25, 25, 25)); + palette.setColor(QPalette::Disabled, QPalette::Base, QColor(30, 30, 30)); + palette.setColor(QPalette::All, QPalette::AlternateBase, QColor(38, 38, 38)); + palette.setColor(QPalette::Disabled, QPalette::AlternateBase, QColor(42, 42, 42)); + palette.setColor(QPalette::All, QPalette::ToolTipBase, QColor(45, 45, 45)); + palette.setColor(QPalette::Disabled, QPalette::ToolTipBase, QColor(45, 45, 45)); + palette.setColor(QPalette::All, QPalette::ToolTipText, QColor(200, 200, 200)); + palette.setColor(QPalette::Disabled, QPalette::ToolTipText, QColor(200, 200, 200)); + palette.setColor(QPalette::All, QPalette::PlaceholderText, QColor(90, 90, 90)); + palette.setColor(QPalette::Disabled, QPalette::PlaceholderText, QColor(90, 90, 90)); + palette.setColor(QPalette::All, QPalette::Text, QColor(200, 200, 200)); + palette.setColor(QPalette::Disabled, QPalette::Text, QColor(108, 108, 108)); + palette.setColor(QPalette::All, QPalette::Button, QColor(54, 54, 54)); + palette.setColor(QPalette::Disabled, QPalette::Button, QColor(54, 54, 54)); + palette.setColor(QPalette::All, QPalette::ButtonText, QColor(200, 200, 200)); + palette.setColor(QPalette::Disabled, QPalette::ButtonText, QColor(108, 108, 108)); + palette.setColor(QPalette::All, QPalette::BrightText, QColor(75, 75, 75)); + palette.setColor(QPalette::Disabled, QPalette::BrightText, QColor(255, 255, 255)); + palette.setColor(QPalette::All, QPalette::Light, QColor(26, 26, 26)); + palette.setColor(QPalette::Disabled, QPalette::Light, QColor(26, 26, 26)); + palette.setColor(QPalette::All, QPalette::Midlight, QColor(40, 40, 40)); + palette.setColor(QPalette::Disabled, QPalette::Midlight, QColor(40, 40, 40)); + palette.setColor(QPalette::All, QPalette::Dark, QColor(108, 108, 108)); + palette.setColor(QPalette::Disabled, QPalette::Dark, QColor(108, 108, 108)); + palette.setColor(QPalette::All, QPalette::Mid, QColor(71, 71, 71)); + palette.setColor(QPalette::Disabled, QPalette::Mid, QColor(71, 71, 71)); + palette.setColor(QPalette::All, QPalette::Shadow, QColor(25, 25, 25)); + palette.setColor(QPalette::Disabled, QPalette::Shadow, QColor(37, 37, 37)); + palette.setColor(QPalette::All, QPalette::Highlight, QColor(45, 140, 225)); + palette.setColor(QPalette::Disabled, QPalette::Highlight, QColor(45, 140, 225).darker()); +#if QT_VERSION >= QT_VERSION_CHECK(6, 6, 0) + palette.setColor(QPalette::All, QPalette::Accent, QColor(45, 140, 225)); + palette.setColor(QPalette::Disabled, QPalette::Accent, QColor(45, 140, 225).darker()); +#endif + palette.setColor(QPalette::All, QPalette::HighlightedText, QColor(255, 255, 255)); + palette.setColor(QPalette::Disabled, QPalette::HighlightedText, QColor(40, 40, 40)); + palette.setColor(QPalette::All, QPalette::Link, QColor(40, 130, 220)); + palette.setColor(QPalette::Disabled, QPalette::Link, QColor(40, 130, 220).darker()); + palette.setColor(QPalette::All, QPalette::LinkVisited, QColor(110, 70, 150)); + palette.setColor(QPalette::Disabled, QPalette::LinkVisited, QColor(110, 70, 150).darker()); + } + else if (style_type == StyleType::FusionDark) + { + palette.setColor(QPalette::All, QPalette::Window, QColor(22, 22, 22)); + palette.setColor(QPalette::Disabled, QPalette::Window, QColor(30, 30, 30)); + palette.setColor(QPalette::All, QPalette::WindowText, QColor(180, 180, 180)); + palette.setColor(QPalette::Disabled, QPalette::WindowText, QColor(90, 90, 90)); + palette.setColor(QPalette::All, QPalette::Base, QColor(35, 35, 35)); + palette.setColor(QPalette::Disabled, QPalette::Base, QColor(30, 30, 30)); + palette.setColor(QPalette::All, QPalette::AlternateBase, QColor(40, 40, 40)); + palette.setColor(QPalette::Disabled, QPalette::AlternateBase, QColor(35, 35, 35)); + palette.setColor(QPalette::All, QPalette::ToolTipBase, QColor(0, 0, 0)); + palette.setColor(QPalette::Disabled, QPalette::ToolTipBase, QColor(0, 0, 0)); + palette.setColor(QPalette::All, QPalette::ToolTipText, QColor(170, 170, 170)); + palette.setColor(QPalette::Disabled, QPalette::ToolTipText, QColor(170, 170, 170)); + palette.setColor(QPalette::All, QPalette::PlaceholderText, QColor(100, 100, 100)); + palette.setColor(QPalette::Disabled, QPalette::PlaceholderText, QColor(100, 100, 100)); + palette.setColor(QPalette::All, QPalette::Text, QColor(200, 200, 200)); + palette.setColor(QPalette::Disabled, QPalette::Text, QColor(90, 90, 90)); + palette.setColor(QPalette::All, QPalette::Button, QColor(30, 30, 30)); + palette.setColor(QPalette::Disabled, QPalette::Button, QColor(20, 20, 20)); + palette.setColor(QPalette::All, QPalette::ButtonText, QColor(180, 180, 180)); + palette.setColor(QPalette::Disabled, QPalette::ButtonText, QColor(90, 90, 90)); + palette.setColor(QPalette::All, QPalette::BrightText, QColor(75, 75, 75)); + palette.setColor(QPalette::Disabled, QPalette::BrightText, QColor(255, 255, 255)); + palette.setColor(QPalette::All, QPalette::Light, QColor(0, 0, 0)); + palette.setColor(QPalette::Disabled, QPalette::Light, QColor(0, 0, 0)); + palette.setColor(QPalette::All, QPalette::Midlight, QColor(40, 40, 40)); + palette.setColor(QPalette::Disabled, QPalette::Midlight, QColor(40, 40, 40)); + palette.setColor(QPalette::All, QPalette::Dark, QColor(90, 90, 90)); + palette.setColor(QPalette::Disabled, QPalette::Dark, QColor(90, 90, 90)); + palette.setColor(QPalette::All, QPalette::Mid, QColor(60, 60, 60)); + palette.setColor(QPalette::Disabled, QPalette::Mid, QColor(60, 60, 60)); + palette.setColor(QPalette::All, QPalette::Shadow, QColor(10, 10, 10)); + palette.setColor(QPalette::Disabled, QPalette::Shadow, QColor(20, 20, 20)); + palette.setColor(QPalette::All, QPalette::Highlight, QColor(35, 130, 200)); + palette.setColor(QPalette::Disabled, QPalette::Highlight, QColor(35, 130, 200).darker()); +#if QT_VERSION >= QT_VERSION_CHECK(6, 6, 0) + palette.setColor(QPalette::All, QPalette::Accent, QColor(35, 130, 200)); + palette.setColor(QPalette::Disabled, QPalette::Accent, QColor(35, 130, 200).darker()); +#endif + palette.setColor(QPalette::All, QPalette::HighlightedText, QColor(240, 240, 240)); + palette.setColor(QPalette::Disabled, QPalette::HighlightedText, QColor(35, 35, 35)); + palette.setColor(QPalette::All, QPalette::Link, QColor(40, 130, 220)); + palette.setColor(QPalette::Disabled, QPalette::Link, QColor(40, 130, 220).darker()); + palette.setColor(QPalette::All, QPalette::LinkVisited, QColor(110, 70, 150)); + palette.setColor(QPalette::Disabled, QPalette::LinkVisited, QColor(110, 70, 150).darker()); + } #ifdef _WIN32 // Unlike other OSes we don't automatically get a default dark theme on Windows. // We manually load a dark palette for our included "(Dark)" style, // and for *any* external style when the system is in "Dark" mode. // Unfortunately it doesn't seem trivial to load a palette based on the stylesheet itself. - if (style_type == StyleType::Dark || (style_type != StyleType::Light && IsSystemDark())) + else if (style_type == StyleType::Dark || (style_type != StyleType::Light && IsSystemDark())) { if (stylesheet_contents.isEmpty()) { @@ -188,7 +342,7 @@ void Settings::ApplyStyle() stylesheet_contents = QString::fromUtf8(file.readAll().data()); } - QPalette palette = qApp->style()->standardPalette(); + 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)); @@ -202,20 +356,19 @@ void Settings::ApplyStyle() 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); } +#endif else { - // reset any palette changes that may exist from a previously set dark mode if (s_default_palette) - qApp->setPalette(*s_default_palette); + palette = *s_default_palette; } -#endif + + qApp->setPalette(palette); // Define tooltips style if not already defined if (!stylesheet_contents.contains(QStringLiteral("QToolTip"), Qt::CaseSensitive)) { - const QPalette& palette = qApp->palette(); QColor window_color; QColor text_color; QColor unused_text_emphasis_color; diff --git a/Source/Core/DolphinQt/Settings.h b/Source/Core/DolphinQt/Settings.h index ff3f88edf3..e91fb130fa 100644 --- a/Source/Core/DolphinQt/Settings.h +++ b/Source/Core/DolphinQt/Settings.h @@ -66,9 +66,12 @@ public: Light = 1, Dark = 2, User = 3, + FusionLight = 4, + FusionDarkGray = 5, + FusionDark = 6, MinValue = 0, - MaxValue = 3, + MaxValue = 6, }; void SetStyleType(StyleType type); diff --git a/Source/Core/DolphinQt/Settings/InterfacePane.cpp b/Source/Core/DolphinQt/Settings/InterfacePane.cpp index 2c97269483..f12689cb31 100644 --- a/Source/Core/DolphinQt/Settings/InterfacePane.cpp +++ b/Source/Core/DolphinQt/Settings/InterfacePane.cpp @@ -157,6 +157,13 @@ void InterfacePane::CreateUI() m_combobox_userstyle->addItem(tr("(Dark)"), static_cast<int>(Settings::StyleType::Dark)); #endif + m_combobox_userstyle->addItem(tr("(Fusion Light)"), + static_cast<int>(Settings::StyleType::FusionLight)); + m_combobox_userstyle->addItem(tr("(Fusion Dark Gray)"), + static_cast<int>(Settings::StyleType::FusionDarkGray)); + m_combobox_userstyle->addItem(tr("(Fusion Dark)"), + static_cast<int>(Settings::StyleType::FusionDark)); + for (const std::string& path : userstyle_search_results) { const QFileInfo file_info(QString::fromStdString(path)); |
