frontend: Set up theme watcher during init

This commit is contained in:
Warchamp7
2026-05-08 16:29:06 -04:00
committed by Ryan Foster
parent 4d6d9a5166
commit 686ee75a05
+11 -7
View File
@@ -827,7 +827,7 @@ bool OBSApp::SetTheme(const QString &name)
if (!theme)
return false;
if (themeWatcher) {
if (themeWatcher && themeWatcher->files().size() > 0) {
themeWatcher->blockSignals(true);
themeWatcher->removePaths(themeWatcher->files());
}
@@ -1027,6 +1027,16 @@ bool OBSApp::InitTheme()
#endif
}
if (config_get_bool(userConfig, "Appearance", "AutoReload")) {
if (themeWatcher) {
themeWatcher->deleteLater();
}
// Set up Qt file watcher to automatically reload themes.
themeWatcher = new QFileSystemWatcher(this);
connect(themeWatcher, &QFileSystemWatcher::fileChanged, this, &OBSApp::themeFileChanged);
}
if (!SetTheme(themeName)) {
blog(LOG_ERROR,
"Loading default theme \"%s\" failed, falling back to "
@@ -1035,11 +1045,5 @@ bool OBSApp::InitTheme()
return SetTheme("com.obsproject.System");
}
if (config_get_bool(userConfig, "Appearance", "AutoReload")) {
/* Set up Qt file watcher to automatically reload themes */
themeWatcher = new QFileSystemWatcher(this);
connect(themeWatcher.get(), &QFileSystemWatcher::fileChanged, this, &OBSApp::themeFileChanged);
}
return true;
}