提交 b5f56ff5 编写于 作者: P Palana

Highlight label in properties-view when a disabled list item is selected

上级 5b5ef6aa
......@@ -172,7 +172,7 @@ static void AddComboItem(QComboBox *combo, obs_property_t prop,
item->setFlags(Qt::NoItemFlags);
}
QWidget *OBSPropertiesView::AddList(obs_property_t prop)
QWidget *OBSPropertiesView::AddList(obs_property_t prop, bool &warning)
{
const char *name = obs_property_name(prop);
QComboBox *combo = new QComboBox();
......@@ -213,6 +213,10 @@ QWidget *OBSPropertiesView::AddList(obs_property_t prop)
if (idx != -1)
combo->setCurrentIndex(idx);
QAbstractItemModel *model = combo->model();
warning = idx != -1 &&
model->flags(model->index(idx, 0)) == Qt::NoItemFlags;
WidgetInfo *info = new WidgetInfo(this, prop, combo);
connect(combo, SIGNAL(currentIndexChanged(int)), info,
SLOT(ControlChanged()));
......@@ -244,6 +248,7 @@ void OBSPropertiesView::AddProperty(obs_property_t property,
return;
QWidget *widget = nullptr;
bool warning = false;
switch (type) {
case OBS_PROPERTY_INVALID:
......@@ -264,7 +269,7 @@ void OBSPropertiesView::AddProperty(obs_property_t property,
AddPath(property, layout);
break;
case OBS_PROPERTY_LIST:
widget = AddList(property);
widget = AddList(property, warning);
break;
case OBS_PROPERTY_COLOR:
/* TODO */
......@@ -285,6 +290,9 @@ void OBSPropertiesView::AddProperty(obs_property_t property,
type != OBS_PROPERTY_BUTTON)
label = new QLabel(QT_UTF8(obs_property_description(property)));
if (warning && label) //TODO: select color based on background color
label->setStyleSheet("QLabel { color: red; }");
if (label && minSize) {
label->setMinimumWidth(minSize);
label->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
......
......@@ -65,7 +65,7 @@ private:
QWidget *AddPath(obs_property_t prop, QFormLayout *layout);
QWidget *AddInt(obs_property_t prop);
QWidget *AddFloat(obs_property_t prop);
QWidget *AddList(obs_property_t prop);
QWidget *AddList(obs_property_t prop, bool &warning);
QWidget *AddButton(obs_property_t prop);
void AddProperty(obs_property_t property, QFormLayout *layout);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册