Merge pull request #3198 from AngeredZeus/master

UI: Fix clickable text on boolean properties with tooltips
master
Jim 2020-07-27 16:12:38 -07:00 committed by GitHub
commit a41048b486
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 6 deletions

View File

@ -1443,28 +1443,42 @@ void OBSPropertiesView::AddProperty(obs_property_t *property,
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) {
QString lStr = "<html>%1 <img src='%2' style=' \
vertical-align: bottom; \
' /></html>";
label->setText(lStr.arg(label->text(), file));
label->setToolTip(
obs_property_long_description(property));
} else if (type == OBS_PROPERTY_BOOL) {
QString bStr = "<html> <img src='%1' style=' \
vertical-align: bottom; \
' /></html>";
const char *desc = obs_property_description(property);
QWidget *newWidget = new QWidget();
QHBoxLayout *boxLayout = new QHBoxLayout(newWidget);
boxLayout->setContentsMargins(0, 0, 0, 0);
boxLayout->setAlignment(Qt::AlignLeft);
boxLayout->setSpacing(0);
QCheckBox *check = qobject_cast<QCheckBox *>(widget);
QLabel *help =
new QLabel(lStr.arg(check->text(), file));
check->setText(desc);
check->setToolTip(
obs_property_long_description(property));
QLabel *help = new QLabel(check);
help->setText(bStr.arg(file));
help->setToolTip(
obs_property_long_description(property));
check->setText("");
boxLayout->addWidget(check);
boxLayout->addWidget(help);
widget = newWidget;