Rename _last_video* to _next_video* as it seems to make more sense that way.
[dcpomatic.git] / src / lib / config.cc
index bf294aec957e03a3c95d7d6ff8f7677112d66073..f8639692fe0b97013c4beb4c0e8b90fbf46da064 100644 (file)
@@ -34,6 +34,7 @@
 #include "ratio.h"
 #include "types.h"
 #include "util.h"
+#include "zipper.h"
 #include <dcp/certificate_chain.h>
 #include <dcp/name_format.h>
 #include <dcp/raw_convert.h>
@@ -183,6 +184,7 @@ Config::set_defaults ()
        _audio_mapping = boost::none;
        _custom_languages.clear ();
        _add_files_path = boost::none;
+       _auto_crop_threshold = 0.1;
 
        _allowed_dcp_frame_rates.clear ();
        _allowed_dcp_frame_rates.push_back (24);
@@ -583,6 +585,7 @@ try
        }
 
        _add_files_path = f.optional_string_child("AddFilesPath");
+       _auto_crop_threshold = f.optional_number_child<double>("AutoCropThreshold").get_value_or(0.1);
 
        if (boost::filesystem::exists (_cinemas_file)) {
                cxml::Document f ("Cinemas");
@@ -1014,6 +1017,7 @@ Config::write_config () const
                /* [XML] AddFilesPath The default path that will be offered in the picker when adding files to a film. */
                root->add_child("AddFilesPath")->add_child_text(_add_files_path->string());
        }
+       root->add_child("AutoCropThreshold")->add_child_text(raw_convert<string>(_auto_crop_threshold));
 
        auto target = config_write_file();
 
@@ -1474,3 +1478,21 @@ Config::add_custom_language (dcp::LanguageTag tag)
        }
 }
 
+
+void
+save_all_config_as_zip (boost::filesystem::path zip_file)
+{
+       Zipper zipper (zip_file);
+
+       auto config = Config::instance();
+       zipper.add ("config.xml", dcp::file_to_string(config->config_read_file()));
+       if (boost::filesystem::exists(config->cinemas_file())) {
+               zipper.add ("cinemas.xml", dcp::file_to_string(config->cinemas_file()));
+       }
+       if (boost::filesystem::exists(config->dkdm_recipients_file())) {
+               zipper.add ("dkdm_recipients.xml", dcp::file_to_string(config->dkdm_recipients_file()));
+       }
+
+       zipper.close ();
+}
+