From b5f56ff57942d9d70a7585bc94e581ac7f383f9c Mon Sep 17 00:00:00 2001 From: Palana Date: Sat, 21 Jun 2014 22:13:30 +0200 Subject: [PATCH] Highlight label in properties-view when a disabled list item is selected --- obs/properties-view.cpp | 12 ++++++++++-- obs/properties-view.hpp | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/obs/properties-view.cpp b/obs/properties-view.cpp index 5d7f5d307..39cb8e3d3 100644 --- a/obs/properties-view.cpp +++ b/obs/properties-view.cpp @@ -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); diff --git a/obs/properties-view.hpp b/obs/properties-view.hpp index e7acffdee..7c793bc30 100644 --- a/obs/properties-view.hpp +++ b/obs/properties-view.hpp @@ -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);