mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-08-29 02:03:03 +08:00
frontend: Set up theme watcher during init
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user