X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fwx%2Fcontent_menu.cc;h=2a91831341fc506bbd1ed739febb19db3c02c946;hb=f1dbcec7552052856369631e77c5eb160badd619;hp=14632d984797f83cbcc3949e6dfb62859d615591;hpb=8a05e8f7d58fb7411e091ae8161c351f735f7735;p=dcpomatic.git diff --git a/src/wx/content_menu.cc b/src/wx/content_menu.cc index 14632d984..2a9183134 100644 --- a/src/wx/content_menu.cc +++ b/src/wx/content_menu.cc @@ -66,6 +66,7 @@ enum { ContentMenu::ContentMenu (wxWindow* p) : _menu (new wxMenu) , _parent (p) + , _pop_up_open (false) { _repeat = _menu->Append (ID_repeat, _("Repeat...")); _join = _menu->Append (ID_join, _("Join")); @@ -80,27 +81,17 @@ ContentMenu::ContentMenu (wxWindow* p) _menu->AppendSeparator (); _remove = _menu->Append (ID_remove, _("Remove")); - _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::ov, this), ID_ov); - _parent->Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&ContentMenu::remove, this), ID_remove); - + _parent->Bind (wxEVT_MENU, boost::bind (&ContentMenu::repeat, this), ID_repeat); + _parent->Bind (wxEVT_MENU, boost::bind (&ContentMenu::join, this), ID_join); + _parent->Bind (wxEVT_MENU, boost::bind (&ContentMenu::find_missing, this), ID_find_missing); + _parent->Bind (wxEVT_MENU, boost::bind (&ContentMenu::properties, this), ID_properties); + _parent->Bind (wxEVT_MENU, boost::bind (&ContentMenu::re_examine, this), ID_re_examine); + _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::remove, this), ID_remove); _parent->Bind (wxEVT_MENU, boost::bind (&ContentMenu::cpl_selected, this, _1), 1, ID_repeat - 1); } -ContentMenu::~ContentMenu () -{ - delete _menu; - - BOOST_FOREACH (boost::signals2::connection& i, _job_connections) { - i.disconnect (); - } -} - void ContentMenu::popup (weak_ptr film, ContentList c, TimelineContentViewList v, wxPoint p) { @@ -152,6 +143,8 @@ ContentMenu::popup (weak_ptr film, ContentList c, TimelineContentViewList } } catch (dcp::DCPReadError) { /* The DCP is probably missing */ + } catch (dcp::KDMDecryptionError) { + /* We have an incorrect KDM */ } } else { _kdm->Enable (false); @@ -164,7 +157,9 @@ ContentMenu::popup (weak_ptr film, ContentList c, TimelineContentViewList _remove->Enable (!_content.empty ()); + _pop_up_open = true; _parent->PopupMenu (_menu, p); + _pop_up_open = false; } void @@ -285,8 +280,6 @@ ContentMenu::find_missing () return; } - shared_ptr content; - /* XXX: a bit nasty */ shared_ptr ic = dynamic_pointer_cast (_content.front ()); shared_ptr dc = dynamic_pointer_cast (_content.front ()); @@ -306,29 +299,35 @@ ContentMenu::find_missing () d->Destroy (); } + list > content; + if (r == wxID_OK) { - content = content_factory (film, path); + if (dc) { + content.push_back (shared_ptr (new DCPContent (film, path))); + } else { + content = content_factory (film, path); + } } - if (!content) { + if (content.empty ()) { return; } - shared_ptr j (new ExamineContentJob (film, content)); + BOOST_FOREACH (shared_ptr i, content) { + shared_ptr j (new ExamineContentJob (film, i)); - _job_connections.push_back ( j->Finished.connect ( bind ( &ContentMenu::maybe_found_missing, this, boost::weak_ptr (j), boost::weak_ptr (_content.front ()), - boost::weak_ptr (content) + boost::weak_ptr (i) ) - ) - ); + ); - JobManager::instance()->add (j); + JobManager::instance()->add (j); + } } void @@ -362,7 +361,7 @@ ContentMenu::maybe_found_missing (weak_ptr j, weak_ptr oc, weak_pt return; } - old_content->set_path (new_content->path (0)); + old_content->set_paths (new_content->paths()); } void @@ -376,9 +375,9 @@ ContentMenu::kdm () if (d->ShowModal() == wxID_OK) { try { - dcp->add_kdm (dcp::EncryptedKDM (dcp::file_to_string (wx_to_std (d->GetPath ())))); + dcp->add_kdm (dcp::EncryptedKDM (dcp::file_to_string (wx_to_std (d->GetPath ()), MAX_KDM_SIZE))); } catch (exception& e) { - error_dialog (_parent, wxString::Format (_("Could not load KDM (%s)"), e.what ())); + error_dialog (_parent, wxString::Format (_("Could not load KDM.")), std_to_wx(e.what())); d->Destroy (); return; } @@ -421,6 +420,10 @@ ContentMenu::properties () void ContentMenu::cpl_selected (wxCommandEvent& ev) { + if (!_pop_up_open) { + return; + } + DCPOMATIC_ASSERT (!_content.empty ()); shared_ptr dcp = dynamic_pointer_cast (_content.front ()); DCPOMATIC_ASSERT (dcp);