Browse Source

obs-vst: Make VST editor buttons reflect UI and VST loaded state

This changes the buttons to better reflect the state of the filter:
* When no VST is loaded, hide both buttons
* Check if VST is loaded before changing visibility
* Check if VST is loaded and editor is open before changing visibility
PatTheMav 3 năm trước cách đây
mục cha
commit
2dbd6c2a2f
1 tập tin đã thay đổi với 23 bổ sung12 xóa
  1. 23 12
      plugins/obs-vst/obs-vst.cpp

+ 23 - 12
plugins/obs-vst/obs-vst.cpp

@@ -40,12 +40,15 @@ static bool open_editor_button_clicked(obs_properties_t *props,
 {
 {
 	VSTPlugin *vstPlugin = (VSTPlugin *)data;
 	VSTPlugin *vstPlugin = (VSTPlugin *)data;
 
 
-	QMetaObject::invokeMethod(vstPlugin, "openEditor");
+	if (vstPlugin && vstPlugin->vstLoaded()) {
 
 
-	obs_property_set_visible(obs_properties_get(props, OPEN_VST_SETTINGS),
-				 false);
-	obs_property_set_visible(obs_properties_get(props, CLOSE_VST_SETTINGS),
-				 true);
+		QMetaObject::invokeMethod(vstPlugin, "openEditor");
+
+		obs_property_set_visible(
+			obs_properties_get(props, OPEN_VST_SETTINGS), false);
+		obs_property_set_visible(
+			obs_properties_get(props, CLOSE_VST_SETTINGS), true);
+	}
 
 
 	UNUSED_PARAMETER(props);
 	UNUSED_PARAMETER(props);
 	UNUSED_PARAMETER(property);
 	UNUSED_PARAMETER(property);
@@ -59,12 +62,15 @@ static bool close_editor_button_clicked(obs_properties_t *props,
 {
 {
 	VSTPlugin *vstPlugin = (VSTPlugin *)data;
 	VSTPlugin *vstPlugin = (VSTPlugin *)data;
 
 
-	QMetaObject::invokeMethod(vstPlugin, "closeEditor");
+	if (vstPlugin && vstPlugin->vstLoaded() && vstPlugin->isEditorOpen()) {
 
 
-	obs_property_set_visible(obs_properties_get(props, OPEN_VST_SETTINGS),
-				 true);
-	obs_property_set_visible(obs_properties_get(props, CLOSE_VST_SETTINGS),
-				 false);
+		QMetaObject::invokeMethod(vstPlugin, "closeEditor");
+
+		obs_property_set_visible(
+			obs_properties_get(props, OPEN_VST_SETTINGS), true);
+		obs_property_set_visible(
+			obs_properties_get(props, CLOSE_VST_SETTINGS), false);
+	}
 
 
 	UNUSED_PARAMETER(property);
 	UNUSED_PARAMETER(property);
 
 
@@ -302,9 +308,14 @@ static obs_properties_t *vst_properties(void *data)
 	bool close_settings_vis = false;
 	bool close_settings_vis = false;
 	if (data) {
 	if (data) {
 		VSTPlugin *vstPlugin = (VSTPlugin *)data;
 		VSTPlugin *vstPlugin = (VSTPlugin *)data;
-		if (vstPlugin->isEditorOpen()) {
-			close_settings_vis = true;
+		if (!vstPlugin->vstLoaded()) {
+			close_settings_vis = false;
 			open_settings_vis = false;
 			open_settings_vis = false;
+		} else {
+			if (vstPlugin->isEditorOpen()) {
+				close_settings_vis = true;
+				open_settings_vis = false;
+			}
 		}
 		}
 	}
 	}