X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fwx%2Fcontent_menu.cc;h=a80a5fc82e1dffda4a3a0019e5ddf02d186d68fc;hb=85b9d9e308c21eccf0ca27dd6d324888f203abfb;hp=7e465947999b802782c54bf374bcc6e29326ce35;hpb=c5e0f7894019d4d45fc331f34c3fa5cbcdd2b5ca;p=dcpomatic.git diff --git a/src/wx/content_menu.cc b/src/wx/content_menu.cc index 7e4659479..a80a5fc82 100644 --- a/src/wx/content_menu.cc +++ b/src/wx/content_menu.cc @@ -25,8 +25,8 @@ #include "content_properties_dialog.h" #include "film_viewer.h" #include "repeat_dialog.h" -#include "timeline_audio_content_view.h" #include "timeline_video_content_view.h" +#include "timeline_audio_content_view.h" #include "wx_util.h" #include "lib/audio_content.h" #include "lib/config.h" @@ -38,6 +38,7 @@ #include "lib/exceptions.h" #include "lib/ffmpeg_content.h" #include "lib/film.h" +#include "lib/find_missing.h" #include "lib/guess_crop.h" #include "lib/image_content.h" #include "lib/job_manager.h" @@ -342,46 +343,22 @@ ContentMenu::find_missing () boost::filesystem::path path; if ((ic && !ic->still ()) || dc) { - auto d = new wxDirDialog (0, _("Choose a folder"), wxT (""), wxDD_DIR_MUST_EXIST); + auto d = new wxDirDialog (nullptr, _("Choose a folder"), wxT (""), wxDD_DIR_MUST_EXIST); r = d->ShowModal (); - path = wx_to_std (d->GetPath ()); + path = wx_to_std (d->GetPath()); d->Destroy (); } else { - auto d = new wxFileDialog (0, _("Choose a file"), wxT (""), wxT (""), wxT ("*.*")); + auto d = new wxFileDialog (nullptr, _("Choose a file"), wxT (""), wxT (""), wxT ("*.*")); r = d->ShowModal (); - path = wx_to_std (d->GetPath ()); + path = wx_to_std (d->GetPath()); d->Destroy (); } - list> content; - - if (r == wxID_OK) { - if (dc) { - content.push_back (make_shared(path)); - } else { - content = content_factory (path); - } - } - - if (content.empty ()) { + if (r == wxID_CANCEL) { return; } - for (auto i: content) { - auto j = make_shared(film, i); - - j->Finished.connect ( - bind ( - &ContentMenu::maybe_found_missing, - this, - std::weak_ptr (j), - std::weak_ptr (_content.front ()), - std::weak_ptr (i) - ) - ); - - JobManager::instance()->add (j); - } + dcpomatic::find_missing (film->content(), path); } void @@ -393,30 +370,10 @@ ContentMenu::re_examine () } for (auto i: _content) { - JobManager::instance()->add (shared_ptr (new ExamineContentJob (film, i))); + JobManager::instance()->add(make_shared(film, i)); } } -void -ContentMenu::maybe_found_missing (weak_ptr j, weak_ptr oc, weak_ptr nc) -{ - auto job = j.lock (); - if (!job || !job->finished_ok ()) { - return; - } - - auto old_content = oc.lock (); - auto new_content = nc.lock (); - DCPOMATIC_ASSERT (old_content); - DCPOMATIC_ASSERT (new_content); - - if (new_content->digest() != old_content->digest()) { - error_dialog (0, _("The content file(s) you specified are not the same as those that are missing. Either try again with the correct content file or remove the missing content.")); - return; - } - - old_content->set_paths (new_content->paths()); -} void ContentMenu::kdm () @@ -555,7 +512,7 @@ ContentMenu::auto_crop () auto const content = _content.front(); auto const current_crop = content->video->actual_crop(); viewer->set_crop_guess ( - Rect( + dcpomatic::Rect( static_cast(std::max(0, crop.left - current_crop.left)) / content->video->size().width, static_cast(std::max(0, crop.top - current_crop.top)) / content->video->size().height, 1.0f - (static_cast(std::max(0, crop.left - current_crop.left + crop.right - current_crop.right)) / content->video->size().width), @@ -602,13 +559,13 @@ ContentMenu::auto_crop () /* Handle the user closing the dialog (with OK or cancel) */ _auto_crop_dialog->Bind (wxEVT_BUTTON, [this, viewer](wxCommandEvent& ev) { + _auto_crop_config_connection.disconnect (); + _auto_crop_viewer_connection.disconnect (); if (ev.GetId() == wxID_OK) { _content.front()->video->set_crop(_auto_crop_dialog->get()); } _auto_crop_dialog->Show (false); viewer->unset_crop_guess (); - _auto_crop_config_connection.disconnect (); - _auto_crop_viewer_connection.disconnect (); }); /* Update the view when something in the dialog is changed */