Use $HOME rather than hard-coded user name.
[dcpomatic.git] / src / wx / gain_calculator_dialog.cc
index 701856610a88145dd0b89a0ba982347a1ddcef48..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)
 {
@@ -37,7 +38,7 @@ GainCalculatorDialog::GainCalculatorDialog (wxWindow* parent)
        add (_("But I have to use fader"), true);
        _actual = add (new wxTextCtrl (this, wxID_ANY, wxT (""), wxDefaultPosition, wxDefaultSize, 0, wxTextValidator (wxFILTER_NUMERIC)));
 
-       BOOST_FOREACH (CinemaSoundProcessor const * i, CinemaSoundProcessor::all()) {
+       for (auto i: CinemaSoundProcessor::all()) {
                _processor->Append (std_to_wx(i->name()));
        }
 
@@ -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())),