Add space shortcut to start/stop playback (#1201).
[dcpomatic.git] / src / tools / dcpomatic.cc
index 1e6c49d7bc592f2e9e67533eaf5dd69c92333c7a..982e38e67cdc3213046f8a958db40007ca688fcd 100644 (file)
@@ -218,7 +218,8 @@ enum {
        ID_help_report_a_problem,
        /* IDs for shortcuts (with no associated menu item) */
        ID_add_file,
-       ID_remove
+       ID_remove,
+       ID_start_stop
 };
 
 class DOMFrame : public wxFrame
@@ -328,18 +329,20 @@ public:
                overall_panel->SetSizer (main_sizer);
 
 #ifdef __WXOSX__
-               int accelerators = 3;
+               int accelerators = 4;
 #else
-               int accelerators = 2;
+               int accelerators = 3;
 #endif
                wxAcceleratorEntry* accel = new wxAcceleratorEntry[accelerators];
                accel[0].Set (wxACCEL_CTRL, static_cast<int>('A'), ID_add_file);
                accel[1].Set (wxACCEL_NORMAL, WXK_DELETE, ID_remove);
+               accel[2].Set (wxACCEL_NORMAL, WXK_SPACE, ID_start_stop);
 #ifdef __WXOSX__
-               accel[2].Set (wxACCEL_CTRL, static_cast<int>('W'), wxID_EXIT);
+               accel[3].Set (wxACCEL_CTRL, static_cast<int>('W'), wxID_EXIT);
 #endif
                Bind (wxEVT_MENU, boost::bind (&ContentPanel::add_file_clicked, _film_editor->content_panel()), ID_add_file);
                Bind (wxEVT_MENU, boost::bind (&DOMFrame::remove_clicked, this, _1), ID_remove);
+               Bind (wxEVT_MENU, boost::bind (&DOMFrame::start_stop_pressed, this), ID_start_stop);
                wxAcceleratorTable accel_table (accelerators, accel);
                SetAcceleratorTable (accel_table);
                delete[] accel;
@@ -427,7 +430,11 @@ private:
                int const r = d->ShowModal ();
 
                if (r == wxID_OK && d->check_path() && maybe_save_then_delete_film<FilmChangedClosingDialog>()) {
-                       new_film (d->path(), d->template_name());
+                       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()));
+                       }
                }
 
                d->Destroy ();
@@ -1197,6 +1204,15 @@ private:
                _update_news_requested = false;
        }
 
+       void start_stop_pressed ()
+       {
+               if (_film_viewer->playing()) {
+                       _film_viewer->stop();
+               } else {
+                       _film_viewer->start();
+               }
+       }
+
        FilmEditor* _film_editor;
        FilmViewer* _film_viewer;
        VideoWaveformDialog* _video_waveform_dialog;