From 08cee21158c1f43956210418dd99ab763a90d2a2 Mon Sep 17 00:00:00 2001 From: Matt Gajownik Date: Mon, 4 Jul 2022 23:26:19 +1000 Subject: [PATCH] UI: Apply default stylesheet before applying theme This significantly improves performance when switching themes. The original intent was to "clear" customizations applied by the previously selected theme. This change does not seem to achieve that goal. --- UI/obs-app.cpp | 2 ++ UI/obs-app.hpp | 1 + 2 files changed, 3 insertions(+) diff --git a/UI/obs-app.cpp b/UI/obs-app.cpp index e84ae9e02..b2833f283 100644 --- a/UI/obs-app.cpp +++ b/UI/obs-app.cpp @@ -1117,6 +1117,7 @@ bool OBSApp::SetTheme(std::string name, std::string path) } } + setStyleSheet(defaultStyleSheet); QString mpath = QString("file:///") + path.c_str(); setPalette(defaultPalette); ParseExtraThemeData(path.c_str()); @@ -1132,6 +1133,7 @@ bool OBSApp::SetTheme(std::string name, std::string path) bool OBSApp::InitTheme() { defaultPalette = palette(); + defaultStyleSheet = styleSheet(); const char *themeName = config_get_string(globalConfig, "General", "CurrentTheme2"); diff --git a/UI/obs-app.hpp b/UI/obs-app.hpp index 1d76fe38b..c058989c2 100644 --- a/UI/obs-app.hpp +++ b/UI/obs-app.hpp @@ -74,6 +74,7 @@ class OBSApp : public QApplication { private: std::string locale; std::string theme; + QString defaultStyleSheet; bool themeDarkMode = true; ConfigFile globalConfig; TextLookup textLookup;