ソースを参照

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);