Try to make splash screen disappear sooner by Skip()ing the idle event.
[dcpomatic.git] / src / tools / dcpomatic.cc
index 7b5696a1c1581b8007a4a69a8160d68b38fe1065..048d5fedd15394befa2fe851f3f9a309685756e1 100644 (file)
 #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 <wx/cmdline.h>
 #include <wx/preferences.h>
 #include <wx/splash.h>
+#include <wx/wxhtml.h>
 #ifdef __WXMSW__
 #include <shellapi.h>
 #endif
@@ -290,6 +293,8 @@ 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);
@@ -410,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)
@@ -427,8 +431,8 @@ public:
                                );
                }
 
-               for (list<string>::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);
@@ -457,6 +461,8 @@ public:
                }
                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 ();
                }
        }
 
@@ -466,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) {
@@ -699,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;
@@ -1016,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<string, string> translations = I18NHook::translations ();
                        for (map<string, string>::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<string> 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 ();
@@ -1097,6 +1110,9 @@ private:
                */
                _config_changed_connection.disconnect ();
 
+               /* Also stop hearing about analytics-related stuff */
+               _analytics_message_connection.disconnect ();
+
                ev.Skip ();
        }
 
@@ -1210,7 +1226,7 @@ private:
                _history_position = _file_menu->GetMenuItems().GetCount();
 
                _file_menu->AppendSeparator ();
-               add_item (_file_menu, _("&Close"), ID_file_close, NEEDS_FILM);
+               add_item (_file_menu, _("&Close\tCtrl-W"), ID_file_close, NEEDS_FILM);
 
 #ifndef __WXOSX__
                _file_menu->AppendSeparator ();
@@ -1320,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<boost::filesystem::path> history = Config::instance()->history ();
 
                if (!history.empty ()) {
@@ -1337,6 +1355,8 @@ private:
                }
 
                _history_items = history.size ();
+
+               dcpomatic_log->set_types (Config::instance()->log_types());
        }
 
        void update_checker_state_changed ()
@@ -1391,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<FilmViewer> _film_viewer;
        StandardControls* _controls;
@@ -1406,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<Content> _clipboard;
 };
@@ -1518,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));
@@ -1607,9 +1635,10 @@ private:
                report_exception ();
        }
 
-       void idle ()
+       void idle (wxIdleEvent& ev)
        {
                signal_manager->ui_idle ();
+               ev.Skip ();
        }
 
        void check ()