UI: Rewrite scene collection system to enable user-provided storage

This change enables loading scene collections from locations different
than OBS' own configuration directory.

It also rewrites profile management in the app to work off an in-memory
collection of profiles found on disk and does not require iterating
over directory contents for most profile interactions by the app.
This commit is contained in:
PatTheMav
2024-09-03 16:29:58 +02:00
committed by Ryan Foster
parent 607d37b423
commit 3e0592dc20
6 changed files with 711 additions and 475 deletions

View File

@@ -16,8 +16,6 @@ template<typename T> static T GetOBSRef(QListWidgetItem *item)
return item->data(static_cast<int>(QtDataRole::OBSRef)).value<T>();
}
void EnumSceneCollections(function<bool(const char *, const char *)> &&cb);
extern volatile bool streaming_active;
extern volatile bool recording_active;
extern volatile bool recording_paused;
@@ -168,19 +166,17 @@ struct OBSStudioAPI : obs_frontend_callbacks {
void obs_frontend_get_scene_collections(
std::vector<std::string> &strings) override
{
auto addCollection = [&](const char *name, const char *) {
strings.emplace_back(name);
return true;
};
EnumSceneCollections(addCollection);
for (auto &[collectionName, collection] :
main->GetSceneCollectionCache()) {
strings.emplace_back(collectionName);
}
}
char *obs_frontend_get_current_scene_collection(void) override
{
const char *cur_name = config_get_string(
App()->GlobalConfig(), "Basic", "SceneCollection");
return bstrdup(cur_name);
const OBSSceneCollection &currentCollection =
main->GetCurrentSceneCollection();
return bstrdup(currentCollection.name.c_str());
}
void obs_frontend_set_current_scene_collection(
@@ -206,10 +202,9 @@ struct OBSStudioAPI : obs_frontend_callbacks {
bool obs_frontend_add_scene_collection(const char *name) override
{
bool success = false;
QMetaObject::invokeMethod(main, "AddSceneCollection",
QMetaObject::invokeMethod(main, "NewSceneCollection",
WaitConnection(),
Q_RETURN_ARG(bool, success),
Q_ARG(bool, true),
Q_ARG(QString, QT_UTF8(name)));
return success;
}