1
0
Эх сурвалжийг харах

UI: Add `_CHANGING` frontend events

Adds the following events:
- `OBS_FRONTEND_EVENT_SCENE_COLLECTION_CHANGING`
- `OBS_FRONTEND_EVENT_PROFILE_CHANGING`

Both emitted right before the change occurs. Can provide plugins with
better awareness of these critical operations happening, so that they
can react accordingly.
tt2468 4 жил өмнө
parent
commit
feda1aaa28

+ 2 - 0
UI/obs-frontend-api/obs-frontend-api.h

@@ -55,6 +55,8 @@ enum obs_frontend_event {
 	OBS_FRONTEND_EVENT_VIRTUALCAM_STOPPED,
 
 	OBS_FRONTEND_EVENT_TBAR_VALUE_CHANGED,
+	OBS_FRONTEND_EVENT_SCENE_COLLECTION_CHANGING,
+	OBS_FRONTEND_EVENT_PROFILE_CHANGING,
 };
 
 /* ------------------------------------------------------------------------- */

+ 12 - 0
UI/window-basic-main-profiles.cpp

@@ -305,6 +305,9 @@ bool OBSBasic::CreateProfile(const std::string &newName, bool create_new,
 		return false;
 	}
 
+	if (api)
+		api->on_event(OBS_FRONTEND_EVENT_PROFILE_CHANGING);
+
 	config_set_string(App()->GlobalConfig(), "Basic", "Profile",
 			  newName.c_str());
 	config_set_string(App()->GlobalConfig(), "Basic", "ProfileDir",
@@ -514,6 +517,9 @@ void OBSBasic::on_actionDupProfile_triggered()
 
 void OBSBasic::on_actionRenameProfile_triggered()
 {
+	if (api)
+		api->on_event(OBS_FRONTEND_EVENT_PROFILE_CHANGING);
+
 	std::string curDir =
 		config_get_string(App()->GlobalConfig(), "Basic", "ProfileDir");
 	std::string curName =
@@ -580,6 +586,9 @@ void OBSBasic::on_actionRemoveProfile_triggered(bool skipConfirmation)
 		return;
 	}
 
+	if (api)
+		api->on_event(OBS_FRONTEND_EVENT_PROFILE_CHANGING);
+
 	newPath.resize(newPath_len);
 
 	const char *newDir = strrchr(newPath.c_str(), '/') + 1;
@@ -755,6 +764,9 @@ void OBSBasic::ChangeProfile()
 		return;
 	}
 
+	if (api)
+		api->on_event(OBS_FRONTEND_EVENT_PROFILE_CHANGING);
+
 	path.resize(path_len);
 
 	const char *newName = config_get_string(config, "General", "Name");

+ 12 - 0
UI/window-basic-main-scene-collections.cpp

@@ -166,6 +166,9 @@ bool OBSBasic::AddSceneCollection(bool create_new, const QString &qname)
 		RefreshSceneCollections();
 	};
 
+	if (api)
+		api->on_event(OBS_FRONTEND_EVENT_SCENE_COLLECTION_CHANGING);
+
 	new_collection(file, name);
 
 	blog(LOG_INFO, "Added scene collection '%s' (%s, %s.json)",
@@ -275,6 +278,9 @@ void OBSBasic::on_actionRenameSceneCollection_triggered()
 		return;
 	}
 
+	if (api)
+		api->on_event(OBS_FRONTEND_EVENT_SCENE_COLLECTION_CHANGING);
+
 	oldFile.insert(0, path);
 	oldFile += ".json";
 	os_unlink(oldFile.c_str());
@@ -336,6 +342,9 @@ void OBSBasic::on_actionRemoveSceneCollection_triggered()
 		return;
 	}
 
+	if (api)
+		api->on_event(OBS_FRONTEND_EVENT_SCENE_COLLECTION_CHANGING);
+
 	oldFile.insert(0, path);
 	oldFile += ".json";
 
@@ -424,6 +433,9 @@ void OBSBasic::ChangeSceneCollection()
 		return;
 	}
 
+	if (api)
+		api->on_event(OBS_FRONTEND_EVENT_SCENE_COLLECTION_CHANGING);
+
 	SaveProjectNow();
 
 	Load(fileName.c_str());