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

Method AddFont

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

Source from the content-addressed store, hash-verified

1007}
1008
1009void OBSPropertiesView::AddFont(obs_property_t *prop, QFormLayout *layout,
1010 QLabel *&label)
1011{
1012 const char *name = obs_property_name(prop);
1013 OBSDataAutoRelease font_obj = obs_data_get_obj(settings, name);
1014 const char *face = obs_data_get_string(font_obj, "face");
1015 const char *style = obs_data_get_string(font_obj, "style");
1016 QPushButton *button = new QPushButton;
1017 QLabel *fontLabel = new QLabel;
1018 QFont font;
1019
1020 if (!obs_property_enabled(prop)) {
1021 button->setEnabled(false);
1022 fontLabel->setEnabled(false);
1023 }
1024
1025 font = fontLabel->font();
1026 MakeQFont(font_obj, font, true);
1027
1028 button->setProperty("themeID", "settingsButtons");
1029 button->setText(QTStr("Basic.PropertiesWindow.SelectFont"));
1030 button->setToolTip(QT_UTF8(obs_property_long_description(prop)));
1031
1032 fontLabel->setFrameStyle(QFrame::Sunken | QFrame::Panel);
1033 fontLabel->setFont(font);
1034 fontLabel->setText(QString("%1 %2").arg(face, style));
1035 fontLabel->setAlignment(Qt::AlignCenter);
1036 fontLabel->setToolTip(QT_UTF8(obs_property_long_description(prop)));
1037
1038 QHBoxLayout *subLayout = new QHBoxLayout;
1039 subLayout->setContentsMargins(0, 0, 0, 0);
1040
1041 subLayout->addWidget(fontLabel);
1042 subLayout->addWidget(button);
1043
1044 WidgetInfo *info = new WidgetInfo(this, prop, fontLabel);
1045 connect(button, &QPushButton::clicked, info,
1046 &WidgetInfo::ControlChanged);
1047 children.emplace_back(info);
1048
1049 label = new QLabel(QT_UTF8(obs_property_description(prop)));
1050 layout->addRow(label, subLayout);
1051}
1052
1053template<typename T> static double make_epsilon(T val)
1054{

Callers

nothing calls this directly

Calls 4

MakeQFontFunction · 0.85
setTextMethod · 0.80
addRowMethod · 0.80
setToolTipMethod · 0.45

Tested by

no test coverage detected