X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fwx%2Ffull_config_dialog.cc;h=7aea87c73ddeb8438150e40e9578ace618e60d7c;hb=7aab34abcab28ca38a5354dec075b56d430e82db;hp=1eb87d93e70b05f419b0b65cb0f88dcad46c7112;hpb=0d7d4fb3472a30f7706baab0703114ec32d5a2af;p=dcpomatic.git diff --git a/src/wx/full_config_dialog.cc b/src/wx/full_config_dialog.cc index 1eb87d93e..7aea87c73 100644 --- a/src/wx/full_config_dialog.cc +++ b/src/wx/full_config_dialog.cc @@ -28,6 +28,7 @@ #include "config_dialog.h" #include "config_move_dialog.h" #include "dcpomatic_button.h" +#include "dcpomatic_choice.h" #include "dir_picker_ctrl.h" #include "editable_list.h" #include "email_dialog.h" @@ -35,10 +36,12 @@ #include "filter_dialog.h" #include "full_config_dialog.h" #include "kdm_choice.h" +#include "language_tag_widget.h" #include "make_chain_dialog.h" #include "nag_dialog.h" #include "name_format_editor.h" #include "password_entry.h" +#include "region_subtag_widget.h" #include "send_test_email_dialog.h" #include "server_dialog.h" #include "static_text.h" @@ -122,6 +125,11 @@ private: table->Add (export_cinemas, wxGBPosition (r, 2)); ++r; + add_label_to_sizer(table, _panel, _("Default \"add file\" location"), true, wxGBPosition(r, 0)); + _default_add_file_location = new Choice(_panel); + table->Add(_default_add_file_location, wxGBPosition(r, 1)); + ++r; + #ifdef DCPOMATIC_HAVE_EBUR128_PATCHED_FFMPEG _analyse_ebur128 = new CheckBox (_panel, _("Find integrated loudness, true peak and loudness range when analysing audio")); table->Add (_analyse_ebur128, wxGBPosition (r, 0), wxGBSpan (1, 2)); @@ -134,6 +142,10 @@ private: add_update_controls (table, r); + _default_add_file_location->add(_("Same place as last time")); + _default_add_file_location->add(_("Same place as project")); + _default_add_file_location->bind(&FullGeneralPage::default_add_file_location_changed, this); + _config_file->Bind (wxEVT_FILEPICKER_CHANGED, boost::bind(&FullGeneralPage::config_file_changed, this)); _cinemas_file->Bind (wxEVT_FILEPICKER_CHANGED, boost::bind(&FullGeneralPage::cinemas_file_changed, this)); @@ -144,9 +156,9 @@ private: export_cinemas->Bind (wxEVT_BUTTON, boost::bind (&FullGeneralPage::export_cinemas_file, this)); #ifdef DCPOMATIC_HAVE_EBUR128_PATCHED_FFMPEG - _analyse_ebur128->Bind (wxEVT_CHECKBOX, boost::bind (&FullGeneralPage::analyse_ebur128_changed, this)); + _analyse_ebur128->bind(&FullGeneralPage::analyse_ebur128_changed, this); #endif - _automatic_audio_analysis->Bind (wxEVT_CHECKBOX, boost::bind (&FullGeneralPage::automatic_audio_analysis_changed, this)); + _automatic_audio_analysis->bind(&FullGeneralPage::automatic_audio_analysis_changed, this); } void config_changed () override @@ -161,21 +173,21 @@ private: checked_set (_automatic_audio_analysis, config->automatic_audio_analysis ()); checked_set (_config_file, config->config_read_file()); checked_set (_cinemas_file, config->cinemas_file()); + checked_set(_default_add_file_location, config->default_add_file_location() == Config::DefaultAddFileLocation::SAME_AS_LAST_TIME ? 0 : 1); GeneralPage::config_changed (); } void export_cinemas_file () { - auto d = new wxFileDialog ( + wxFileDialog dialog( _panel, _("Select Cinemas File"), wxEmptyString, wxEmptyString, wxT("XML files (*.xml)|*.xml"), wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); - if (d->ShowModal () == wxID_OK) { - boost::filesystem::copy_file(Config::instance()->cinemas_file(), wx_to_std(d->GetPath()), boost::filesystem::copy_option::overwrite_if_exists); + if (dialog.ShowModal() == wxID_OK) { + boost::filesystem::copy_file(Config::instance()->cinemas_file(), wx_to_std(dialog.GetPath()), boost::filesystem::copy_option::overwrite_if_exists); } - d->Destroy (); } #ifdef DCPOMATIC_HAVE_EBUR128_PATCHED_FFMPEG @@ -209,11 +221,10 @@ private: } bool copy_and_link = true; if (boost::filesystem::exists(new_file)) { - auto d = new ConfigMoveDialog (_panel, new_file); - if (d->ShowModal() == wxID_OK) { + ConfigMoveDialog dialog(_panel, new_file); + if (dialog.ShowModal() == wxID_OK) { copy_and_link = false; } - d->Destroy (); } if (copy_and_link) { @@ -231,14 +242,22 @@ private: Config::instance()->set_cinemas_file (wx_to_std (_cinemas_file->GetPath ())); } + void default_add_file_location_changed() + { + Config::instance()->set_default_add_file_location( + _default_add_file_location->get().get_value_or(0) == 0 ? Config::DefaultAddFileLocation::SAME_AS_LAST_TIME : Config::DefaultAddFileLocation::SAME_AS_PROJECT + ); + } + + Choice* _default_add_file_location; wxSpinCtrl* _master_encoding_threads; wxSpinCtrl* _server_encoding_threads; FilePickerCtrl* _config_file; FilePickerCtrl* _cinemas_file; #ifdef DCPOMATIC_HAVE_EBUR128_PATCHED_FFMPEG - wxCheckBox* _analyse_ebur128; + CheckBox* _analyse_ebur128; #endif - wxCheckBox* _automatic_audio_analysis; + CheckBox* _automatic_audio_analysis; }; @@ -285,10 +304,6 @@ private: #endif table->Add (_directory, 1, wxEXPAND); - add_label_to_sizer (table, _panel, _("Default container"), true, 0, wxLEFT | wxRIGHT | wxALIGN_CENTRE_VERTICAL); - _container = new wxChoice (_panel, wxID_ANY); - table->Add (_container); - add_label_to_sizer (table, _panel, _("Default content type"), true, 0, wxLEFT | wxRIGHT | wxALIGN_CENTRE_VERTICAL); _dcp_content_type = new wxChoice (_panel, wxID_ANY); table->Add (_dcp_content_type); @@ -319,6 +334,16 @@ private: _standard = new wxChoice (_panel, wxID_ANY); table->Add (_standard); + _enable_audio_language = new CheckBox(_panel, _("Default audio language")); + table->Add(_enable_audio_language, 1, wxEXPAND | wxALIGN_CENTRE_VERTICAL); + _audio_language = new LanguageTagWidget(_panel, _("Default audio language to use for new DCPs"), Config::instance()->default_audio_language(), wxString("cmnr-Hant-")); + table->Add(_audio_language->sizer()); + + _enable_territory = new CheckBox(_panel, _("Default territory")); + table->Add(_enable_territory, 1, wxEXPAND | wxALIGN_CENTRE_VERTICAL); + _territory = new RegionSubtagWidget(_panel, _("Default territory to use for new DCPs"), Config::instance()->default_territory(), wxString("cmnr-Hant-")); + table->Add(_territory->sizer()); + table->Add (_enable_metadata["facility"] = new CheckBox (_panel, _("Default facility")), 0, wxALIGN_CENTRE_VERTICAL); table->Add (_metadata["facility"] = new wxTextCtrl (_panel, wxID_ANY, wxT("")), 0, wxEXPAND); @@ -367,13 +392,7 @@ private: _kdm_duration->Bind (wxEVT_SPINCTRL, boost::bind(&DefaultsPage::kdm_duration_changed, this)); _kdm_duration_unit->Bind (wxEVT_CHOICE, boost::bind(&DefaultsPage::kdm_duration_changed, this)); - _use_isdcf_name_by_default->Bind (wxEVT_CHECKBOX, boost::bind(&DefaultsPage::use_isdcf_name_by_default_changed, this)); - - for (auto i: Ratio::containers()) { - _container->Append (std_to_wx(i->container_nickname())); - } - - _container->Bind (wxEVT_CHOICE, boost::bind (&DefaultsPage::container_changed, this)); + _use_isdcf_name_by_default->bind(&DefaultsPage::use_isdcf_name_by_default_changed, this); for (auto i: DCPContentType::all()) { _dcp_content_type->Append (std_to_wx (i->pretty_name ())); @@ -395,25 +414,24 @@ private: _standard->Bind (wxEVT_CHOICE, boost::bind (&DefaultsPage::standard_changed, this)); for (auto const& i: _enable_metadata) { - i.second->Bind (wxEVT_CHECKBOX, boost::bind(&DefaultsPage::metadata_changed, this)); + i.second->bind(&DefaultsPage::metadata_changed, this); } for (auto const& i: _metadata) { i.second->Bind (wxEVT_TEXT, boost::bind(&DefaultsPage::metadata_changed, this)); } + + _enable_audio_language->bind(&DefaultsPage::enable_audio_language_toggled, this); + _audio_language->Changed.connect(boost::bind(&DefaultsPage::audio_language_changed, this)); + + _enable_territory->bind(&DefaultsPage::enable_territory_toggled, this); + _territory->Changed.connect(boost::bind(&DefaultsPage::territory_changed, this)); } void config_changed () override { auto config = Config::instance (); - auto containers = Ratio::containers (); - for (size_t i = 0; i < containers.size(); ++i) { - if (containers[i] == config->default_container()) { - _container->SetSelection (i); - } - } - auto const ct = DCPContentType::all (); for (size_t i = 0; i < ct.size(); ++i) { if (ct[i] == config->default_dcp_content_type()) { @@ -431,6 +449,12 @@ private: checked_set (_dcp_audio_channels, locale_convert (config->default_dcp_audio_channels())); checked_set (_audio_delay, config->default_audio_delay ()); checked_set (_standard, config->default_interop() ? 1 : 0); + auto dal = config->default_audio_language(); + checked_set(_enable_audio_language, static_cast(dal)); + checked_set(_audio_language, dal ? dal : boost::none); + auto dt = config->default_territory(); + checked_set(_enable_territory, static_cast(dt)); + checked_set(_territory, dt ? dt : boost::none); auto metadata = config->default_metadata(); @@ -541,12 +565,6 @@ private: Config::instance()->set_default_still_length (_still_length->GetValue ()); } - void container_changed () - { - auto ratio = Ratio::containers (); - Config::instance()->set_default_container (ratio[_container->GetSelection()]); - } - void dcp_content_type_changed () { auto ct = DCPContentType::all (); @@ -570,8 +588,40 @@ private: setup_sensitivity (); } + void enable_audio_language_toggled() + { + setup_sensitivity(); + audio_language_changed(); + } + + void audio_language_changed() + { + if (_enable_audio_language->get()) { + Config::instance()->set_default_audio_language(_audio_language->get().get_value_or(dcp::LanguageTag("en-US"))); + } else { + Config::instance()->unset_default_audio_language(); + } + } + + void enable_territory_toggled() + { + setup_sensitivity(); + territory_changed(); + } + + void territory_changed() + { + if (_enable_territory->get()) { + Config::instance()->set_default_territory(_territory->get().get_value_or(dcp::LanguageTag::RegionSubtag("US"))); + } else { + Config::instance()->unset_default_territory(); + } + } + void setup_sensitivity () { + _audio_language->enable(_enable_audio_language->get()); + _territory->enable(_enable_territory->get()); for (auto const& i: _enable_metadata) { _metadata[i.first]->Enable(i.second->GetValue()); } @@ -590,11 +640,14 @@ private: KDMChoice* _kdm_type; wxSpinCtrl* _kdm_duration; wxChoice* _kdm_duration_unit; - wxCheckBox* _use_isdcf_name_by_default; - wxChoice* _container; + CheckBox* _use_isdcf_name_by_default; wxChoice* _dcp_content_type; wxChoice* _dcp_audio_channels; wxChoice* _standard; + CheckBox* _enable_audio_language; + LanguageTagWidget* _audio_language; + CheckBox* _enable_territory; + RegionSubtagWidget* _territory; map _enable_metadata; map _metadata; }; @@ -639,7 +692,7 @@ private: _panel->GetSizer()->Add (_servers_list, 1, wxEXPAND | wxALL, _border); - _use_any_servers->Bind (wxEVT_CHECKBOX, boost::bind(&EncodingServersPage::use_any_servers_changed, this)); + _use_any_servers->bind(&EncodingServersPage::use_any_servers_changed, this); } void config_changed () override @@ -658,7 +711,7 @@ private: return s; } - wxCheckBox* _use_any_servers; + CheckBox* _use_any_servers; EditableList* _servers_list; }; @@ -719,7 +772,7 @@ private: _tms_protocol->Append (_("SCP (for AAM and Doremi)")); _tms_protocol->Append (_("FTP (for Dolby)")); - _upload->Bind (wxEVT_CHECKBOX, boost::bind(&TMSPage::upload_changed, this)); + _upload->bind(&TMSPage::upload_changed, this); _tms_protocol->Bind (wxEVT_CHOICE, boost::bind (&TMSPage::tms_protocol_changed, this)); _tms_passive->bind(&TMSPage::tms_passive_changed, this); @@ -919,31 +972,31 @@ private: 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.")); + SendTestEmailDialog dialog(_panel); + if (dialog.ShowModal() != wxID_OK) { + return; + } + + 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; @@ -1160,8 +1213,8 @@ private: _cc->layout (); - _enable_message_box->Bind (wxEVT_CHECKBOX, boost::bind (&NotificationsPage::type_changed, this, _enable_message_box, Config::MESSAGE_BOX)); - _enable_email->Bind (wxEVT_CHECKBOX, boost::bind (&NotificationsPage::type_changed, this, _enable_email, Config::EMAIL)); + _enable_message_box->bind(&NotificationsPage::type_changed, this, _enable_message_box, Config::MESSAGE_BOX); + _enable_email->bind(&NotificationsPage::type_changed, this, _enable_email, Config::EMAIL); _subject->Bind (wxEVT_TEXT, boost::bind (&NotificationsPage::notification_subject_changed, this)); _from->Bind (wxEVT_TEXT, boost::bind (&NotificationsPage::notification_from_changed, this)); @@ -1237,14 +1290,14 @@ private: checked_set (_email, Config::instance()->notification_email()); } - void type_changed (wxCheckBox* b, Config::Notification n) + void type_changed (CheckBox* b, Config::Notification n) { Config::instance()->set_notification(n, b->GetValue()); setup_sensitivity (); } - wxCheckBox* _enable_message_box; - wxCheckBox* _enable_email; + CheckBox* _enable_message_box; + CheckBox* _enable_email; wxTextCtrl* _subject; wxTextCtrl* _from; @@ -1614,27 +1667,27 @@ private: _video_display_mode->Append (_("OpenGL (faster)")); #endif _video_display_mode->Bind (wxEVT_CHOICE, boost::bind(&AdvancedPage::video_display_mode_changed, this)); - _allow_any_dcp_frame_rate->Bind (wxEVT_CHECKBOX, boost::bind (&AdvancedPage::allow_any_dcp_frame_rate_changed, this)); - _allow_any_container->Bind (wxEVT_CHECKBOX, boost::bind (&AdvancedPage::allow_any_container_changed, this)); - _allow_96khz_audio->Bind (wxEVT_CHECKBOX, boost::bind(&AdvancedPage::allow_96khz_audio_changed, this)); - _use_all_audio_channels->Bind(wxEVT_CHECKBOX, boost::bind(&AdvancedPage::use_all_channels_changed, this)); - _show_experimental_audio_processors->Bind (wxEVT_CHECKBOX, boost::bind (&AdvancedPage::show_experimental_audio_processors_changed, this)); - _only_servers_encode->Bind (wxEVT_CHECKBOX, boost::bind (&AdvancedPage::only_servers_encode_changed, this)); + _allow_any_dcp_frame_rate->bind(&AdvancedPage::allow_any_dcp_frame_rate_changed, this); + _allow_any_container->bind(&AdvancedPage::allow_any_container_changed, this); + _allow_96khz_audio->bind(&AdvancedPage::allow_96khz_audio_changed, this); + _use_all_audio_channels->bind(&AdvancedPage::use_all_channels_changed, this); + _show_experimental_audio_processors->bind(&AdvancedPage::show_experimental_audio_processors_changed, this); + _only_servers_encode->bind(&AdvancedPage::only_servers_encode_changed, this); _frames_in_memory_multiplier->Bind (wxEVT_SPINCTRL, boost::bind(&AdvancedPage::frames_in_memory_multiplier_changed, this)); _dcp_metadata_filename_format->Changed.connect (boost::bind (&AdvancedPage::dcp_metadata_filename_format_changed, this)); _dcp_asset_filename_format->Changed.connect (boost::bind (&AdvancedPage::dcp_asset_filename_format_changed, this)); - _log_general->Bind (wxEVT_CHECKBOX, boost::bind (&AdvancedPage::log_changed, this)); - _log_warning->Bind (wxEVT_CHECKBOX, boost::bind (&AdvancedPage::log_changed, this)); - _log_error->Bind (wxEVT_CHECKBOX, boost::bind (&AdvancedPage::log_changed, this)); - _log_timing->Bind (wxEVT_CHECKBOX, boost::bind (&AdvancedPage::log_changed, this)); - _log_debug_threed->Bind (wxEVT_CHECKBOX, boost::bind (&AdvancedPage::log_changed, this)); - _log_debug_encode->Bind (wxEVT_CHECKBOX, boost::bind (&AdvancedPage::log_changed, this)); - _log_debug_email->Bind (wxEVT_CHECKBOX, boost::bind (&AdvancedPage::log_changed, this)); - _log_debug_video_view->Bind (wxEVT_CHECKBOX, boost::bind (&AdvancedPage::log_changed, this)); - _log_debug_player->Bind (wxEVT_CHECKBOX, boost::bind (&AdvancedPage::log_changed, this)); - _log_debug_audio_analysis->Bind (wxEVT_CHECKBOX, boost::bind (&AdvancedPage::log_changed, this)); + _log_general->bind(&AdvancedPage::log_changed, this); + _log_warning->bind(&AdvancedPage::log_changed, this); + _log_error->bind(&AdvancedPage::log_changed, this); + _log_timing->bind(&AdvancedPage::log_changed, this); + _log_debug_threed->bind(&AdvancedPage::log_changed, this); + _log_debug_encode->bind(&AdvancedPage::log_changed, this); + _log_debug_email->bind(&AdvancedPage::log_changed, this); + _log_debug_video_view->bind(&AdvancedPage::log_changed, this); + _log_debug_player->bind(&AdvancedPage::log_changed, this); + _log_debug_audio_analysis->bind(&AdvancedPage::log_changed, this); #ifdef DCPOMATIC_WINDOWS - _win32_console->Bind (wxEVT_CHECKBOX, boost::bind (&AdvancedPage::win32_console_changed, this)); + _win32_console->bind(&AdvancedPage::win32_console_changed, this); #endif } @@ -1778,26 +1831,26 @@ private: wxSpinCtrl* _maximum_j2k_bandwidth = nullptr; wxChoice* _video_display_mode = nullptr; wxSpinCtrl* _frames_in_memory_multiplier = nullptr; - wxCheckBox* _allow_any_dcp_frame_rate = nullptr; - wxCheckBox* _allow_any_container = nullptr; - wxCheckBox* _allow_96khz_audio = nullptr; - wxCheckBox* _use_all_audio_channels = nullptr; - wxCheckBox* _show_experimental_audio_processors = nullptr; - wxCheckBox* _only_servers_encode = nullptr; + CheckBox* _allow_any_dcp_frame_rate = nullptr; + CheckBox* _allow_any_container = nullptr; + CheckBox* _allow_96khz_audio = nullptr; + CheckBox* _use_all_audio_channels = nullptr; + CheckBox* _show_experimental_audio_processors = nullptr; + CheckBox* _only_servers_encode = nullptr; NameFormatEditor* _dcp_metadata_filename_format = nullptr; NameFormatEditor* _dcp_asset_filename_format = nullptr; - wxCheckBox* _log_general = nullptr; - wxCheckBox* _log_warning = nullptr; - wxCheckBox* _log_error = nullptr; - wxCheckBox* _log_timing = nullptr; - wxCheckBox* _log_debug_threed = nullptr; - wxCheckBox* _log_debug_encode = nullptr; - wxCheckBox* _log_debug_email = nullptr; - wxCheckBox* _log_debug_video_view = nullptr; - wxCheckBox* _log_debug_player = nullptr; - wxCheckBox* _log_debug_audio_analysis = nullptr; + CheckBox* _log_general = nullptr; + CheckBox* _log_warning = nullptr; + CheckBox* _log_error = nullptr; + CheckBox* _log_timing = nullptr; + CheckBox* _log_debug_threed = nullptr; + CheckBox* _log_debug_encode = nullptr; + CheckBox* _log_debug_email = nullptr; + CheckBox* _log_debug_video_view = nullptr; + CheckBox* _log_debug_player = nullptr; + CheckBox* _log_debug_audio_analysis = nullptr; #ifdef DCPOMATIC_WINDOWS - wxCheckBox* _win32_console = nullptr; + CheckBox* _win32_console = nullptr; #endif };