UI: Show help icon for properties with tooltips

This commit is contained in:
Matt Gajownik 2020-03-01 14:29:42 +11:00
parent e40f2cc155
commit 51948ebc87
4 changed files with 33 additions and 0 deletions

1
UI/forms/images/help.svg Normal file
View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" class="feather feather-help-circle"><circle cx="12" cy="12" r="10"></circle><path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"></path><line x1="12" y1="17" x2="12.01" y2="17"></line></svg>

After

Width:  |  Height:  |  Size: 367 B

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="rgb(82.352941%,82.352941%,82.352941%)" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" class="feather feather-help-circle"><circle cx="12" cy="12" r="10"></circle><path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"></path><line x1="12" y1="17" x2="12.01" y2="17"></line></svg>

After

Width:  |  Height:  |  Size: 392 B

View file

@ -17,6 +17,8 @@
<file>images/locked.svg</file>
<file>images/invisible.svg</file>
<file>images/visible.svg</file>
<file>images/help.svg</file>
<file>images/help_light.svg</file>
<file>images/trash.svg</file>
<file>images/revert.svg</file>
<file>images/sources/brush.svg</file>

View file

@ -1436,6 +1436,35 @@ void OBSPropertiesView::AddProperty(obs_property_t *property,
if (!widget)
return;
if (obs_property_long_description(property)) {
QString lStr = "<html>%1 <img src='%2' style=' \
vertical-align: bottom; \
' /></html>";
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<QCheckBox *>(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())