Browse Source

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.
Matt Gajownik 3 years ago
parent
commit
08cee21158
2 changed files with 3 additions and 0 deletions
  1. 2 0
      UI/obs-app.cpp
  2. 1 0
      UI/obs-app.hpp

+ 2 - 0
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();
 	QString mpath = QString("file:///") + path.c_str();
 	setPalette(defaultPalette);
 	setPalette(defaultPalette);
 	ParseExtraThemeData(path.c_str());
 	ParseExtraThemeData(path.c_str());
@@ -1132,6 +1133,7 @@ bool OBSApp::SetTheme(std::string name, std::string path)
 bool OBSApp::InitTheme()
 bool OBSApp::InitTheme()
 {
 {
 	defaultPalette = palette();
 	defaultPalette = palette();
+	defaultStyleSheet = styleSheet();
 
 
 	const char *themeName =
 	const char *themeName =
 		config_get_string(globalConfig, "General", "CurrentTheme2");
 		config_get_string(globalConfig, "General", "CurrentTheme2");

+ 1 - 0
UI/obs-app.hpp

@@ -74,6 +74,7 @@ class OBSApp : public QApplication {
 private:
 private:
 	std::string locale;
 	std::string locale;
 	std::string theme;
 	std::string theme;
+	QString defaultStyleSheet;
 	bool themeDarkMode = true;
 	bool themeDarkMode = true;
 	ConfigFile globalConfig;
 	ConfigFile globalConfig;
 	TextLookup textLookup;
 	TextLookup textLookup;