From: Carl Hetherington Date: Tue, 17 Aug 2021 20:16:43 +0000 (+0200) Subject: Add defaults for facility, studio, chain, distributor (#2075). X-Git-Tag: v2.15.158~8 X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=924f4edb20d14bc697956254951fb87513cf2e19 Add defaults for facility, studio, chain, distributor (#2075). --- diff --git a/src/lib/config.cc b/src/lib/config.cc index a8653a10c..ed00d274b 100644 --- a/src/lib/config.cc +++ b/src/lib/config.cc @@ -104,6 +104,7 @@ Config::set_defaults () _default_j2k_bandwidth = 150000000; _default_audio_delay = 0; _default_interop = false; + _default_metadata.clear (); _upload_after_make_dcp = false; _mail_server = ""; _mail_port = 25; @@ -313,6 +314,11 @@ try _default_j2k_bandwidth = f.optional_number_child("DefaultJ2KBandwidth").get_value_or (200000000); _default_audio_delay = f.optional_number_child("DefaultAudioDelay").get_value_or (0); _default_interop = f.optional_bool_child("DefaultInterop").get_value_or (false); + + for (auto const& i: f.node_children("DefaultMetadata")) { + _default_metadata[i->string_attribute("key")] = i->content(); + } + _default_kdm_directory = f.optional_string_child("DefaultKDMDirectory"); /* Read any cinemas that are still lying around in the config file @@ -690,6 +696,11 @@ Config::write_config () const root->add_child("DefaultAudioDelay")->add_child_text (raw_convert (_default_audio_delay)); /* [XML] DefaultInterop 1 to default new films to Interop, 0 for SMPTE. */ root->add_child("DefaultInterop")->add_child_text (_default_interop ? "1" : "0"); + for (auto const& i: _default_metadata) { + auto c = root->add_child("DefaultMetadata"); + c->set_attribute("key", i.first); + c->add_child_text(i.second); + } if (_default_kdm_directory) { /* [XML:opt] DefaultKDMDirectory Default directory to write KDMs to. */ root->add_child("DefaultKDMDirectory")->add_child_text (_default_kdm_directory->string ()); diff --git a/src/lib/config.h b/src/lib/config.h index 5b64922e6..46bd390cc 100644 --- a/src/lib/config.h +++ b/src/lib/config.h @@ -220,6 +220,10 @@ public: return _default_interop; } + std::map default_metadata () const { + return _default_metadata; + } + bool upload_after_make_dcp () { return _upload_after_make_dcp; } @@ -699,6 +703,10 @@ public: maybe_set (_default_interop, i); } + void set_default_metadata (std::map const& metadata) { + maybe_set (_default_metadata, metadata); + } + void set_upload_after_make_dcp (bool u) { maybe_set (_upload_after_make_dcp, u); } @@ -1180,6 +1188,7 @@ private: int _default_j2k_bandwidth; int _default_audio_delay; bool _default_interop; + std::map _default_metadata; /** Default directory to offer to write KDMs to; if it's not set, the home directory will be offered. */ diff --git a/src/lib/film.cc b/src/lib/film.cc index acfea9991..94e996e19 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -176,6 +176,20 @@ Film::Film (optional dir) { set_isdcf_date_today (); + auto metadata = Config::instance()->default_metadata(); + if (metadata.find("chain") != metadata.end()) { + _chain = metadata["chain"]; + } + if (metadata.find("distributor") != metadata.end()) { + _distributor = metadata["distributor"]; + } + if (metadata.find("facility") != metadata.end()) { + _facility = metadata["facility"]; + } + if (metadata.find("studio") != metadata.end()) { + _studio = metadata["studio"]; + } + _playlist_change_connection = _playlist->Change.connect (bind (&Film::playlist_change, this, _1)); _playlist_order_changed_connection = _playlist->OrderChange.connect (bind (&Film::playlist_order_changed, this)); _playlist_content_change_connection = _playlist->ContentChange.connect (bind (&Film::playlist_content_change, this, _1, _2, _3, _4)); diff --git a/src/wx/full_config_dialog.cc b/src/wx/full_config_dialog.cc index 4912db320..1d0c1e01a 100644 --- a/src/wx/full_config_dialog.cc +++ b/src/wx/full_config_dialog.cc @@ -313,6 +313,18 @@ private: _standard = new wxChoice (_panel, wxID_ANY); table->Add (_standard); + 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); + + table->Add (_enable_metadata["studio"] = new CheckBox (_panel, _("Default studio")), 0, wxALIGN_CENTRE_VERTICAL); + table->Add (_metadata["studio"] = new wxTextCtrl (_panel, wxID_ANY, wxT("")), 0, wxEXPAND); + + table->Add (_enable_metadata["chain"] = new CheckBox (_panel, _("Default chain")), 0, wxALIGN_CENTRE_VERTICAL); + table->Add (_metadata["chain"] = new wxTextCtrl (_panel, wxID_ANY, wxT("")), 0, wxEXPAND); + + table->Add (_enable_metadata["distributor"] = new CheckBox (_panel, _("Default distributor")), 0, wxALIGN_CENTRE_VERTICAL); + table->Add (_metadata["distributor"] = new wxTextCtrl (_panel, wxID_ANY, wxT("")), 0, wxEXPAND); + add_label_to_sizer (table, _panel, _("Default KDM directory"), true, 0, wxLEFT | wxRIGHT | wxALIGN_CENTRE_VERTICAL); #ifdef DCPOMATIC_USE_OWN_PICKER _kdm_directory = new DirPickerCtrl (_panel); @@ -352,6 +364,14 @@ private: _standard->Append (_("SMPTE")); _standard->Append (_("Interop")); _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)); + } + + for (auto const& i: _metadata) { + i.second->Bind (wxEVT_TEXT, boost::bind(&DefaultsPage::metadata_changed, this)); + } } void config_changed () @@ -380,6 +400,27 @@ 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 metadata = config->default_metadata(); + + for (auto const& i: metadata) { + _enable_metadata[i.first]->SetValue(true); + checked_set (_metadata[i.first], i.second); + } + + for (auto const& i: _enable_metadata) { + if (metadata.find(i.first) == metadata.end()) { + checked_set (i.second, false); + } + } + + for (auto const& i: _metadata) { + if (metadata.find(i.first) == metadata.end()) { + checked_set (i.second, wxT("")); + } + } + + setup_sensitivity (); } void j2k_bandwidth_changed () @@ -434,6 +475,25 @@ private: Config::instance()->set_default_interop (_standard->GetSelection() == 1); } + void metadata_changed () + { + map metadata; + for (auto const& i: _enable_metadata) { + if (i.second->GetValue()) { + metadata[i.first] = wx_to_std(_metadata[i.first]->GetValue()); + } + } + Config::instance()->set_default_metadata (metadata); + setup_sensitivity (); + } + + void setup_sensitivity () + { + for (auto const& i: _enable_metadata) { + _metadata[i.first]->Enable(i.second->GetValue()); + } + } + wxSpinCtrl* _j2k_bandwidth; wxSpinCtrl* _audio_delay; wxSpinCtrl* _still_length; @@ -448,6 +508,8 @@ private: wxChoice* _dcp_content_type; wxChoice* _dcp_audio_channels; wxChoice* _standard; + map _enable_metadata; + map _metadata; };