| 743 | } |
| 744 | |
| 745 | QWidget *OBSPropertiesView::AddList(obs_property_t *prop, bool &warning) |
| 746 | { |
| 747 | const char *name = obs_property_name(prop); |
| 748 | obs_combo_type type = obs_property_list_type(prop); |
| 749 | obs_combo_format format = obs_property_list_format(prop); |
| 750 | size_t count = obs_property_list_item_count(prop); |
| 751 | |
| 752 | QVariant value = from_obs_data(settings, name, format); |
| 753 | |
| 754 | if (type == OBS_COMBO_TYPE_RADIO) { |
| 755 | QButtonGroup *buttonGroup = new QButtonGroup(); |
| 756 | QFormLayout *subLayout = new QFormLayout(); |
| 757 | subLayout->setContentsMargins(0, 0, 0, 0); |
| 758 | |
| 759 | for (size_t idx = 0; idx < count; idx++) |
| 760 | AddRadioItem(buttonGroup, subLayout, prop, value, idx); |
| 761 | |
| 762 | if (count > 0) { |
| 763 | buttonGroup->setExclusive(true); |
| 764 | WidgetInfo *info = new WidgetInfo( |
| 765 | this, prop, buttonGroup->buttons()[0]); |
| 766 | children.emplace_back(info); |
| 767 | connect(buttonGroup, &QButtonGroup::buttonClicked, info, |
| 768 | &WidgetInfo::ControlChanged); |
| 769 | } |
| 770 | |
| 771 | QWidget *widget = new QWidget(); |
| 772 | widget->setLayout(subLayout); |
| 773 | return widget; |
| 774 | } |
| 775 | |
| 776 | int idx = -1; |
| 777 | |
| 778 | QComboBox *combo = new QComboBox(); |
| 779 | for (size_t i = 0; i < count; i++) |
| 780 | AddComboItem(combo, prop, i); |
| 781 | |
| 782 | if (type == OBS_COMBO_TYPE_EDITABLE) |
| 783 | combo->setEditable(true); |
| 784 | |
| 785 | combo->setMaxVisibleItems(40); |
| 786 | combo->setToolTip(QT_UTF8(obs_property_long_description(prop))); |
| 787 | |
| 788 | if (format == OBS_COMBO_FORMAT_STRING && |
| 789 | type == OBS_COMBO_TYPE_EDITABLE) { |
| 790 | combo->lineEdit()->setText(value.toString()); |
| 791 | } else { |
| 792 | idx = combo->findData(value); |
| 793 | } |
| 794 | |
| 795 | if (type == OBS_COMBO_TYPE_EDITABLE) |
| 796 | return NewWidget(prop, combo, &QComboBox::editTextChanged); |
| 797 | |
| 798 | if (idx != -1) |
| 799 | combo->setCurrentIndex(idx); |
| 800 | |
| 801 | PRAGMA_WARN_PUSH |
| 802 | PRAGMA_DISABLE_DEPRECATION |
nothing calls this directly
no test coverage detected