X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fwx%2Ffull_config_dialog.cc;h=3b9955beaedfc5961a01dffd9e2ee93ed99184cc;hb=b9a1ad3df5f9d85fb7439efd93fede72b9b078af;hp=127ca412973ba10800248d7cf9ad4b60d96afc26;hpb=7bc591abc86ed4742f21f45ca1d6151cb14bc100;p=dcpomatic.git diff --git a/src/wx/full_config_dialog.cc b/src/wx/full_config_dialog.cc index 127ca4129..3b9955bea 100644 --- a/src/wx/full_config_dialog.cc +++ b/src/wx/full_config_dialog.cc @@ -39,24 +39,29 @@ #include "nag_dialog.h" #include "name_format_editor.h" #include "password_entry.h" +#include "send_test_email_dialog.h" #include "server_dialog.h" #include "static_text.h" #include "wx_util.h" #include "lib/config.h" #include "lib/cross.h" #include "lib/dcp_content_type.h" +#include "lib/emailer.h" #include "lib/exceptions.h" #include "lib/filter.h" #include "lib/log.h" #include "lib/ratio.h" #include "lib/util.h" +#include "lib/warnings.h" #include #include #include +DCPOMATIC_DISABLE_WARNINGS #include #include #include #include +DCPOMATIC_ENABLE_WARNINGS #include #include #include @@ -87,7 +92,7 @@ public: {} private: - void setup () + void setup () override { auto table = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP); _panel->GetSizer()->Add (table, 1, wxALL | wxEXPAND, _border); @@ -144,7 +149,7 @@ private: _automatic_audio_analysis->Bind (wxEVT_CHECKBOX, boost::bind (&FullGeneralPage::automatic_audio_analysis_changed, this)); } - void config_changed () + void config_changed () override { auto config = Config::instance (); @@ -244,20 +249,20 @@ public: : Page (panel_size, border) {} - wxString GetName () const + wxString GetName () const override { return _("Defaults"); } #ifdef DCPOMATIC_OSX - wxBitmap GetLargeIcon () const + wxBitmap GetLargeIcon () const override { return wxBitmap(bitmap_path("defaults"), wxBITMAP_TYPE_PNG); } #endif private: - void setup () + void setup () override { auto table = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP); table->AddGrowableCol (1, 1); @@ -383,7 +388,7 @@ private: } } - void config_changed () + void config_changed () override { auto config = Config::instance (); @@ -543,20 +548,20 @@ public: : Page (panel_size, border) {} - wxString GetName () const + wxString GetName () const override { return _("Servers"); } #ifdef DCPOMATIC_OSX - wxBitmap GetLargeIcon () const + wxBitmap GetLargeIcon () const override { return wxBitmap(bitmap_path("servers"), wxBITMAP_TYPE_PNG); } #endif private: - void setup () + void setup () override { _use_any_servers = new CheckBox (_panel, _("Search network for servers")); _panel->GetSizer()->Add (_use_any_servers, 0, wxALL, _border); @@ -576,7 +581,7 @@ private: _use_any_servers->Bind (wxEVT_CHECKBOX, boost::bind(&EncodingServersPage::use_any_servers_changed, this)); } - void config_changed () + void config_changed () override { checked_set (_use_any_servers, Config::instance()->use_any_servers ()); _servers_list->refresh (); @@ -604,20 +609,20 @@ public: : Page (panel_size, border) {} - wxString GetName () const + wxString GetName () const override { return _("TMS"); } #ifdef DCPOMATIC_OSX - wxBitmap GetLargeIcon () const + wxBitmap GetLargeIcon () const override { return wxBitmap(bitmap_path("tms"), wxBITMAP_TYPE_PNG); } #endif private: - void setup () + void setup () override { _upload = new CheckBox (_panel, _("Upload DCP to TMS after creation")); _panel->GetSizer()->Add (_upload, 0, wxALL | wxEXPAND, _border); @@ -657,7 +662,7 @@ private: _tms_password->Changed.connect (boost::bind (&TMSPage::tms_password_changed, this)); } - void config_changed () + void config_changed () override { auto config = Config::instance (); @@ -715,20 +720,20 @@ public: : Page (panel_size, border) {} - wxString GetName () const + wxString GetName () const override { return _("Email"); } #ifdef DCPOMATIC_OSX - wxBitmap GetLargeIcon () const + wxBitmap GetLargeIcon () const override { return wxBitmap(bitmap_path("email"), wxBITMAP_TYPE_PNG); } #endif private: - void setup () + void setup () override { auto table = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP); table->AddGrowableCol (1, 1); @@ -762,14 +767,19 @@ private: _password = new PasswordEntry (_panel); table->Add (_password->get_panel(), 1, wxEXPAND | wxALL); + table->AddSpacer (0); + _send_test_email = new Button (_panel, _("Send test email...")); + table->Add (_send_test_email); + _server->Bind (wxEVT_TEXT, boost::bind(&EmailPage::server_changed, this)); _port->Bind (wxEVT_SPINCTRL, boost::bind(&EmailPage::port_changed, this)); _protocol->Bind (wxEVT_CHOICE, boost::bind(&EmailPage::protocol_changed, this)); _user->Bind (wxEVT_TEXT, boost::bind(&EmailPage::user_changed, this)); _password->Changed.connect (boost::bind(&EmailPage::password_changed, this)); + _send_test_email->Bind (wxEVT_BUTTON, boost::bind(&EmailPage::send_test_email_clicked, this)); } - void config_changed () + void config_changed () override { auto config = Config::instance (); @@ -831,11 +841,41 @@ private: Config::instance()->set_mail_password(_password->get()); } + void send_test_email_clicked () + { + auto dialog = new SendTestEmailDialog(_panel); + auto result = dialog->ShowModal(); + dialog->Destroy(); + if (result == wxID_OK) { + Emailer emailer( + wx_to_std(dialog->from()), + { wx_to_std(dialog->to()) }, + wx_to_std(_("DCP-o-matic test email")), + wx_to_std(_("This is a test email from DCP-o-matic.")) + ); + auto config = Config::instance(); + try { + emailer.send (config->mail_server(), config->mail_port(), config->mail_protocol(), config->mail_user(), config->mail_password()); + } catch (NetworkError& e) { + error_dialog (_panel, std_to_wx(e.summary()), std_to_wx(e.detail().get_value_or(""))); + return; + } catch (std::exception& e) { + error_dialog (_panel, _("Test email sending failed."), std_to_wx(e.what())); + return; + } catch (...) { + error_dialog (_panel, _("Test email sending failed.")); + return; + } + message_dialog (_panel, _("Test email sent.")); + } + } + wxTextCtrl* _server; wxSpinCtrl* _port; wxChoice* _protocol; wxTextCtrl* _user; PasswordEntry* _password; + Button* _send_test_email; }; @@ -852,20 +892,20 @@ public: #endif {} - wxString GetName () const + wxString GetName () const override { return _("KDM Email"); } #ifdef DCPOMATIC_OSX - wxBitmap GetLargeIcon () const + wxBitmap GetLargeIcon () const override { return wxBitmap(bitmap_path("kdm_email"), wxBITMAP_TYPE_PNG); } #endif private: - void setup () + void setup () override { auto table = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP); table->AddGrowableCol (1, 1); @@ -911,9 +951,9 @@ private: _reset_email->Bind (wxEVT_BUTTON, boost::bind (&KDMEmailPage::reset_email, this)); } - void config_changed () + void config_changed () override { - Config* config = Config::instance (); + auto config = Config::instance (); checked_set (_subject, config->kdm_subject ()); checked_set (_from, config->kdm_from ()); @@ -974,20 +1014,20 @@ public: #endif {} - wxString GetName () const + wxString GetName () const override { return _("Notifications"); } #ifdef DCPOMATIC_OSX - wxBitmap GetLargeIcon () const + wxBitmap GetLargeIcon () const override { return wxBitmap(bitmap_path("notifications"), wxBITMAP_TYPE_PNG); } #endif private: - void setup () + void setup () override { auto table = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP); table->AddGrowableCol (1, 1); @@ -1063,7 +1103,7 @@ private: _reset_email->Enable(s); } - void config_changed () + void config_changed () override { auto config = Config::instance (); @@ -1147,20 +1187,20 @@ public: #endif {} - wxString GetName () const + wxString GetName () const override { return _("Cover Sheet"); } #ifdef DCPOMATIC_OSX - wxBitmap GetLargeIcon () const + wxBitmap GetLargeIcon () const override { return wxBitmap(bitmap_path("cover_sheet"), wxBITMAP_TYPE_PNG); } #endif private: - void setup () + void setup () override { _cover_sheet = new wxTextCtrl (_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (-1, 200), wxTE_MULTILINE); _panel->GetSizer()->Add (_cover_sheet, 0, wxEXPAND | wxALL, _border); @@ -1172,7 +1212,7 @@ private: _reset_cover_sheet->Bind (wxEVT_BUTTON, boost::bind (&CoverSheetPage::reset_cover_sheet, this)); } - void config_changed () + void config_changed () override { checked_set (_cover_sheet, Config::instance()->cover_sheet()); } @@ -1206,20 +1246,20 @@ public: : Page (panel_size, border) {} - wxString GetName () const + wxString GetName () const override { return _("Identifiers"); } #ifdef DCPOMATIC_OSX - wxBitmap GetLargeIcon () const + wxBitmap GetLargeIcon () const override { return wxBitmap(bitmap_path("identifiers"), wxBITMAP_TYPE_PNG); } #endif private: - void setup () + void setup () override { auto table = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP); table->AddGrowableCol (1, 1); @@ -1264,7 +1304,7 @@ private: _j2k_comment->Bind (wxEVT_TEXT, boost::bind(&IdentifiersPage::j2k_comment_changed, this)); } - void config_changed () + void config_changed () override { auto config = Config::instance (); checked_set (_issuer, config->dcp_issuer ()); @@ -1324,13 +1364,13 @@ public: : Page (panel_size, border) {} - wxString GetName () const + wxString GetName () const override { return _("Advanced"); } #ifdef DCPOMATIC_OSX - wxBitmap GetLargeIcon () const + wxBitmap GetLargeIcon () const override { return wxBitmap(bitmap_path("advanced"), wxBITMAP_TYPE_PNG); } @@ -1348,7 +1388,7 @@ private: table->Add (m, 0, flags, DCPOMATIC_SIZER_Y_GAP); } - void setup () + void setup () override { auto table = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP); table->AddGrowableCol (1, 1); @@ -1508,7 +1548,7 @@ private: #endif } - void config_changed () + void config_changed () override { auto config = Config::instance ();