obs source的属性框的创建过程
来源:互联网 发布:excel同列不同数据分列 编辑:程序博客网 时间:2024/06/05 05:08
当你双击某个资源时,如图,此时会触发
void OBSBasic::on_sources_itemDoubleClicked(QListWidgetItem *witem){if (!witem)return;OBSSceneItem item = GetSceneItem(witem);OBSSource source = obs_sceneitem_get_source(item);if (source)CreatePropertiesWindow(source);}
根据List的Item获得源 的item,然后根据该item,获得该source,然后创建该source的property
window-basic-properties.cpp中的定义了source的属性类OBSBasicProperties
该类的构造函数中会创建OBSPropertiesView,然后调用RefreshProperties,添加相应的属性
void OBSPropertiesView::RefreshProperties(){//obs_property_t *property = obs_properties_first(properties.get());bool hasNoProperties = !property;while (property) {AddProperty(property, layout);obs_property_next(&property);}/////}获得属性的类型,根据不同的类型 动态创建相应的控件
void OBSPropertiesView::AddProperty(obs_property_t *property,QFormLayout *layout){const char *name = obs_property_name(property);obs_property_type type = obs_property_get_type(property);if (!obs_property_visible(property))return;QLabel *label = nullptr;QWidget *widget = nullptr;bool warning = false;switch (type) {case OBS_PROPERTY_INVALID:return;case OBS_PROPERTY_BOOL:widget = AddCheckbox(property);break;case OBS_PROPERTY_INT:AddInt(property, layout, &label);break;case OBS_PROPERTY_FLOAT:AddFloat(property, layout, &label);break;case OBS_PROPERTY_TEXT:widget = AddText(property, layout, label);break;case OBS_PROPERTY_PATH:AddPath(property, layout, &label);break;case OBS_PROPERTY_LIST:widget = AddList(property, warning);break;case OBS_PROPERTY_COLOR:AddColor(property, layout, label);break;case OBS_PROPERTY_FONT:AddFont(property, layout, label);break;case OBS_PROPERTY_BUTTON:widget = AddButton(property);break;case OBS_PROPERTY_EDITABLE_LIST:AddEditableList(property, layout, label);break;case OBS_PROPERTY_FRAME_RATE:AddFrameRate(property, warning, layout, label);break;}if (widget && !obs_property_enabled(property))widget->setEnabled(false);if (!label && type != OBS_PROPERTY_BOOL && type != OBS_PROPERTY_BUTTON)label = new QLabel(QT_UTF8(obs_property_description(property)));if (warning && label) //TODO: select color based on background colorlabel->setStyleSheet("QLabel { color: red; }");if (label && minSize) {label->setMinimumWidth(minSize);label->setAlignment(Qt::AlignRight | Qt::AlignVCenter);}if (!widget)return;layout->addRow(label, widget);if (!lastFocused.empty())if (lastFocused.compare(name) == 0)lastWidget = widget;}
例如 音频的设备Device,是个QComboBox,type=OBS_PROPERTY_LIST,此时会调用
QWidget *OBSPropertiesView::AddList(obs_property_t *prop, bool &warning){const char *name = obs_property_name(prop);QComboBox *combo = new QComboBox();obs_combo_type type = obs_property_list_type(prop);obs_combo_format format = obs_property_list_format(prop);size_t count = obs_property_list_item_count(prop);int idx = -1;for (size_t i = 0; i < count; i++)AddComboItem(combo, prop, format, i);if (type == OBS_COMBO_TYPE_EDITABLE)combo->setEditable(true);combo->setMaxVisibleItems(40);combo->setToolTip(QT_UTF8(obs_property_long_description(prop)));string value = from_obs_data(settings, name, format);if (format == OBS_COMBO_FORMAT_STRING &&type == OBS_COMBO_TYPE_EDITABLE) {combo->lineEdit()->setText(QT_UTF8(value.c_str()));} else {idx = combo->findData(QByteArray(value.c_str()));}if (type == OBS_COMBO_TYPE_EDITABLE)return NewWidget(prop, combo,SIGNAL(editTextChanged(const QString &)));if (idx != -1)combo->setCurrentIndex(idx);if (obs_data_has_autoselect_value(settings, name)) {string autoselect =from_obs_data_autoselect(settings, name, format);int id = combo->findData(QT_UTF8(autoselect.c_str()));if (id != -1 && id != idx) {QString actual = combo->itemText(id);QString selected = combo->itemText(idx);QString combined = QTStr("Basic.PropertiesWindow.AutoSelectFormat");combo->setItemText(idx,combined.arg(selected).arg(actual));}}QAbstractItemModel *model = combo->model();warning = idx != -1 &&model->flags(model->index(idx, 0)) == Qt::NoItemFlags;WidgetInfo *info = new WidgetInfo(this, prop, combo);connect(combo, SIGNAL(currentIndexChanged(int)), info,SLOT(ControlChanged()));children.emplace_back(info);/* trigger a settings update if the index was not found */if (idx == -1)info->ControlChanged();return combo;}
注意obs内部的字符编码是UTF8,如果你直接用const char*接受返回的设备名字,会出现无效字符,此时记着UTF8转换为Unicode
0 0
- obs source的属性框的创建过程
- obs-studio的源
- OBS源码阅读笔记--如何给source添加展示画面的地方呢?
- OBS下的音频知识
- 基于obs studio 的源码应用
- 基于obs studio 的源码应用
- obs-studio的编译环境配置
- OBS解读-动态循环缓冲区的实现
- OBS窗口捕获黑屏的解决办法
- 基于OBS的插件开发总结
- 索引属性用作databinding source的语法
- WPF中Image控件的Source属性
- SilverLight MultiScaleImage 的Source属性动态设置
- qml中Image的source属性路径
- 存储过程的属性
- 自定义属性的过程
- 如何创建节俭的source insight工程
- obs-studio源码阅读笔记:学习obs流程的第一步,test程序
- ubantu nginx 安装
- Java IO 之 BufferedWriter 字符输出缓冲类使用示例和详解
- 小码哥-玩转【斗鱼直播APP】系列之框架搭建
- 表里无此字段,但是存储过程得新增一条字段,DepartmentName
- Google-Guice入门介绍
- obs source的属性框的创建过程
- HDU 1166 敌兵布阵
- JavaSE学习笔记之Annotation(注解)
- 新手自定义锁屏
- iOS 图片上传
- Java堆分配参数总结
- 计算机视觉篇:一:opencv的基本操作,卷积。
- Linux下MySQL数据库常用基本操作 一
- java多线程的创建及常用方法