From bc9f0fe56c543e03f83f943deb3fefdba3dc95d0 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Fri, 22 Dec 2023 00:33:36 +0100 Subject: [PATCH] Qt: use initial style as default style --- rpcs3/rpcs3qt/gui_application.cpp | 27 ++++++++++++++++++++++----- rpcs3/rpcs3qt/gui_application.h | 2 ++ 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/rpcs3/rpcs3qt/gui_application.cpp b/rpcs3/rpcs3qt/gui_application.cpp index f56e4c8547..0d5a542159 100644 --- a/rpcs3/rpcs3qt/gui_application.cpp +++ b/rpcs3/rpcs3qt/gui_application.cpp @@ -747,14 +747,31 @@ 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()) + // Determine default style + if (m_default_style.isEmpty()) { - // The first style is the default style according to the Qt docs. - if (QStyle* style = QStyleFactory::create(styles.front())) + // Use the initial style as default style + if (const QStyle* style = QApplication::style()) { - setStyle(style); + m_default_style = style->name(); + gui_log.notice("Determined '%s' as default style", m_default_style); } + + // Fallback to the first style, which is supposed to be the default style according to the Qt docs. + if (m_default_style.isEmpty()) + { + if (const QStringList styles = QStyleFactory::keys(); !styles.empty()) + { + m_default_style = styles.front(); + gui_log.notice("Determined '%s' as default style (first style available)", m_default_style); + } + } + } + + // Reset style to default before doing anything else, or we will get unexpected effects in custom stylesheets. + if (QStyle* style = QStyleFactory::create(m_default_style)) + { + setStyle(style); } const auto match_native_style = [&stylesheet_name]() -> QString diff --git a/rpcs3/rpcs3qt/gui_application.h b/rpcs3/rpcs3qt/gui_application.h index eac5e19d95..79cb1b352b 100644 --- a/rpcs3/rpcs3qt/gui_application.h +++ b/rpcs3/rpcs3qt/gui_application.h @@ -94,6 +94,8 @@ private: std::shared_ptr m_gui_settings; std::shared_ptr m_persistent_settings; + QString m_default_style; + bool m_show_gui = true; bool m_use_cli_style = false; bool m_with_cli_boot = false;