From 660d365faf784a8ea80d5fdc21a1384e81153194 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 5 Jan 2018 18:57:48 +0000 Subject: [PATCH] Make player/KDM creator and main DCP-o-matic all behave the same with respect to problems when loading config. --- src/tools/dcpomatic.cc | 14 +------------- src/tools/dcpomatic_kdm.cc | 20 ++++++++++++++++++++ src/tools/dcpomatic_player.cc | 20 +++++++------------- src/wx/wx_util.cc | 22 ++++++++++++++++++++++ src/wx/wx_util.h | 2 ++ 5 files changed, 52 insertions(+), 26 deletions(-) diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc index a0dde813d..90c70abc2 100644 --- a/src/tools/dcpomatic.cc +++ b/src/tools/dcpomatic.cc @@ -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")); diff --git a/src/tools/dcpomatic_kdm.cc b/src/tools/dcpomatic_kdm.cc index ee2e87161..26e7f8479 100644 --- a/src/tools/dcpomatic_kdm.cc +++ b/src/tools/dcpomatic_kdm.cc @@ -42,11 +42,13 @@ #include "lib/compose.hpp" #include "lib/cinema.h" #include "lib/dkdm_wrapper.h" +#include "lib/cross.h" #include #include #include #include #include +#include #include #ifdef __WXOSX__ #include @@ -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; }; diff --git a/src/tools/dcpomatic_player.cc b/src/tools/dcpomatic_player.cc index 1913a4b15..5ac01c348 100644 --- a/src/tools/dcpomatic_player.cc +++ b/src/tools/dcpomatic_player.cc @@ -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; }; diff --git a/src/wx/wx_util.cc b/src/wx/wx_util.cc index 05f2db121..dd4ec3948 100644 --- a/src/wx/wx_util.cc +++ b/src/wx/wx_util.cc @@ -26,8 +26,10 @@ #include "file_picker_ctrl.h" #include "lib/config.h" #include "lib/util.h" +#include "lib/cross.h" #include #include +#include #include 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; +} diff --git a/src/wx/wx_util.h b/src/wx/wx_util.h index d163c6938..7011d35d3 100644 --- a/src/wx/wx_util.h +++ b/src/wx/wx_util.h @@ -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); -- 2.30.2