diff --git a/UI/properties-view.cpp b/UI/properties-view.cpp index afe3d650f7ab1b228b06bd4139a5cea1087c32cd..11cca078b354ede842073b49f71b6e1b852c960b 100644 --- a/UI/properties-view.cpp +++ b/UI/properties-view.cpp @@ -235,10 +235,21 @@ QWidget *OBSPropertiesView::AddText(obs_property_t *prop, QFormLayout *layout, { const char *name = obs_property_name(prop); const char *val = obs_data_get_string(settings, name); + const bool monospace = obs_property_text_monospace(prop); obs_text_type type = obs_property_text_type(prop); if (type == OBS_TEXT_MULTILINE) { QPlainTextEdit *edit = new QPlainTextEdit(QT_UTF8(val)); +#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) + edit->setTabStopDistance(40); +#else + edit->setTabStopWidth(40); +#endif + if (monospace) { + QFont f("Courier"); + f.setStyleHint(QFont::Monospace); + edit->setFont(f); + } return NewWidget(prop, edit, SIGNAL(textChanged())); } else if (type == OBS_TEXT_PASSWORD) { diff --git a/libobs/obs-properties.c b/libobs/obs-properties.c index b52c6c46b258523f04fa1d16dbd33946098e1e4e..1e994c353614093658074f09bdfe077e0e06f0aa 100644 --- a/libobs/obs-properties.c +++ b/libobs/obs-properties.c @@ -55,6 +55,7 @@ struct path_data { struct text_data { enum obs_text_type type; + bool monospace; }; struct list_data { @@ -978,6 +979,12 @@ enum obs_text_type obs_property_text_type(obs_property_t *p) return data ? data->type : OBS_TEXT_DEFAULT; } +enum obs_text_type obs_property_text_monospace(obs_property_t *p) +{ + struct text_data *data = get_type_data(p, OBS_PROPERTY_TEXT); + return data ? data->monospace : false; +} + enum obs_path_type obs_property_path_type(obs_property_t *p) { struct path_data *data = get_type_data(p, OBS_PROPERTY_PATH); @@ -1051,6 +1058,15 @@ void obs_property_float_set_suffix(obs_property_t *p, const char *suffix) data->suffix = bstrdup(suffix); } +void obs_property_text_set_monospace(obs_property_t *p, bool monospace) +{ + struct text_data *data = get_type_data(p, OBS_PROPERTY_TEXT); + if (!data) + return; + + data->monospace = monospace; +} + void obs_property_list_clear(obs_property_t *p) { struct list_data *data = get_list_data(p); diff --git a/libobs/obs-properties.h b/libobs/obs-properties.h index a85777866c7842cd6421d6017d8bee0b22eaf775..b3aac8072771cf0667336a2a642acc08df7acb39 100644 --- a/libobs/obs-properties.h +++ b/libobs/obs-properties.h @@ -313,6 +313,7 @@ EXPORT double obs_property_float_step(obs_property_t *p); EXPORT enum obs_number_type obs_property_float_type(obs_property_t *p); EXPORT const char *obs_property_float_suffix(obs_property_t *p); EXPORT enum obs_text_type obs_property_text_type(obs_property_t *p); +EXPORT enum obs_text_type obs_property_text_monospace(obs_property_t *p); EXPORT enum obs_path_type obs_property_path_type(obs_property_t *p); EXPORT const char *obs_property_path_filter(obs_property_t *p); EXPORT const char *obs_property_path_default_path(obs_property_t *p); @@ -326,6 +327,7 @@ EXPORT void obs_property_float_set_limits(obs_property_t *p, double min, EXPORT void obs_property_int_set_suffix(obs_property_t *p, const char *suffix); EXPORT void obs_property_float_set_suffix(obs_property_t *p, const char *suffix); +EXPORT void obs_property_text_set_monospace(obs_property_t *p, bool monospace); EXPORT void obs_property_list_clear(obs_property_t *p);