summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2017-02-20 00:54:49 +0000
committerCarl Hetherington <cth@carlh.net>2017-02-20 00:54:49 +0000
commit14247790278d45e98004ef54b8ba700d10f3193a (patch)
tree31eef31dd8ec68507d69501d415fd3eecfe2d776 /src
parent6727f7e47db1ad7b0a21f2047e8ed3b4e1968b2a (diff)
Add DCP button added to content panel.
Diffstat (limited to 'src')
-rw-r--r--src/lib/content_factory.cc19
-rw-r--r--src/wx/content_panel.cc30
-rw-r--r--src/wx/content_panel.h2
3 files changed, 33 insertions, 18 deletions
diff --git a/src/lib/content_factory.cc b/src/lib/content_factory.cc
index 70a3dc774..87f4e36a0 100644
--- a/src/lib/content_factory.cc
+++ b/src/lib/content_factory.cc
@@ -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())));
}
diff --git a/src/wx/content_panel.cc b/src/wx/content_panel.cc
index 816512fb6..1aeba6372 100644
--- a/src/wx/content_panel.cc
+++ b/src/wx/content_panel.cc
@@ -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);
diff --git a/src/wx/content_panel.h b/src/wx/content_panel.h
index e8b31b7f4..cf5782baa 100644
--- a/src/wx/content_panel.h
+++ b/src/wx/content_panel.h
@@ -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;