UI: Use correct color property for freetype in toolbar

This commit is contained in:
gxalpha 2021-09-19 21:44:34 +02:00 committed by Jim
parent 4bd69bf46e
commit 5c26bf06f0

View File

@ -615,7 +615,13 @@ TextSourceToolbar::TextSourceToolbar(QWidget *parent, OBSSource source)
MakeQFont(font_obj, font);
obs_data_release(font_obj);
unsigned int val = (unsigned int)obs_data_get_int(settings, "color");
// Use "color1" if it's a freetype source and "color" elsewise
unsigned int val = (unsigned int)obs_data_get_int(
settings,
(strncmp(obs_source_get_id(source), "text_ft2_source", 15) == 0)
? "color1"
: "color");
color = color_from_int(val);
const char *text = obs_data_get_string(settings, "text");
@ -687,7 +693,12 @@ void TextSourceToolbar::on_selectColor_clicked()
return;
}
obs_property_t *p = obs_properties_get(props.get(), "color");
bool freetype =
strncmp(obs_source_get_id(source), "text_ft2_source", 15) == 0;
obs_property_t *p =
obs_properties_get(props.get(), freetype ? "color1" : "color");
const char *desc = obs_property_description(p);
QColorDialog::ColorDialogOptions options;
@ -707,7 +718,7 @@ void TextSourceToolbar::on_selectColor_clicked()
SaveOldProperties(source);
obs_data_t *settings = obs_data_create();
if (!strncmp(obs_source_get_id(source), "text_ft2_source", 15)) {
if (freetype) {
obs_data_set_int(settings, "color1", color_to_int(color));
obs_data_set_int(settings, "color2", color_to_int(color));
} else {