Give a more informative error when using bad filename characters on Windows.
[dcpomatic.git] / src / tools / dcpomatic.cc
index 7392c830c7be939d8560201ad8597c2e40cbf036..63a5143e8e473adc72a4f52ee010d1bd4c09b736 100644 (file)
@@ -22,7 +22,8 @@
  *  @brief The main DCP-o-matic GUI.
  */
 
-#include "wx/control_film_viewer.h"
+#include "wx/controls.h"
+#include "wx/film_viewer.h"
 #include "wx/film_editor.h"
 #include "wx/job_manager_view.h"
 #include "wx/full_config_dialog.h"
@@ -90,6 +91,7 @@
 #include <boost/filesystem.hpp>
 #include <boost/noncopyable.hpp>
 #include <boost/foreach.hpp>
+#include <boost/algorithm/string.hpp>
 #include <iostream>
 #include <fstream>
 /* This is OK as it's only used with DCPOMATIC_WINDOWS */
@@ -113,6 +115,8 @@ using boost::shared_ptr;
 using boost::dynamic_pointer_cast;
 using boost::optional;
 using boost::function;
+using boost::is_any_of;
+using boost::algorithm::find;
 using dcp::raw_convert;
 
 class FilmChangedClosingDialog : public boost::noncopyable
@@ -317,12 +321,14 @@ public:
                */
                wxPanel* overall_panel = new wxPanel (this, wxID_ANY);
 
-               _film_viewer = new ControlFilmViewer (overall_panel);
+               _film_viewer.reset (new FilmViewer (overall_panel));
+               _controls = new Controls (overall_panel, _film_viewer);
                _film_editor = new FilmEditor (overall_panel, _film_viewer);
                JobManagerView* job_manager_view = new JobManagerView (overall_panel, false);
 
                wxBoxSizer* right_sizer = new wxBoxSizer (wxVERTICAL);
-               right_sizer->Add (_film_viewer, 2, wxEXPAND | wxALL, 6);
+               right_sizer->Add (_film_viewer->panel(), 2, wxEXPAND | wxALL, 6);
+               right_sizer->Add (_controls, 0, wxEXPAND | wxALL, 6);
                right_sizer->Add (job_manager_view, 1, wxEXPAND | wxALL, 6);
 
                wxBoxSizer* main_sizer = new wxBoxSizer (wxHORIZONTAL);
@@ -473,7 +479,23 @@ private:
                        try {
                                new_film (d->path(), d->template_name());
                        } catch (boost::filesystem::filesystem_error& e) {
-                               error_dialog (this, _("Could not create folder to store film"), std_to_wx(e.what()));
+#ifdef DCPOMATIC_WINDOWS
+                               string bad_chars = "<>:\"/\\|?*";
+                               string const filename = d->path().string();
+                               string found_bad_chars;
+                               for (size_t i = 0; i < bad_chars.length(); ++i) {
+                                       if (filename.find(bad_chars[i]) != string::npos && found_bad_chars.find(bad_chars[i]) == string::npos) {
+                                               found_bad_chars += bad_chars[i];
+                                       }
+                               }
+                               error_dialog (
+                                       this,
+                                       String::compose(_("Could not create folder to store film.  Try removing the %1 characters from your folder name.", found_bad_chars)),
+                                       std_to_wx(e.what())
+                                       );
+#else
+                               error_dialog (this, _("Could not create folder to store film."), std_to_wx(e.what()));
+#endif
                        }
                }
 
@@ -1298,16 +1320,17 @@ private:
 
        void back_frame ()
        {
-               _film_viewer->back_frame ();
+               _film_viewer->seek_by (-_film_viewer->one_video_frame(), true);
        }
 
        void forward_frame ()
        {
-               _film_viewer->forward_frame ();
+               _film_viewer->seek_by (_film_viewer->one_video_frame(), true);
        }
 
        FilmEditor* _film_editor;
-       ControlFilmViewer* _film_viewer;
+       boost::shared_ptr<FilmViewer> _film_viewer;
+       Controls* _controls;
        VideoWaveformDialog* _video_waveform_dialog;
        HintsDialog* _hints_dialog;
        ServersListDialog* _servers_list_dialog;