浏览代码

Merge pull request #2444 from WizardCM/property-help-icon

UI: Show help icon for properties with tooltips
Jim 5 年之前
父节点
当前提交
521d0ce4b7
共有 4 个文件被更改,包括 33 次插入0 次删除
  1. 1 0
      UI/forms/images/help.svg
  2. 1 0
      UI/forms/images/help_light.svg
  3. 2 0
      UI/forms/obs.qrc
  4. 29 0
      UI/properties-view.cpp

+ 1 - 0
UI/forms/images/help.svg

@@ -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>

+ 1 - 0
UI/forms/images/help_light.svg

@@ -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>

+ 2 - 0
UI/forms/obs.qrc

@@ -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>

+ 29 - 0
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 = "<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())