未验证 提交 8af794ce 编写于 作者: J Jim 提交者: GitHub

Merge pull request #2276 from WizardCM/monospace-multiline

Add monospace font for multiline text property
......@@ -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) {
......
......@@ -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);
......
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册