Tidy up to use one list of servers.
[dcpomatic.git] / src / tools / dcpomatic.cc
index b221201435deac4504cf1090b2602e2edac9457a..33e90aef35260306b29562ea2e625e7ed9c58fed 100644 (file)
@@ -29,6 +29,7 @@
 #include "wx/wx_util.h"
 #include "wx/film_name_location_dialog.h"
 #include "wx/wx_signal_manager.h"
+#include "wx/recreate_chain_dialog.h"
 #include "wx/about_dialog.h"
 #include "wx/kdm_dialog.h"
 #include "wx/self_dkdm_dialog.h"
@@ -217,7 +218,11 @@ enum {
        ID_help_report_a_problem,
        /* IDs for shortcuts (with no associated menu item) */
        ID_add_file,
-       ID_remove
+       ID_remove,
+       ID_start_stop,
+       ID_timeline,
+       ID_back_frame,
+       ID_forward_frame
 };
 
 class DOMFrame : public wxFrame
@@ -327,18 +332,26 @@ public:
                overall_panel->SetSizer (main_sizer);
 
 #ifdef __WXOSX__
-               int accelerators = 3;
+               int accelerators = 7;
 #else
-               int accelerators = 2;
+               int accelerators = 6;
 #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);
+               accel[3].Set (wxACCEL_CTRL, static_cast<int>('T'), ID_timeline);
+               accel[4].Set (wxACCEL_NORMAL, WXK_LEFT, ID_back_frame);
+               accel[5].Set (wxACCEL_NORMAL, WXK_RIGHT, ID_forward_frame);
 #ifdef __WXOSX__
-               accel[2].Set (wxACCEL_CTRL, static_cast<int>('W'), wxID_EXIT);
+               accel[6].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, _1), ID_start_stop);
+               Bind (wxEVT_MENU, boost::bind (&DOMFrame::timeline_pressed, this), ID_timeline);
+               Bind (wxEVT_MENU, boost::bind (&DOMFrame::back_frame, this, _1), ID_back_frame);
+               Bind (wxEVT_MENU, boost::bind (&DOMFrame::forward_frame, this, _1), ID_forward_frame);
                wxAcceleratorTable accel_table (accelerators, accel);
                SetAcceleratorTable (accel_table);
                delete[] accel;
@@ -426,7 +439,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 ();
@@ -1196,6 +1213,56 @@ private:
                _update_news_requested = false;
        }
 
+       /** Skip the given event if we're focussed in a TextCtrl, so that hotkeys don't
+        *  steal from text controls.
+        */
+       bool maybe_pass (wxCommandEvent& ev)
+       {
+               wxWindow* f = wxWindow::FindFocus();
+               if (!f || !dynamic_cast<wxTextCtrl*>(f)) {
+                       return false;
+               }
+
+               ev.Skip();
+               return true;
+       }
+
+       void start_stop_pressed (wxCommandEvent& ev)
+       {
+               if (maybe_pass(ev)) {
+                       return;
+               }
+
+               if (_film_viewer->playing()) {
+                       _film_viewer->stop();
+               } else {
+                       _film_viewer->start();
+               }
+       }
+
+       void timeline_pressed ()
+       {
+               _film_editor->content_panel()->timeline_clicked ();
+       }
+
+       void back_frame (wxCommandEvent& ev)
+       {
+               if (maybe_pass(ev)) {
+                       return;
+               }
+
+               _film_viewer->back_frame ();
+       }
+
+       void forward_frame (wxCommandEvent& ev)
+       {
+               if (maybe_pass(ev)) {
+                       return;
+               }
+
+               _film_viewer->forward_frame ();
+       }
+
        FilmEditor* _film_editor;
        FilmViewer* _film_viewer;
        VideoWaveformDialog* _video_waveform_dialog;
@@ -1281,6 +1348,8 @@ private:
                */
                Config::drop ();
 
+               Config::BadSignerChain.connect (boost::bind (&App::config_bad_signer_chain, this));
+
                _frame = new DOMFrame (_("DCP-o-matic"));
                SetTopWindow (_frame);
                _frame->Maximize ();
@@ -1420,6 +1489,18 @@ private:
                message_dialog (_frame, std_to_wx (m));
        }
 
+       bool config_bad_signer_chain ()
+       {
+               if (Config::instance()->nagged(Config::NAG_BAD_SIGNER_CHAIN)) {
+                       return false;
+               }
+
+               RecreateChainDialog* d = new RecreateChainDialog (_frame);
+               int const r = d->ShowModal ();
+               d->Destroy ();
+               return r == wxID_OK;
+       }
+
        DOMFrame* _frame;
        shared_ptr<wxTimer> _timer;
        string _film_to_load;