Browse Source

UI: Add functions to open properties and filters

Exeldro 4 years ago
parent
commit
5b18faeb49

+ 12 - 0
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--) {

+ 12 - 0
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);
+}

+ 3 - 0
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

+ 4 - 0
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

+ 14 - 4
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();

+ 2 - 1
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();

+ 16 - 0
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.