Make player/KDM creator and main DCP-o-matic all behave the same with respect to...
authorCarl Hetherington <cth@carlh.net>
Fri, 5 Jan 2018 18:57:48 +0000 (18:57 +0000)
committerCarl Hetherington <cth@carlh.net>
Fri, 5 Jan 2018 18:57:48 +0000 (18:57 +0000)
src/tools/dcpomatic.cc
src/tools/dcpomatic_kdm.cc
src/tools/dcpomatic_player.cc
src/wx/wx_util.cc
src/wx/wx_util.h

index a0dde813ddf4642d8d7845443d3cfda5407c379e..90c70abc23f103beba660d2242aa3048580afdd5 100644 (file)
@@ -1177,19 +1177,7 @@ private:
                Config::FailedToLoad.connect (boost::bind (&App::config_failed_to_load, this));
                Config::Warning.connect (boost::bind (&App::config_warning, this, _1));
 
-               wxSplashScreen* splash = 0;
-               try {
-                       if (!Config::have_existing ("config.xml")) {
-                               wxBitmap bitmap;
-                               boost::filesystem::path p = shared_path () / "splash.png";
-                               if (bitmap.LoadFile (std_to_wx (p.string ()), wxBITMAP_TYPE_PNG)) {
-                                       splash = new wxSplashScreen (bitmap, wxSPLASH_CENTRE_ON_SCREEN | wxSPLASH_NO_TIMEOUT, 0, 0, -1);
-                                       wxYield ();
-                               }
-                       }
-               } catch (boost::filesystem::filesystem_error& e) {
-                       /* Maybe we couldn't find the splash image; never mind */
-               }
+               wxSplashScreen* splash = maybe_show_splash ();
 
                SetAppName (_("DCP-o-matic"));
 
index ee2e87161abb2377a70eeb11c827dd568b4369ff..26e7f8479ec465f5d34011af2b0ab846d5106d14 100644 (file)
 #include "lib/compose.hpp"
 #include "lib/cinema.h"
 #include "lib/dkdm_wrapper.h"
+#include "lib/cross.h"
 #include <dcp/encrypted_kdm.h>
 #include <dcp/decrypted_kdm.h>
 #include <dcp/exceptions.h>
 #include <wx/wx.h>
 #include <wx/preferences.h>
+#include <wx/splash.h>
 #include <wx/filepicker.h>
 #ifdef __WXOSX__
 #include <ApplicationServices/ApplicationServices.h>
@@ -536,6 +538,11 @@ private:
        {
                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 ();
+
                SetAppName (_("DCP-o-matic KDM Creator"));
 
                if (!wxApp::OnInit()) {
@@ -575,6 +582,9 @@ private:
                _frame = new DOMFrame (_("DCP-o-matic KDM Creator"));
                SetTopWindow (_frame);
                _frame->Maximize ();
+               if (splash) {
+                       splash->Destroy ();
+               }
                _frame->Show ();
 
                signal_manager = new wxSignalManager (this);
@@ -628,6 +638,16 @@ private:
                signal_manager->ui_idle ();
        }
 
+       void config_failed_to_load ()
+       {
+               message_dialog (_frame, _("The existing configuration failed to load.  Default values will be used instead.  These may take a short time to create."));
+       }
+
+       void config_warning (string m)
+       {
+               message_dialog (_frame, std_to_wx (m));
+       }
+
        DOMFrame* _frame;
 };
 
index 1913a4b154fff5c7e743a5aa72c3799900900ab0..5ac01c348ea0a4be7a0ad4a8686687cf93a9cfae 100644 (file)
@@ -414,20 +414,9 @@ private:
                wxInitAllImageHandlers ();
 
                Config::FailedToLoad.connect (boost::bind (&App::config_failed_to_load, this));
+               Config::Warning.connect (boost::bind (&App::config_warning, this, _1));
 
-               wxSplashScreen* splash = 0;
-               try {
-                       if (!Config::have_existing ("config.xml")) {
-                               wxBitmap bitmap;
-                               boost::filesystem::path p = shared_path () / "splash.png";
-                               if (bitmap.LoadFile (std_to_wx (p.string ()), wxBITMAP_TYPE_PNG)) {
-                                       splash = new wxSplashScreen (bitmap, wxSPLASH_CENTRE_ON_SCREEN | wxSPLASH_NO_TIMEOUT, 0, 0, -1);
-                                       wxYield ();
-                               }
-                       }
-               } catch (boost::filesystem::filesystem_error& e) {
-                       /* Maybe we couldn't find the splash image; never mind */
-               }
+               wxSplashScreen* splash = maybe_show_splash ();
 
                SetAppName (_("DCP-o-matic Player"));
 
@@ -561,6 +550,11 @@ private:
                message_dialog (_frame, _("The existing configuration failed to load.  Default values will be used instead.  These may take a short time to create."));
        }
 
+       void config_warning (string m)
+       {
+               message_dialog (_frame, std_to_wx (m));
+       }
+
        DOMFrame* _frame;
        string _dcp_to_load;
 };
index 05f2db121ac69496ce828c828929820ad1db65d7..dd4ec3948765bbcdbf9946c8d0a923c3a669f24e 100644 (file)
 #include "file_picker_ctrl.h"
 #include "lib/config.h"
 #include "lib/util.h"
+#include "lib/cross.h"
 #include <dcp/locale_convert.h>
 #include <wx/spinctrl.h>
+#include <wx/splash.h>
 #include <boost/thread.hpp>
 
 using namespace std;
@@ -382,3 +384,23 @@ setup_audio_channels_choice (wxChoice* choice, int minimum)
 
        checked_set (choice, items);
 }
+
+wxSplashScreen *
+maybe_show_splash ()
+{
+       wxSplashScreen* splash = 0;
+       try {
+               if (!Config::have_existing ("config.xml")) {
+                       wxBitmap bitmap;
+                       boost::filesystem::path p = shared_path () / "splash.png";
+                       if (bitmap.LoadFile (std_to_wx (p.string ()), wxBITMAP_TYPE_PNG)) {
+                               splash = new wxSplashScreen (bitmap, wxSPLASH_CENTRE_ON_SCREEN | wxSPLASH_NO_TIMEOUT, 0, 0, -1);
+                               wxYield ();
+                       }
+               }
+       } catch (boost::filesystem::filesystem_error& e) {
+               /* Maybe we couldn't find the splash image; never mind */
+       }
+
+       return splash;
+}
index d163c6938765dcf7bfa2cd7fac382ef2678b319b..7011d35d32559c54f7f6d992b0726be5347ffde2 100644 (file)
@@ -39,6 +39,7 @@ class FilePickerCtrl;
 class wxSpinCtrl;
 class wxSpinCtrlDouble;
 class wxGridBagSizer;
+class wxSplashScreen;
 
 #define DCPOMATIC_SIZER_X_GAP 8
 #define DCPOMATIC_SIZER_Y_GAP 8
@@ -80,6 +81,7 @@ extern wxString context_translation (wxString);
 extern std::string string_client_data (wxClientData* o);
 extern wxString time_to_timecode (DCPTime t, double fps);
 extern void setup_audio_channels_choice (wxChoice* choice, int minimum);
+extern wxSplashScreen* maybe_show_splash ();
 
 extern void checked_set (FilePickerCtrl* widget, boost::filesystem::path value);
 extern void checked_set (wxSpinCtrl* widget, int value);