From 2eae0a9d3a818977f1a260952e15e37dbe355df0 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Tue, 19 Dec 2023 23:20:25 +0100 Subject: [PATCH] Qt: allow to use native styles --- rpcs3/rpcs3qt/gui_application.cpp | 42 +++++++++++++++++++++++++++++++ rpcs3/rpcs3qt/gui_settings.h | 1 + rpcs3/rpcs3qt/settings_dialog.cpp | 8 ++++++ 3 files changed, 51 insertions(+) diff --git a/rpcs3/rpcs3qt/gui_application.cpp b/rpcs3/rpcs3qt/gui_application.cpp index cb07672173..f56e4c8547 100644 --- a/rpcs3/rpcs3qt/gui_application.cpp +++ b/rpcs3/rpcs3qt/gui_application.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include @@ -746,14 +747,55 @@ void gui_application::OnChangeStyleSheetRequest() const QString stylesheet_name = m_gui_settings->GetValue(gui::m_currentStylesheet).toString(); + // Reset style to default before doing anything else, or we will get unexpected effects in custom stylesheets. + if (const QStringList styles = QStyleFactory::keys(); !styles.empty()) + { + // The first style is the default style according to the Qt docs. + if (QStyle* style = QStyleFactory::create(styles.front())) + { + setStyle(style); + } + } + + const auto match_native_style = [&stylesheet_name]() -> QString + { + // Search for "native (