From 51948ebc8763c468c5e4b8a91d208fb4ff1e4192 Mon Sep 17 00:00:00 2001 From: Matt Gajownik Date: Sun, 1 Mar 2020 14:29:42 +1100 Subject: [PATCH] UI: Show help icon for properties with tooltips --- UI/forms/images/help.svg | 1 + UI/forms/images/help_light.svg | 1 + UI/forms/obs.qrc | 2 ++ UI/properties-view.cpp | 29 +++++++++++++++++++++++++++++ 4 files changed, 33 insertions(+) create mode 100644 UI/forms/images/help.svg create mode 100644 UI/forms/images/help_light.svg diff --git a/UI/forms/images/help.svg b/UI/forms/images/help.svg new file mode 100644 index 000000000..d1175742b --- /dev/null +++ b/UI/forms/images/help.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/UI/forms/images/help_light.svg b/UI/forms/images/help_light.svg new file mode 100644 index 000000000..5cd3c7df9 --- /dev/null +++ b/UI/forms/images/help_light.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/UI/forms/obs.qrc b/UI/forms/obs.qrc index 0cd6cf2ee..1e618445f 100644 --- a/UI/forms/obs.qrc +++ b/UI/forms/obs.qrc @@ -17,6 +17,8 @@ images/locked.svg images/invisible.svg images/visible.svg + images/help.svg + images/help_light.svg images/trash.svg images/revert.svg images/sources/brush.svg diff --git a/UI/properties-view.cpp b/UI/properties-view.cpp index 11cca078b..443136637 100644 --- a/UI/properties-view.cpp +++ b/UI/properties-view.cpp @@ -1436,6 +1436,35 @@ void OBSPropertiesView::AddProperty(obs_property_t *property, if (!widget) return; + if (obs_property_long_description(property)) { + QString lStr = "%1 "; + bool lightTheme = palette().text().color().redF() < 0.5; + QString file = lightTheme ? ":/res/images/help.svg" + : ":/res/images/help_light.svg"; + if (label) { + label->setText(lStr.arg(label->text(), file)); + label->setToolTip( + obs_property_long_description(property)); + } else if (type == OBS_PROPERTY_BOOL) { + QWidget *newWidget = new QWidget(); + QHBoxLayout *boxLayout = new QHBoxLayout(newWidget); + boxLayout->setContentsMargins(0, 0, 0, 0); + boxLayout->setAlignment(Qt::AlignLeft); + + QCheckBox *check = qobject_cast(widget); + QLabel *help = + new QLabel(lStr.arg(check->text(), file)); + help->setToolTip( + obs_property_long_description(property)); + check->setText(""); + boxLayout->addWidget(check); + boxLayout->addWidget(help); + widget = newWidget; + } + } + layout->addRow(label, widget); if (!lastFocused.empty())