From 748cf32a434d0325ea6d980c45c2e048c4fc66a5 Mon Sep 17 00:00:00 2001 From: cg2121 Date: Thu, 24 Feb 2022 22:56:20 -0600 Subject: [PATCH] UI: Add events for renaming profiles/collections The events make it more clear when profiles or scene collections are renamed. --- UI/obs-frontend-api/obs-frontend-api.h | 2 ++ UI/window-basic-main-profiles.cpp | 9 ++------- UI/window-basic-main-scene-collections.cpp | 9 ++------- docs/sphinx/reference-frontend-api.rst | 13 ++++++++++--- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/UI/obs-frontend-api/obs-frontend-api.h b/UI/obs-frontend-api/obs-frontend-api.h index 2fdbe0367..afc0ccbbd 100644 --- a/UI/obs-frontend-api/obs-frontend-api.h +++ b/UI/obs-frontend-api/obs-frontend-api.h @@ -58,6 +58,8 @@ enum obs_frontend_event { OBS_FRONTEND_EVENT_SCENE_COLLECTION_CHANGING, OBS_FRONTEND_EVENT_PROFILE_CHANGING, OBS_FRONTEND_EVENT_SCRIPTING_SHUTDOWN, + OBS_FRONTEND_EVENT_PROFILE_RENAMED, + OBS_FRONTEND_EVENT_SCENE_COLLECTION_RENAMED, }; /* ------------------------------------------------------------------------- */ diff --git a/UI/window-basic-main-profiles.cpp b/UI/window-basic-main-profiles.cpp index 6919863d5..ed3c87ca4 100644 --- a/UI/window-basic-main-profiles.cpp +++ b/UI/window-basic-main-profiles.cpp @@ -517,9 +517,6 @@ 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 = @@ -534,10 +531,8 @@ void OBSBasic::on_actionRenameProfile_triggered() RefreshProfiles(); } - if (api) { - api->on_event(OBS_FRONTEND_EVENT_PROFILE_LIST_CHANGED); - api->on_event(OBS_FRONTEND_EVENT_PROFILE_CHANGED); - } + if (api) + api->on_event(OBS_FRONTEND_EVENT_PROFILE_RENAMED); } void OBSBasic::on_actionRemoveProfile_triggered(bool skipConfirmation) diff --git a/UI/window-basic-main-scene-collections.cpp b/UI/window-basic-main-scene-collections.cpp index cd426b82b..42dffd16a 100644 --- a/UI/window-basic-main-scene-collections.cpp +++ b/UI/window-basic-main-scene-collections.cpp @@ -276,9 +276,6 @@ 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()); @@ -293,10 +290,8 @@ void OBSBasic::on_actionRenameSceneCollection_triggered() UpdateTitleBar(); RefreshSceneCollections(); - if (api) { - api->on_event(OBS_FRONTEND_EVENT_SCENE_COLLECTION_LIST_CHANGED); - api->on_event(OBS_FRONTEND_EVENT_SCENE_COLLECTION_CHANGED); - } + if (api) + api->on_event(OBS_FRONTEND_EVENT_SCENE_COLLECTION_RENAMED); } void OBSBasic::on_actionRemoveSceneCollection_triggered() diff --git a/docs/sphinx/reference-frontend-api.rst b/docs/sphinx/reference-frontend-api.rst index 7bce5c580..bb8925609 100644 --- a/docs/sphinx/reference-frontend-api.rst +++ b/docs/sphinx/reference-frontend-api.rst @@ -95,8 +95,11 @@ Structures/Enumerations - **OBS_FRONTEND_EVENT_SCENE_COLLECTION_LIST_CHANGED** - Triggered when a scene collection has been - added/removed/renamed. + Triggered when a scene collection has been added or removed. + + - **OBS_FRONTEND_EVENT_SCENE_COLLECTION_RENAMED** + + Triggered when a scene collection has been renamed. - **OBS_FRONTEND_EVENT_PROFILE_CHANGING** @@ -108,7 +111,11 @@ Structures/Enumerations - **OBS_FRONTEND_EVENT_PROFILE_LIST_CHANGED** - Triggered when a profile has been added/removed/renamed. + Triggered when a profile has been added or removed. + + - **OBS_FRONTEND_EVENT_PROFILE_RENAMED** + + Triggered when a profile has been renamed. - **OBS_FRONTEND_EVENT_FINISHED_LOADING**