Save config changes made through the batch converter.
authorCarl Hetherington <cth@carlh.net>
Mon, 28 May 2018 23:39:24 +0000 (00:39 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 28 May 2018 23:39:24 +0000 (00:39 +0100)
src/tools/dcpomatic_batch.cc

index f6197b1e22f7bc473cfb9fc2622c1f7e11383d66..6d4490ad7bb36a9fc616e3494eb8f2c29d188287 100644 (file)
@@ -101,6 +101,8 @@ public:
                setup_menu (bar);
                SetMenuBar (bar);
 
+               Config::instance()->Changed.connect (boost::bind (&DOMFrame::config_changed, this, _1));
+
                Bind (wxEVT_MENU, boost::bind (&DOMFrame::file_add_film, this),    ID_file_add_film);
                Bind (wxEVT_MENU, boost::bind (&DOMFrame::file_quit, this),        wxID_EXIT);
                Bind (wxEVT_MENU, boost::bind (&DOMFrame::edit_preferences, this), wxID_PREFERENCES);
@@ -238,6 +240,36 @@ private:
                c->Destroy ();
        }
 
+       void config_changed (Config::Property what)
+       {
+               /* Instantly save any config changes when using the DCP-o-matic GUI */
+               if (what == Config::CINEMAS) {
+                       try {
+                               Config::instance()->write_cinemas();
+                       } catch (exception& e) {
+                               error_dialog (
+                                       this,
+                                       wxString::Format (
+                                               _("Could not write to cinemas file at %s.  Your changes have not been saved."),
+                                               std_to_wx (Config::instance()->cinemas_file().string()).data()
+                                               )
+                                       );
+                       }
+               } else {
+                       try {
+                               Config::instance()->write_config();
+                       } catch (exception& e) {
+                               error_dialog (
+                                       this,
+                                       wxString::Format (
+                                               _("Could not write to config file at %s.  Your changes have not been saved."),
+                                               std_to_wx (Config::instance()->cinemas_file().string()).data()
+                                               )
+                                       );
+                       }
+               }
+       }
+
        boost::optional<boost::filesystem::path> _last_parent;
        wxSizer* _sizer;
        wxPreferencesEditor* _config_dialog;