X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fwx%2Fcontent_menu.cc;h=daadab7d7d6ce15cb53ce2869a10ce9e7370b3a6;hb=258da8a37c21a87ba5a7aa1c3e6243280d5c8d10;hp=3bdaf259110bf0e0fdf9b204c5059f86ace3d54d;hpb=59e769023c392c332331567a1aea94660002c463;p=dcpomatic.git diff --git a/src/wx/content_menu.cc b/src/wx/content_menu.cc index 3bdaf2591..daadab7d7 100644 --- a/src/wx/content_menu.cc +++ b/src/wx/content_menu.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Carl Hetherington + Copyright (C) 2013-2015 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,8 +17,12 @@ */ -#include -#include +#include "content_menu.h" +#include "repeat_dialog.h" +#include "wx_util.h" +#include "timeline_video_content_view.h" +#include "timeline_audio_content_view.h" +#include "content_properties_dialog.h" #include "lib/playlist.h" #include "lib/film.h" #include "lib/image_content.h" @@ -27,9 +31,8 @@ #include "lib/job_manager.h" #include "lib/exceptions.h" #include "lib/dcp_content.h" -#include "content_menu.h" -#include "repeat_dialog.h" -#include "wx_util.h" +#include +#include using std::cout; using std::vector; @@ -41,6 +44,7 @@ enum { ID_repeat = 1, ID_join, ID_find_missing, + ID_properties, ID_re_examine, ID_kdm, ID_remove @@ -53,6 +57,7 @@ ContentMenu::ContentMenu (wxWindow* p) _repeat = _menu->Append (ID_repeat, _("Repeat...")); _join = _menu->Append (ID_join, _("Join")); _find_missing = _menu->Append (ID_find_missing, _("Find missing...")); + _properties = _menu->Append (ID_properties, _("Properties...")); _re_examine = _menu->Append (ID_re_examine, _("Re-examine...")); _kdm = _menu->Append (ID_kdm, _("Add KDM...")); _menu->AppendSeparator (); @@ -61,6 +66,7 @@ ContentMenu::ContentMenu (wxWindow* p) _parent->Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&ContentMenu::repeat, this), ID_repeat); _parent->Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&ContentMenu::join, this), ID_join); _parent->Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&ContentMenu::find_missing, this), ID_find_missing); + _parent->Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&ContentMenu::properties, this), ID_properties); _parent->Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&ContentMenu::re_examine, this), ID_re_examine); _parent->Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&ContentMenu::kdm, this), ID_kdm); _parent->Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&ContentMenu::remove, this), ID_remove); @@ -72,10 +78,11 @@ ContentMenu::~ContentMenu () } void -ContentMenu::popup (weak_ptr f, ContentList c, wxPoint p) +ContentMenu::popup (weak_ptr f, ContentList c, TimelineContentViewList v, wxPoint p) { _film = f; _content = c; + _views = v; _repeat->Enable (!_content.empty ()); int n = 0; @@ -88,6 +95,7 @@ ContentMenu::popup (weak_ptr f, ContentList c, wxPoint p) _join->Enable (n > 1); _find_missing->Enable (_content.size() == 1 && !_content.front()->paths_valid ()); + _properties->Enable (_content.size() == 1); _re_examine->Enable (!_content.empty ()); if (_content.size() == 1) { @@ -123,6 +131,7 @@ ContentMenu::repeat () d->Destroy (); _content.clear (); + _views.clear (); } void @@ -166,9 +175,46 @@ ContentMenu::remove () return; } - film->playlist()->remove (_content); + /* We are removing from the timeline if _views is not empty */ + bool handled = false; + if (!_views.empty ()) { + /* Special case: we only remove FFmpegContent if its video view is selected; + if not, and its audio view is selected, we unmap the audio. + */ + for (ContentList::iterator i = _content.begin(); i != _content.end(); ++i) { + shared_ptr fc = dynamic_pointer_cast (*i); + if (!fc) { + continue; + } + + shared_ptr video; + shared_ptr audio; + + for (TimelineContentViewList::iterator i = _views.begin(); i != _views.end(); ++i) { + shared_ptr v = dynamic_pointer_cast (*i); + shared_ptr a = dynamic_pointer_cast (*i); + if (v && v->content() == fc) { + video = v; + } else if (a && a->content() == fc) { + audio = a; + } + } + + if (!video && audio) { + AudioMapping m = fc->audio_mapping (); + m.unmap_all (); + fc->set_audio_mapping (m); + handled = true; + } + } + } + + if (!handled) { + film->playlist()->remove (_content); + } _content.clear (); + _views.clear (); } void @@ -209,7 +255,7 @@ ContentMenu::find_missing () shared_ptr j (new ExamineContentJob (film, content)); - j->Finished.connect ( + _job_connection = j->Finished.connect ( bind ( &ContentMenu::maybe_found_missing, this, @@ -274,3 +320,11 @@ ContentMenu::kdm () d->Destroy (); } + +void +ContentMenu::properties () +{ + ContentPropertiesDialog* d = new ContentPropertiesDialog (_parent, _content.front ()); + d->ShowModal (); + d->Destroy (); +}