Add options for where the add files dialog starts (#2413).
[dcpomatic.git] / src / wx / full_config_dialog.cc
index ba596162ec6c432dabe10838e8122c1dfe5b80e2..f7ed2b5beef491fb6810a2b1bf043e4a584a023f 100644 (file)
@@ -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"
 #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));
 
@@ -161,6 +173,7 @@ 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 ();
        }
@@ -231,6 +244,14 @@ 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;
@@ -315,6 +336,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);
 
@@ -391,6 +422,12 @@ private:
                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
@@ -414,6 +451,12 @@ private:
                checked_set (_dcp_audio_channels, locale_convert<string> (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<bool>(dal));
+               checked_set(_audio_language, dal ? dal : boost::none);
+               auto dt = config->default_territory();
+               checked_set(_enable_territory, static_cast<bool>(dt));
+               checked_set(_territory, dt ? dt : boost::none);
 
                auto metadata = config->default_metadata();
 
@@ -547,8 +590,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());
                }
@@ -571,6 +646,10 @@ private:
        wxChoice* _dcp_content_type;
        wxChoice* _dcp_audio_channels;
        wxChoice* _standard;
+       CheckBox* _enable_audio_language;
+       LanguageTagWidget* _audio_language;
+       CheckBox* _enable_territory;
+       RegionSubtagWidget* _territory;
        map<string, CheckBox*> _enable_metadata;
        map<string, wxTextCtrl*> _metadata;
 };