From ba438ecd16207700ffd849820796b6f833beef21 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 10 Oct 2023 01:05:27 +0200 Subject: Add new "copy markers from this DCP" option (#2628). Also stop the "copy settings" options from doing this, as Carsten points out that it could be confusing and potentially very bad if you copy markers from an OV to an edited VF which then bring house lights up at the wrong time or whatever. --- src/lib/copy_dcp_details_to_film.cc | 13 +++++++++---- src/lib/copy_dcp_details_to_film.h | 1 + src/wx/content_menu.cc | 21 +++++++++++++++++++++ src/wx/content_menu.h | 2 ++ 4 files changed, 33 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/lib/copy_dcp_details_to_film.cc b/src/lib/copy_dcp_details_to_film.cc index 206475ed6..669fc8ac9 100644 --- a/src/lib/copy_dcp_details_to_film.cc +++ b/src/lib/copy_dcp_details_to_film.cc @@ -61,12 +61,17 @@ copy_dcp_settings_to_film(shared_ptr dcp, shared_ptr fil film->set_audio_channels (dcp->audio->stream()->channels()); } + film->set_ratings (dcp->ratings()); + film->set_content_versions (dcp->content_versions()); +} + + +void +copy_dcp_markers_to_film(shared_ptr dcp, shared_ptr film) +{ film->clear_markers (); for (auto const& i: dcp->markers()) { - film->set_marker (i.first, dcpomatic::DCPTime(i.second.get())); + film->set_marker(i.first, dcpomatic::DCPTime(i.second.get())); } - - film->set_ratings (dcp->ratings()); - film->set_content_versions (dcp->content_versions()); } diff --git a/src/lib/copy_dcp_details_to_film.h b/src/lib/copy_dcp_details_to_film.h index 99f9cdeb7..0948cbec1 100644 --- a/src/lib/copy_dcp_details_to_film.h +++ b/src/lib/copy_dcp_details_to_film.h @@ -27,3 +27,4 @@ class Film; extern void copy_dcp_settings_to_film(std::shared_ptr dcp, std::shared_ptr film); +extern void copy_dcp_markers_to_film(std::shared_ptr dcp, std::shared_ptr film); diff --git a/src/wx/content_menu.cc b/src/wx/content_menu.cc index 722f4563b..8bb7e3526 100644 --- a/src/wx/content_menu.cc +++ b/src/wx/content_menu.cc @@ -83,6 +83,7 @@ enum { ID_ov, ID_choose_cpl, ID_set_dcp_settings, + ID_set_dcp_markers, ID_remove }; @@ -106,6 +107,7 @@ ContentMenu::ContentMenu(wxWindow* p, FilmViewer& viewer) _cpl_menu = new wxMenu (); _choose_cpl = _menu->Append (ID_choose_cpl, _("Choose CPL..."), _cpl_menu); _set_dcp_settings = _menu->Append (ID_set_dcp_settings, _("Set project DCP settings from this DCP")); + _set_dcp_markers = _menu->Append(ID_set_dcp_markers, _("Set project markers from this DCP")); _menu->AppendSeparator (); _remove = _menu->Append (ID_remove, _("Remove")); @@ -119,6 +121,7 @@ ContentMenu::ContentMenu(wxWindow* p, FilmViewer& viewer) _parent->Bind (wxEVT_MENU, boost::bind (&ContentMenu::kdm, this), ID_kdm); _parent->Bind (wxEVT_MENU, boost::bind (&ContentMenu::ov, this), ID_ov); _parent->Bind (wxEVT_MENU, boost::bind (&ContentMenu::set_dcp_settings, this), ID_set_dcp_settings); + _parent->Bind (wxEVT_MENU, boost::bind (&ContentMenu::set_dcp_markers, this), ID_set_dcp_markers); _parent->Bind (wxEVT_MENU, boost::bind (&ContentMenu::remove, this), ID_remove); _parent->Bind (wxEVT_MENU, boost::bind (&ContentMenu::cpl_selected, this, _1), 1, ID_repeat - 1); } @@ -158,6 +161,7 @@ ContentMenu::popup (weak_ptr film, ContentList c, TimelineContentViewList _kdm->Enable (dcp->encrypted ()); _ov->Enable (dcp->needs_assets ()); _set_dcp_settings->Enable (static_cast(dcp)); + _set_dcp_markers->Enable(static_cast(dcp)); try { auto cpls = dcp::find_and_resolve_cpls (dcp->directories(), true); _choose_cpl->Enable (cpls.size() > 1); @@ -186,10 +190,12 @@ ContentMenu::popup (weak_ptr film, ContentList c, TimelineContentViewList _ov->Enable (false); _choose_cpl->Enable (false); _set_dcp_settings->Enable (false); + _set_dcp_markers->Enable(false); } } else { _kdm->Enable (false); _set_dcp_settings->Enable (false); + _set_dcp_markers->Enable(false); } _remove->Enable (!_content.empty ()); @@ -215,6 +221,21 @@ ContentMenu::set_dcp_settings () } +void +ContentMenu::set_dcp_markers() +{ + auto film = _film.lock(); + if (!film) { + return; + } + + DCPOMATIC_ASSERT(_content.size() == 1); + auto dcp = dynamic_pointer_cast(_content.front()); + DCPOMATIC_ASSERT(dcp); + copy_dcp_markers_to_film(dcp, film); +} + + void ContentMenu::repeat () { diff --git a/src/wx/content_menu.h b/src/wx/content_menu.h index c750ae852..2f3250284 100644 --- a/src/wx/content_menu.h +++ b/src/wx/content_menu.h @@ -61,6 +61,7 @@ private: void kdm (); void ov (); void set_dcp_settings (); + void set_dcp_markers(); void remove (); void cpl_selected (wxCommandEvent& ev); @@ -84,6 +85,7 @@ private: wxMenuItem* _ov; wxMenuItem* _choose_cpl; wxMenuItem* _set_dcp_settings; + wxMenuItem* _set_dcp_markers; wxMenuItem* _remove; wx_ptr _auto_crop_dialog; -- cgit v1.2.3