UI: Add functions to open properties and filters

This commit is contained in:
Exeldro 2021-08-09 22:35:30 +02:00 committed by Jim
parent f0d372bdd7
commit 5b18faeb49
7 changed files with 63 additions and 5 deletions

View file

@ -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--) {

View file

@ -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);
}

View file

@ -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

View file

@ -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

View file

@ -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();

View file

@ -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();

View file

@ -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.