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

Method FontChanged

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

Source from the content-addressed store, hash-verified

2072}
2073
2074bool WidgetInfo::FontChanged(const char *setting)
2075{
2076 OBSDataAutoRelease font_obj = obs_data_get_obj(view->settings, setting);
2077 bool success;
2078 uint32_t flags;
2079 QFont font;
2080
2081 QFontDialog::FontDialogOptions options;
2082
2083#ifndef _WIN32
2084 options = QFontDialog::DontUseNativeDialog;
2085#endif
2086
2087 if (!font_obj) {
2088 QFont initial;
2089 font = QFontDialog::getFont(
2090 &success, initial, view,
2091 QTStr("Basic.PropertiesWindow.SelectFont.WindowTitle"),
2092 options);
2093 } else {
2094 MakeQFont(font_obj, font);
2095 font = QFontDialog::getFont(
2096 &success, font, view,
2097 QTStr("Basic.PropertiesWindow.SelectFont.WindowTitle"),
2098 options);
2099 }
2100
2101 if (!success)
2102 return false;
2103
2104 font_obj = obs_data_create();
2105
2106 obs_data_set_string(font_obj, "face", QT_TO_UTF8(font.family()));
2107 obs_data_set_string(font_obj, "style", QT_TO_UTF8(font.styleName()));
2108 obs_data_set_int(font_obj, "size", font.pointSize());
2109 flags = font.bold() ? OBS_FONT_BOLD : 0;
2110 flags |= font.italic() ? OBS_FONT_ITALIC : 0;
2111 flags |= font.underline() ? OBS_FONT_UNDERLINE : 0;
2112 flags |= font.strikeOut() ? OBS_FONT_STRIKEOUT : 0;
2113 obs_data_set_int(font_obj, "flags", flags);
2114
2115 QLabel *label = static_cast<QLabel *>(widget);
2116 QFont labelFont;
2117 MakeQFont(font_obj, labelFont, true);
2118 label->setFont(labelFont);
2119 label->setText(QString("%1 %2").arg(font.family(), font.styleName()));
2120
2121 obs_data_set_obj(view->settings, setting, font_obj);
2122 return true;
2123}
2124
2125void WidgetInfo::GroupChanged(const char *setting)
2126{

Callers

nothing calls this directly

Calls 2

MakeQFontFunction · 0.85
setTextMethod · 0.80

Tested by

no test coverage detected