MCPcopy Create free account
hub / github.com/WarmUpTill/SceneSwitcher / AddList

Method AddList

plugins/scripting/utils/properties-view.cpp:745–833  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

743}
744
745QWidget *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

Callers

nothing calls this directly

Calls 9

from_obs_dataFunction · 0.85
AddRadioItemFunction · 0.85
AddComboItemFunction · 0.85
setTextMethod · 0.80
modelMethod · 0.80
flagsMethod · 0.80
ControlChangedMethod · 0.80
setToolTipMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected