X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=blobdiff_plain;f=src%2Ftools%2Fdcpomatic.cc;h=3ba9ceb9dfc5b6bf497b4473228eec2c0c61ac81;hp=ee79aeb3763e8f6ee253985996cc56b7fa8cef7b;hb=67bd9c7a2fad1568ac10b771a76a601937c20174;hpb=4548027ac50f2db16891f272d7a6c25b80062f15 diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc index ee79aeb37..3ba9ceb9d 100644 --- a/src/tools/dcpomatic.cc +++ b/src/tools/dcpomatic.cc @@ -46,10 +46,12 @@ #include "wx/export_dialog.h" #include "wx/paste_dialog.h" #include "wx/focus_manager.h" +#include "wx/html_dialog.h" #include "wx/initial_setup_dialog.h" #include "wx/send_i18n_dialog.h" #include "wx/i18n_hook.h" #include "lib/film.h" +#include "lib/analytics.h" #include "lib/emailer.h" #include "lib/config.h" #include "lib/util.h" @@ -87,6 +89,7 @@ #include #include #include +#include #ifdef __WXMSW__ #include #endif @@ -211,7 +214,8 @@ enum { ID_file_duplicate_and_open, ID_file_history, /* Allow spare IDs after _history for the recent files list */ - ID_edit_copy = 100, + ID_file_close = 100, + ID_edit_copy, ID_edit_paste, ID_content_scale_to_fit_width, ID_content_scale_to_fit_height, @@ -289,12 +293,15 @@ public: _config_changed_connection = Config::instance()->Changed.connect (boost::bind (&DOMFrame::config_changed, this, _1)); config_changed (Config::OTHER); + _analytics_message_connection = Analytics::instance()->Message.connect(boost::bind(&DOMFrame::analytics_message, this, _1, _2)); + Bind (wxEVT_MENU, boost::bind (&DOMFrame::file_new, this), ID_file_new); Bind (wxEVT_MENU, boost::bind (&DOMFrame::file_open, this), ID_file_open); Bind (wxEVT_MENU, boost::bind (&DOMFrame::file_save, this), ID_file_save); Bind (wxEVT_MENU, boost::bind (&DOMFrame::file_save_as_template, this), ID_file_save_as_template); Bind (wxEVT_MENU, boost::bind (&DOMFrame::file_duplicate, this), ID_file_duplicate); Bind (wxEVT_MENU, boost::bind (&DOMFrame::file_duplicate_and_open, this), ID_file_duplicate_and_open); + Bind (wxEVT_MENU, boost::bind (&DOMFrame::file_close, this), ID_file_close); Bind (wxEVT_MENU, boost::bind (&DOMFrame::file_history, this, _1), ID_file_history, ID_file_history + HISTORY_SIZE); Bind (wxEVT_MENU, boost::bind (&DOMFrame::file_exit, this), wxID_EXIT); Bind (wxEVT_MENU, boost::bind (&DOMFrame::edit_copy, this), ID_edit_copy); @@ -339,8 +346,8 @@ public: right_sizer->Add (job_manager_view, 1, wxEXPAND | wxALL, 6); wxBoxSizer* main_sizer = new wxBoxSizer (wxHORIZONTAL); - main_sizer->Add (_film_editor, 1, wxEXPAND | wxALL, 6); - main_sizer->Add (right_sizer, 2, wxEXPAND | wxALL, 6); + main_sizer->Add (_film_editor, 0, wxEXPAND | wxALL, 6); + main_sizer->Add (right_sizer, 1, wxEXPAND | wxALL, 6); set_menu_sensitivity (); @@ -374,7 +381,7 @@ public: accel[4].Set (wxACCEL_NORMAL, WXK_LEFT, ID_back_frame); accel[5].Set (wxACCEL_NORMAL, WXK_RIGHT, ID_forward_frame); #ifdef __WXOSX__ - accel[6].Set (wxACCEL_CTRL, static_cast('W'), wxID_EXIT); + accel[6].Set (wxACCEL_CTRL, static_cast('W'), ID_file_close); #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); @@ -408,7 +415,6 @@ public: film->set_name (path.filename().generic_string()); film->write_metadata (); set_film (film); - dcpomatic_log = film->log (); } void load_film (boost::filesystem::path file) @@ -425,8 +431,8 @@ public: ); } - for (list::const_iterator i = notes.begin(); i != notes.end(); ++i) { - error_dialog (0, std_to_wx (*i)); + BOOST_FOREACH (string i, notes) { + error_dialog (0, std_to_wx(i)); } set_film (film); @@ -450,10 +456,14 @@ public: _video_waveform_dialog = 0; } set_menu_sensitivity (); - if (_film->directory()) { + if (_film && _film->directory()) { Config::instance()->add_to_history (_film->directory().get()); } - _film->Change.connect (boost::bind (&DOMFrame::film_change, this, _1)); + if (_film) { + _film->Change.connect (boost::bind (&DOMFrame::film_change, this, _1)); + _film->Message.connect (boost::bind(&DOMFrame::film_message, this, _1)); + dcpomatic_log = _film->log (); + } } shared_ptr film () const { @@ -462,6 +472,11 @@ public: private: + void film_message (string m) + { + message_dialog (this, std_to_wx(m)); + } + void film_change (ChangeType type) { if (type == CHANGE_TYPE_DONE) { @@ -584,6 +599,31 @@ private: d->Destroy (); } + void file_close () + { + if (_film && _film->dirty ()) { + + FilmChangedClosingDialog* dialog = new FilmChangedClosingDialog (_film->name ()); + int const r = dialog->run (); + delete dialog; + + switch (r) { + case wxID_NO: + /* Don't save and carry on to close */ + break; + case wxID_YES: + /* Save and carry on to close */ + _film->write_metadata (); + break; + case wxID_CANCEL: + /* Stop */ + return; + } + } + + set_film (shared_ptr()); + } + void file_history (wxCommandEvent& event) { vector history = Config::instance()->history (); @@ -670,9 +710,9 @@ private: if (!_film->should_be_enough_disk_space (required, available, can_hard_link)) { wxString message; if (can_hard_link) { - message = wxString::Format (_("The DCP for this film will take up about %.1f Gb, and the disk that you are using only has %.1f Gb available. Do you want to continue anyway?"), required, available); + message = wxString::Format (_("The DCP for this film will take up about %.1f GB, and the disk that you are using only has %.1f GB available. Do you want to continue anyway?"), required, available); } else { - message = wxString::Format (_("The DCP and intermediate files for this film will take up about %.1f Gb, and the disk that you are using only has %.1f Gb available. You would need half as much space if the filesystem supported hard links, but it does not. Do you want to continue anyway?"), required, available); + message = wxString::Format (_("The DCP and intermediate files for this film will take up about %.1f GB, and the disk that you are using only has %.1f GB available. You would need half as much space if the filesystem supported hard links, but it does not. Do you want to continue anyway?"), required, available); } if (!confirm_dialog (this, message)) { return; @@ -987,14 +1027,16 @@ private: string body; body += d->name() + "\n"; body += d->language() + "\n"; + body += string(dcpomatic_version) + " " + string(dcpomatic_git_commit) + "\n"; + body += "--\n"; map translations = I18NHook::translations (); for (map::const_iterator i = translations.begin(); i != translations.end(); ++i) { - body += i->first + "\n" + i->second + "\n"; + body += i->first + "\n" + i->second + "\n\n"; } list to; to.push_back ("carl@dcpomatic.com"); Emailer emailer (d->email(), to, "DCP-o-matic translations", body); - emailer.send ("main.carlh.net", 2525); + emailer.send ("main.carlh.net", 2525, EMAIL_PROTOCOL_STARTTLS); } d->Destroy (); @@ -1068,6 +1110,9 @@ private: */ _config_changed_connection.disconnect (); + /* Also stop hearing about analytics-related stuff */ + _analytics_message_connection.disconnect (); + ev.Skip (); } @@ -1180,6 +1225,9 @@ private: _history_position = _file_menu->GetMenuItems().GetCount(); + _file_menu->AppendSeparator (); + add_item (_file_menu, _("&Close\tCtrl-W"), ID_file_close, NEEDS_FILM); + #ifndef __WXOSX__ _file_menu->AppendSeparator (); #endif @@ -1288,6 +1336,8 @@ private: int pos = _history_position; + /* Clear out non-existant history items before we re-build the menu */ + Config::instance()->clean_history (); vector history = Config::instance()->history (); if (!history.empty ()) { @@ -1305,6 +1355,8 @@ private: } _history_items = history.size (); + + dcpomatic_log->set_types (Config::instance()->log_types()); } void update_checker_state_changed () @@ -1359,6 +1411,13 @@ private: _film_viewer->seek_by (_film_viewer->one_video_frame(), true); } + void analytics_message (string title, string html) + { + HTMLDialog* d = new HTMLDialog(this, std_to_wx(title), std_to_wx(html)); + d->ShowModal(); + d->Destroy(); + } + FilmEditor* _film_editor; boost::shared_ptr _film_viewer; StandardControls* _controls; @@ -1374,6 +1433,7 @@ private: int _history_position; wxMenuItem* _history_separator; boost::signals2::scoped_connection _config_changed_connection; + boost::signals2::scoped_connection _analytics_message_connection; bool _update_news_requested; shared_ptr _clipboard; }; @@ -1395,20 +1455,20 @@ public: App () : wxApp () , _frame (0) + , _splash (0) {} private: bool OnInit () { - wxSplashScreen* splash = 0; try { wxInitAllImageHandlers (); Config::FailedToLoad.connect (boost::bind (&App::config_failed_to_load, this)); Config::Warning.connect (boost::bind (&App::config_warning, this, _1)); - wxSplashScreen* splash = maybe_show_splash (); + _splash = maybe_show_splash (); SetAppName (_("DCP-o-matic")); @@ -1451,9 +1511,9 @@ private: _frame = new DOMFrame (_("DCP-o-matic")); SetTopWindow (_frame); _frame->Maximize (); - if (splash) { - splash->Destroy (); - splash = 0; + if (_splash) { + _splash->Destroy (); + _splash = 0; } if (!Config::instance()->nagged(Config::NAG_INITIAL_SETUP)) { @@ -1486,7 +1546,7 @@ private: } signal_manager = new wxSignalManager (this); - Bind (wxEVT_IDLE, boost::bind (&App::idle, this)); + Bind (wxEVT_IDLE, boost::bind (&App::idle, this, _1)); Bind (wxEVT_TIMER, boost::bind (&App::check, this)); _timer.reset (new wxTimer (this)); @@ -1498,8 +1558,8 @@ private: } catch (exception& e) { - if (splash) { - splash->Destroy (); + if (_splash) { + _splash->Destroy (); } error_dialog (0, wxString::Format ("DCP-o-matic could not start."), std_to_wx(e.what())); } @@ -1538,6 +1598,11 @@ private: void report_exception () { + if (_splash) { + _splash->Destroy (); + _splash = 0; + } + try { throw; } catch (FileError& e) { @@ -1575,9 +1640,10 @@ private: report_exception (); } - void idle () + void idle (wxIdleEvent& ev) { signal_manager->ui_idle (); + ev.Skip (); } void check () @@ -1605,6 +1671,11 @@ private: return false; } + if (_splash) { + _splash->Destroy (); + _splash = 0; + } + RecreateChainDialog* d = new RecreateChainDialog (_frame); int const r = d->ShowModal (); d->Destroy (); @@ -1612,6 +1683,7 @@ private: } DOMFrame* _frame; + wxSplashScreen* _splash; shared_ptr _timer; string _film_to_load; string _film_to_create;