Formatting / C++11 tidying.
[dcpomatic.git] / src / wx / email_dialog.cc
index 97f974a90050a17699c0bcb22d2eacacf815e6d3..4d3ae4fe135a54a26dd3f572d230962a82a57a0e 100644 (file)
@@ -22,7 +22,8 @@
 #include "wx_util.h"
 
 using std::string;
-using boost::shared_ptr;
+using std::shared_ptr;
+using boost::optional;
 
 EmailDialog::EmailDialog (wxWindow* parent)
        : TableDialog (parent, _("Email address"), 2, 1, true)
@@ -31,6 +32,8 @@ EmailDialog::EmailDialog (wxWindow* parent)
        _email = add (new wxTextCtrl (this, wxID_ANY, wxT (""), wxDefaultPosition, wxSize (400, -1)));
 
        layout ();
+
+       _email->SetFocus ();
 }
 
 void
@@ -39,8 +42,14 @@ EmailDialog::set (string address)
        _email->SetValue (std_to_wx (address));
 }
 
-string
+optional<string>
 EmailDialog::get () const
 {
-       return wx_to_std (_email->GetValue ());
+       string s = wx_to_std (_email->GetValue ());
+       if (s.empty ()) {
+               /* Invalid email address */
+               return optional<string> ();
+       }
+
+       return s;
 }