Browse Source

UI: Add 'theme:' prefix to Qt search paths

derrod 2 years ago
parent
commit
ae148b60a8
1 changed files with 14 additions and 0 deletions
  1. 14 0
      UI/obs-app.cpp

+ 14 - 0
UI/obs-app.cpp

@@ -31,6 +31,7 @@
 #include <obs-config.h>
 #include <obs.hpp>
 
+#include <QDir>
 #include <QFile>
 #include <QGuiApplication>
 #include <QScreen>
@@ -1272,6 +1273,19 @@ bool OBSApp::InitTheme()
 	defaultPalette = palette();
 	setStyle(new OBSProxyStyle());
 
+	/* Set search paths for custom 'theme:' URI prefix */
+	string searchDir;
+	if (GetDataFilePath("themes", searchDir)) {
+		auto installSearchDir = filesystem::u8path(searchDir);
+		QDir::addSearchPath("theme", absolute(installSearchDir));
+	}
+
+	char userDir[512];
+	if (GetConfigPath(userDir, sizeof(userDir), "obs-studio/themes")) {
+		auto configSearchDir = filesystem::u8path(userDir);
+		QDir::addSearchPath("theme", absolute(configSearchDir));
+	}
+
 	const char *themeName =
 		config_get_string(globalConfig, "General", "CurrentTheme3");
 	if (!themeName)