소스 검색

UI: Increase float property decimals based on step

Values are no longer truncated if a small step is specified.
jpark37 4 년 전
부모
커밋
01cf13ac51
1개의 변경된 파일8개의 추가작업 그리고 0개의 파일을 삭제
  1. 8 0
      UI/properties-view.cpp

+ 8 - 0
UI/properties-view.cpp

@@ -400,6 +400,14 @@ void OBSPropertiesView::AddFloat(obs_property_t *prop, QFormLayout *layout,
 	spin->setToolTip(QT_UTF8(obs_property_long_description(prop)));
 	spin->setSuffix(QT_UTF8(suffix));
 
+	if (stepVal < 1.0) {
+		int decimals = (int)(log10(1.0 / stepVal) + 0.99);
+		constexpr int sane_limit = 8;
+		decimals = std::min(decimals, sane_limit);
+		if (decimals > spin->decimals())
+			spin->setDecimals(decimals);
+	}
+
 	WidgetInfo *info = new WidgetInfo(this, prop, spin);
 	children.emplace_back(info);