Add DCP button added to content panel.
authorCarl Hetherington <cth@carlh.net>
Mon, 20 Feb 2017 00:54:49 +0000 (00:54 +0000)
committerCarl Hetherington <cth@carlh.net>
Mon, 20 Feb 2017 00:54:49 +0000 (00:54 +0000)
ChangeLog
src/lib/content_factory.cc
src/wx/content_panel.cc
src/wx/content_panel.h

index 9a2f3d9cbeb2465471e1de47595eae33f59e5753..903c036c2f94aaeb567f40c87a9f798ed58e3502 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2017-02-20  Carl Hetherington  <cth@carlh.net>
+
+       * Add "Add DCP" button to the content panel.
+
 2017-02-18  Carl Hetherington  <cth@carlh.net>
 
        * Updated fr_FR translation from Thierry Journet.
index 70a3dc7749b58197d1e5ac8d70b1d5a3383be047..87f4e36a0402ddae1f2d0c3928fbaebce9924ae8 100644 (file)
@@ -118,11 +118,8 @@ content_factory (shared_ptr<const Film> film, boost::filesystem::path path)
                        return content;
                }
 
-               /* Guess if this is a DCP, a set of images or a set of sound files: read the first ten filenames
-                  and if they are all valid image/sound files we assume it is not a DCP.
-               */
+               /* See if this is a set of images or a set of sound files */
 
-               bool is_dcp = false;
                int image_files = 0;
                int sound_files = 0;
                int read = 0;
@@ -142,14 +139,6 @@ content_factory (shared_ptr<const Film> film, boost::filesystem::path path)
                                continue;
                        }
 
-                       if (!valid_image_file (i->path()) && !valid_sound_file (i->path())) {
-                               /* We have a normal file which isn't an image; assume we are looking
-                                  at a DCP.
-                               */
-                               LOG_GENERAL ("It's a DCP because of %1", i->path());
-                               is_dcp = true;
-                       }
-
                        if (valid_image_file (i->path ())) {
                                ++image_files;
                        }
@@ -161,11 +150,9 @@ content_factory (shared_ptr<const Film> film, boost::filesystem::path path)
                        ++read;
                }
 
-               if (is_dcp) {
-                       content.push_back (shared_ptr<Content> (new DCPContent (film, path)));
-               } else if (image_files > 0) {
+               if (image_files > 0 && sound_files == 0)  {
                        content.push_back (shared_ptr<Content> (new ImageContent (film, path)));
-               } else {
+               } else if (image_files == 0 && sound_files > 0) {
                        for (boost::filesystem::directory_iterator i(path); i != boost::filesystem::directory_iterator(); ++i) {
                                content.push_back (shared_ptr<FFmpegContent> (new FFmpegContent (film, i->path())));
                        }
index 816512fb6f1ab8507fc3fe6f52be4f5addadf4f2..1aeba63728181478cbe755e28e67413d5795ef53 100644 (file)
@@ -79,13 +79,17 @@ ContentPanel::ContentPanel (wxNotebook* n, boost::shared_ptr<Film> film, FilmVie
                wxBoxSizer* b = new wxBoxSizer (wxVERTICAL);
 
                _add_file = new wxButton (_panel, wxID_ANY, _("Add file(s)..."));
-               _add_file->SetToolTip (_("Add video, image or sound files to the film."));
+               _add_file->SetToolTip (_("Add video, image, sound or subtitle files to the film."));
                b->Add (_add_file, 0, wxEXPAND | wxALL, DCPOMATIC_BUTTON_STACK_GAP);
 
                _add_folder = new wxButton (_panel, wxID_ANY, _("Add folder..."));
-               _add_folder->SetToolTip (_("Add a folder of image files (which will be used as a moving image sequence) or a DCP."));
+               _add_folder->SetToolTip (_("Add a folder of image files (which will be used as a moving image sequence) or a folder of sound files."));
                b->Add (_add_folder, 1, wxEXPAND | wxALL, DCPOMATIC_BUTTON_STACK_GAP);
 
+               _add_dcp = new wxButton (_panel, wxID_ANY, _("Add DCP..."));
+               _add_dcp->SetToolTip (_("Add a DCP."));
+               b->Add (_add_dcp, 1, wxEXPAND | wxALL, DCPOMATIC_BUTTON_STACK_GAP);
+
                _remove = new wxButton (_panel, wxID_ANY, _("Remove"));
                _remove->SetToolTip (_("Remove the selected piece of content from the film."));
                b->Add (_remove, 0, wxEXPAND | wxALL, DCPOMATIC_BUTTON_STACK_GAP);
@@ -125,6 +129,7 @@ ContentPanel::ContentPanel (wxNotebook* n, boost::shared_ptr<Film> film, FilmVie
        _content->Bind (wxEVT_DROP_FILES, boost::bind (&ContentPanel::files_dropped, this, _1));
        _add_file->Bind (wxEVT_BUTTON, boost::bind (&ContentPanel::add_file_clicked, this));
        _add_folder->Bind (wxEVT_BUTTON, boost::bind (&ContentPanel::add_folder_clicked, this));
+       _add_dcp->Bind (wxEVT_BUTTON, boost::bind (&ContentPanel::add_dcp_clicked, this));
        _remove->Bind (wxEVT_BUTTON, boost::bind (&ContentPanel::remove_clicked, this, false));
        _earlier->Bind (wxEVT_BUTTON, boost::bind (&ContentPanel::earlier_clicked, this));
        _later->Bind (wxEVT_BUTTON, boost::bind (&ContentPanel::later_clicked, this));
@@ -343,6 +348,25 @@ ContentPanel::add_folder_clicked ()
        }
 }
 
+void
+ContentPanel::add_dcp_clicked ()
+{
+       wxDirDialog* d = new wxDirDialog (_panel, _("Choose a DCP folder"), wxT (""), wxDD_DIR_MUST_EXIST);
+       int r = d->ShowModal ();
+       boost::filesystem::path const path (wx_to_std (d->GetPath ()));
+       d->Destroy ();
+
+       if (r != wxID_OK) {
+               return;
+       }
+
+       try {
+               _film->examine_and_add_content (shared_ptr<Content> (new DCPContent (_film, path)));
+       } catch (exception& e) {
+               error_dialog (_parent, e.what());
+       }
+}
+
 /** @return true if this remove "click" should be ignored */
 bool
 ContentPanel::remove_clicked (bool hotkey)
@@ -386,6 +410,7 @@ ContentPanel::setup_sensitivity ()
 {
        _add_file->Enable (_generally_sensitive);
        _add_folder->Enable (_generally_sensitive);
+       _add_dcp->Enable (_generally_sensitive);
 
        ContentList selection = selected ();
        ContentList video_selection = selected_video ();
@@ -423,6 +448,7 @@ ContentPanel::set_general_sensitivity (bool s)
        _content->Enable (s);
        _add_file->Enable (s);
        _add_folder->Enable (s);
+       _add_dcp->Enable (s);
        _remove->Enable (s);
        _earlier->Enable (s);
        _later->Enable (s);
index e8b31b7f478ef816256d901f69252243c88a3a3f..cf5782baa6d45e268b94ce6bd391cea85e01c363 100644 (file)
@@ -73,6 +73,7 @@ public:
 private:
        void selection_changed ();
        void add_folder_clicked ();
+       void add_dcp_clicked ();
        void earlier_clicked ();
        void later_clicked ();
        void right_click (wxListEvent &);
@@ -90,6 +91,7 @@ private:
        wxListCtrl* _content;
        wxButton* _add_file;
        wxButton* _add_folder;
+       wxButton* _add_dcp;
        wxButton* _remove;
        wxButton* _earlier;
        wxButton* _later;