From 5b18faeb495efc29eb08dbb80895f7ff4ba4b666 Mon Sep 17 00:00:00 2001 From: Exeldro Date: Mon, 9 Aug 2021 22:35:30 +0200 Subject: [PATCH] UI: Add functions to open properties and filters --- UI/api-interface.cpp | 12 ++++++++++++ UI/obs-frontend-api/obs-frontend-api.cpp | 12 ++++++++++++ UI/obs-frontend-api/obs-frontend-api.h | 3 +++ UI/obs-frontend-api/obs-frontend-internal.hpp | 4 ++++ UI/window-basic-main.cpp | 18 ++++++++++++++---- UI/window-basic-main.hpp | 3 ++- docs/sphinx/reference-frontend-api.rst | 16 ++++++++++++++++ 7 files changed, 63 insertions(+), 5 deletions(-) diff --git a/UI/api-interface.cpp b/UI/api-interface.cpp index 06283f2b0..17a020d28 100644 --- a/UI/api-interface.cpp +++ b/UI/api-interface.cpp @@ -606,6 +606,18 @@ struct OBSStudioAPI : obs_frontend_callbacks { void obs_frontend_reset_video(void) override { main->ResetVideo(); } + void obs_frontend_open_source_properties(obs_source_t *source) override + { + QMetaObject::invokeMethod(main, "OpenProperties", + Q_ARG(OBSSource, OBSSource(source))); + } + + void obs_frontend_open_source_filters(obs_source_t *source) override + { + QMetaObject::invokeMethod(main, "OpenFilters", + Q_ARG(OBSSource, OBSSource(source))); + } + void on_load(obs_data_t *settings) override { for (size_t i = saveCallbacks.size(); i > 0; i--) { diff --git a/UI/obs-frontend-api/obs-frontend-api.cpp b/UI/obs-frontend-api/obs-frontend-api.cpp index f69b24ff9..758f11f6c 100644 --- a/UI/obs-frontend-api/obs-frontend-api.cpp +++ b/UI/obs-frontend-api/obs-frontend-api.cpp @@ -534,3 +534,15 @@ void obs_frontend_reset_video(void) if (callbacks_valid()) c->obs_frontend_reset_video(); } + +void obs_frontend_open_source_properties(obs_source_t *source) +{ + if (callbacks_valid()) + c->obs_frontend_open_source_properties(source); +} + +void obs_frontend_open_source_filters(obs_source_t *source) +{ + if (callbacks_valid()) + c->obs_frontend_open_source_filters(source); +} diff --git a/UI/obs-frontend-api/obs-frontend-api.h b/UI/obs-frontend-api/obs-frontend-api.h index 0f40a8cd8..36f57bdfb 100644 --- a/UI/obs-frontend-api/obs-frontend-api.h +++ b/UI/obs-frontend-api/obs-frontend-api.h @@ -215,6 +215,9 @@ EXPORT bool obs_frontend_virtualcam_active(void); EXPORT void obs_frontend_reset_video(void); +EXPORT void obs_frontend_open_source_properties(obs_source_t *source); +EXPORT void obs_frontend_open_source_filters(obs_source_t *source); + /* ------------------------------------------------------------------------- */ #ifdef __cplusplus diff --git a/UI/obs-frontend-api/obs-frontend-internal.hpp b/UI/obs-frontend-api/obs-frontend-internal.hpp index fec522854..5ffc617f5 100644 --- a/UI/obs-frontend-api/obs-frontend-internal.hpp +++ b/UI/obs-frontend-api/obs-frontend-internal.hpp @@ -134,6 +134,10 @@ struct obs_frontend_callbacks { virtual bool obs_frontend_virtualcam_active(void) = 0; virtual void obs_frontend_reset_video(void) = 0; + + virtual void + obs_frontend_open_source_properties(obs_source_t *source) = 0; + virtual void obs_frontend_open_source_filters(obs_source_t *source) = 0; }; EXPORT void diff --git a/UI/window-basic-main.cpp b/UI/window-basic-main.cpp index ccb40d999..28b74f354 100644 --- a/UI/window-basic-main.cpp +++ b/UI/window-basic-main.cpp @@ -6007,14 +6007,24 @@ void OBSBasic::SceneNameEdited(QWidget *editor, UNUSED_PARAMETER(endHint); } -void OBSBasic::OpenFilters() +void OBSBasic::OpenFilters(OBSSource source) { - OBSSceneItem item = GetCurrentSceneItem(); - OBSSource source = obs_sceneitem_get_source(item); - + if (source == nullptr) { + OBSSceneItem item = GetCurrentSceneItem(); + source = obs_sceneitem_get_source(item); + } CreateFiltersWindow(source); } +void OBSBasic::OpenProperties(OBSSource source) +{ + if (source == nullptr) { + OBSSceneItem item = GetCurrentSceneItem(); + source = obs_sceneitem_get_source(item); + } + CreatePropertiesWindow(source); +} + void OBSBasic::OpenSceneFilters() { OBSScene scene = GetCurrentScene(); diff --git a/UI/window-basic-main.hpp b/UI/window-basic-main.hpp index b31ddd50c..e2fd388cd 100644 --- a/UI/window-basic-main.hpp +++ b/UI/window-basic-main.hpp @@ -1047,7 +1047,8 @@ private slots: QAbstractItemDelegate::EndEditHint endHint); void OpenSceneFilters(); - void OpenFilters(); + void OpenFilters(OBSSource source = nullptr); + void OpenProperties(OBSSource source = nullptr); void EnablePreviewDisplay(bool enable); void TogglePreview(); diff --git a/docs/sphinx/reference-frontend-api.rst b/docs/sphinx/reference-frontend-api.rst index 71cecd6b5..3a2345563 100644 --- a/docs/sphinx/reference-frontend-api.rst +++ b/docs/sphinx/reference-frontend-api.rst @@ -648,3 +648,19 @@ Functions :return: The value of the position of the T-bar to, with a value in 0-1023. :rtype: int + +--------------------------------------- + +.. function:: void *obs_frontend_open_properties(obs_source_t *source) + + Opens the properties window of the specified source. + + :param source: The source to open the properties window of. + +--------------------------------------- + +.. function:: void *obs_frontend_open_filters(obs_source_t *source) + + Opens the filters window of the specified source. + + :param source: The source to open the filters window of.