| 846 | } |
| 847 | |
| 848 | void OBSPropertiesView::AddEditableList(obs_property_t *prop, |
| 849 | QFormLayout *layout, QLabel *&label) |
| 850 | { |
| 851 | const char *name = obs_property_name(prop); |
| 852 | OBSDataArrayAutoRelease array = obs_data_get_array(settings, name); |
| 853 | QListWidget *list = new QListWidget(); |
| 854 | size_t count = obs_data_array_count(array); |
| 855 | |
| 856 | if (!obs_property_enabled(prop)) |
| 857 | list->setEnabled(false); |
| 858 | |
| 859 | list->setSortingEnabled(false); |
| 860 | list->setSelectionMode(QAbstractItemView::ExtendedSelection); |
| 861 | list->setToolTip(QT_UTF8(obs_property_long_description(prop))); |
| 862 | list->setSpacing(1); |
| 863 | |
| 864 | for (size_t i = 0; i < count; i++) { |
| 865 | OBSDataAutoRelease item = obs_data_array_item(array, i); |
| 866 | list->addItem(QT_UTF8(obs_data_get_string(item, "value"))); |
| 867 | QListWidgetItem *const list_item = list->item((int)i); |
| 868 | list_item->setSelected(obs_data_get_bool(item, "selected")); |
| 869 | list_item->setHidden(obs_data_get_bool(item, "hidden")); |
| 870 | } |
| 871 | |
| 872 | WidgetInfo *info = new WidgetInfo(this, prop, list); |
| 873 | |
| 874 | list->setDragDropMode(QAbstractItemView::InternalMove); |
| 875 | connect(list->model(), &QAbstractItemModel::rowsMoved, |
| 876 | [info]() { info->EditableListChanged(); }); |
| 877 | |
| 878 | QVBoxLayout *sideLayout = new QVBoxLayout(); |
| 879 | NewButton(sideLayout, info, "addIconSmall", &WidgetInfo::EditListAdd); |
| 880 | NewButton(sideLayout, info, "removeIconSmall", |
| 881 | &WidgetInfo::EditListRemove); |
| 882 | NewButton(sideLayout, info, "configIconSmall", |
| 883 | &WidgetInfo::EditListEdit); |
| 884 | NewButton(sideLayout, info, "upArrowIconSmall", |
| 885 | &WidgetInfo::EditListUp); |
| 886 | NewButton(sideLayout, info, "downArrowIconSmall", |
| 887 | &WidgetInfo::EditListDown); |
| 888 | sideLayout->addStretch(0); |
| 889 | |
| 890 | QHBoxLayout *subLayout = new QHBoxLayout(); |
| 891 | subLayout->addWidget(list); |
| 892 | subLayout->addLayout(sideLayout); |
| 893 | |
| 894 | children.emplace_back(info); |
| 895 | |
| 896 | label = new QLabel(QT_UTF8(obs_property_description(prop))); |
| 897 | layout->addRow(label, subLayout); |
| 898 | } |
| 899 | |
| 900 | QWidget *OBSPropertiesView::AddButton(obs_property_t *prop) |
| 901 | { |
nothing calls this directly
no test coverage detected