From: Carl Hetherington Date: Sat, 14 Dec 2019 23:47:53 +0000 (+0100) Subject: Support content version metadata (#782). X-Git-Tag: v2.15.38~3 X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=3dfe3b92df03eee932f3c92336197559c11a5913 Support content version metadata (#782). --- diff --git a/src/lib/film.cc b/src/lib/film.cc index f7fd96a01..2a50e8c81 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -427,6 +427,7 @@ Film::metadata (bool with_content_paths) const BOOST_FOREACH (dcp::Rating i, _ratings) { i.as_xml (root->add_child("Rating")); } + root->add_child("ContentVersion")->add_child_text(_content_version); _playlist->as_xml (root->add_child ("Playlist"), with_content_paths); return doc; @@ -570,6 +571,8 @@ Film::read_metadata (optional path) _ratings.push_back (dcp::Rating(i)); } + _content_version = f.optional_string_child("ContentVersion").get_value_or(""); + list notes; _playlist->set_from_xml (shared_from_this(), f.node_child ("Playlist"), _state_version, notes); @@ -1763,6 +1766,13 @@ Film::set_ratings (vector r) _ratings = r; } +void +Film::set_content_version (string v) +{ + ChangeSignaller ch (this, CONTENT_VERSION); + _content_version = v; +} + optional Film::marker (dcp::Marker type) const { diff --git a/src/lib/film.h b/src/lib/film.h index 4c45c4ffc..68f8b5334 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -239,7 +239,8 @@ public: UPLOAD_AFTER_MAKE_DCP, REENCODE_J2K, MARKERS, - RATINGS + RATINGS, + CONTENT_VERSION }; @@ -344,6 +345,10 @@ public: return _ratings; } + std::string content_version () const { + return _content_version; + } + /* SET */ void set_directory (boost::filesystem::path); @@ -377,6 +382,7 @@ public: void set_marker (dcp::Marker type, dcpomatic::DCPTime time); void unset_marker (dcp::Marker type); void set_ratings (std::vector r); + void set_content_version (std::string v); /** Emitted when some property has of the Film is about to change or has changed */ mutable boost::signals2::signal Change; @@ -461,6 +467,7 @@ private: bool _user_explicit_video_frame_rate; std::map _markers; std::vector _ratings; + std::string _content_version; int _state_version; diff --git a/src/lib/writer.cc b/src/lib/writer.cc index 48f40334a..cc645c8b0 100644 --- a/src/lib/writer.cc +++ b/src/lib/writer.cc @@ -561,6 +561,7 @@ Writer::finish () cpl->set_metadata (meta); cpl->set_ratings (vector_to_list(_film->ratings())); + cpl->set_content_version_label_text (_film->content_version()); shared_ptr signer; if (_film->is_signed ()) { diff --git a/src/wx/metadata_dialog.cc b/src/wx/metadata_dialog.cc index 339ff869c..5462db6a4 100644 --- a/src/wx/metadata_dialog.cc +++ b/src/wx/metadata_dialog.cc @@ -73,6 +73,14 @@ MetadataDialog::MetadataDialog (wxWindow* parent, weak_ptr film) ); sizer->Add (_ratings, 1, wxEXPAND); + add_label_to_sizer (sizer, this, _("Content version"), true); + _content_version = new wxTextCtrl (this, wxID_ANY); + sizer->Add (_content_version, 1, wxEXPAND); + + shared_ptr f = _film.lock(); + DCPOMATIC_ASSERT (f); + _content_version->SetValue (std_to_wx(f->content_version())); + overall_sizer->Add (sizer, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER); wxSizer* buttons = CreateSeparatedButtonSizer (wxCLOSE); @@ -82,6 +90,8 @@ MetadataDialog::MetadataDialog (wxWindow* parent, weak_ptr film) overall_sizer->Layout (); overall_sizer->SetSizeHints (this); + + _content_version->Bind (wxEVT_TEXT, boost::bind(&MetadataDialog::content_version_changed, this)); } vector @@ -99,3 +109,11 @@ MetadataDialog::set_ratings (vector r) DCPOMATIC_ASSERT (film); film->set_ratings (r); } + +void +MetadataDialog::content_version_changed () +{ + shared_ptr film = _film.lock (); + DCPOMATIC_ASSERT (film); + film->set_content_version (wx_to_std(_content_version->GetValue())); +} diff --git a/src/wx/metadata_dialog.h b/src/wx/metadata_dialog.h index 5c574a32b..892aa89df 100644 --- a/src/wx/metadata_dialog.h +++ b/src/wx/metadata_dialog.h @@ -36,7 +36,9 @@ public: private: std::vector ratings () const; void set_ratings (std::vector r); + void content_version_changed (); boost::weak_ptr _film; EditableList* _ratings; + wxTextCtrl* _content_version; };