Move some methods out of util.{cc,h}
[dcpomatic.git] / src / wx / gain_calculator_dialog.cc
index 9c8b87dac42bd622df15700be21a9551ca8a567c..62708fd224526d64f2b455c719c4a6e8ba2d468f 100644 (file)
 
 #include "gain_calculator_dialog.h"
 #include "wx_util.h"
-#include "lib/util.h"
 #include "lib/cinema_sound_processor.h"
 
+
 using boost::optional;
 
+
 GainCalculatorDialog::GainCalculatorDialog (wxWindow* parent)
        : TableDialog (parent, _("Gain Calculator"), 2, 1, true)
 {
@@ -50,9 +51,19 @@ optional<float>
 GainCalculatorDialog::db_change () const
 {
        if (_wanted->GetValue().IsEmpty() || _actual->GetValue().IsEmpty()) {
-               return optional<float>();
+               return {};
        }
 
+       auto relaxed_string_to_float = [](std::string s) {
+               try {
+                       boost::algorithm::replace_all(s, ",", ".");
+                       return boost::lexical_cast<float>(s);
+               } catch (boost::bad_lexical_cast &) {
+                       boost::algorithm::replace_all(s, ".", ",");
+                       return boost::lexical_cast<float>(s);
+               }
+       };
+
        return CinemaSoundProcessor::from_index(
                _processor->GetSelection())->db_for_fader_change(
                        relaxed_string_to_float(wx_to_std(_wanted->GetValue())),