فهرست منبع

UI: Add Selected and Hidden Array Values

Add Selected and Hidden Array Values

Let developers get and set whether items in an editable list are hidden
or selected. May be useful in when editable lists are modified and
handled in a callback. Especially when edit button callbacks are used.

Closes obsproject/obs-studio#1200
Alex Anderson 8 سال پیش
والد
کامیت
e92b2560b6
1فایلهای تغییر یافته به همراه8 افزوده شده و 1 حذف شده
  1. 8 1
      UI/properties-view.cpp

+ 8 - 1
UI/properties-view.cpp

@@ -576,6 +576,10 @@ void OBSPropertiesView::AddEditableList(obs_property_t *prop,
 	for (size_t i = 0; i < count; i++) {
 		obs_data_t *item = obs_data_array_item(array, i);
 		list->addItem(QT_UTF8(obs_data_get_string(item, "value")));
+		list->setItemSelected(list->item((int)i),
+				obs_data_get_bool(item, "selected"));
+		list->setItemHidden(list->item((int)i),
+				obs_data_get_bool(item, "hidden"));
 		obs_data_release(item);
 	}
 
@@ -1690,7 +1694,10 @@ void WidgetInfo::EditableListChanged()
 		obs_data_t *arrayItem = obs_data_create();
 		obs_data_set_string(arrayItem, "value",
 				QT_TO_UTF8(item->text()));
-
+		obs_data_set_bool(arrayItem, "selected",
+			item->isSelected());
+		obs_data_set_bool(arrayItem, "hidden",
+			item->isHidden());
 		obs_data_array_push_back(array, arrayItem);
 		obs_data_release(arrayItem);
 	}