Remove default DCP audio channel setting.
[dcpomatic.git] / src / lib / config.cc
index c2c2cc24457e30c86858992d3360ecb0873bbe05..5401839e37743fbe88551e4b5386b852a17f3f6f 100644 (file)
@@ -686,9 +686,11 @@ Config::instance ()
                if (cinemas_file.extension() == ".xml") {
                        auto sqlite = cinemas_file;
                        sqlite.replace_extension(".sqlite3");
+                       bool const had_sqlite = dcp::filesystem::exists(sqlite);
 
-                       if (dcp::filesystem::exists(cinemas_file) && !dcp::filesystem::exists(sqlite)) {
-                               _instance->set_cinemas_file(sqlite);
+                       _instance->set_cinemas_file(sqlite);
+
+                       if (dcp::filesystem::exists(cinemas_file) && !had_sqlite) {
                                CinemaList cinemas;
                                cinemas.read_legacy_file(cinemas_file);
                        }
@@ -768,14 +770,6 @@ Config::write_config () const
                /* [XML:opt] Language Language to use in the GUI e.g. <code>fr_FR</code>. */
                cxml::add_text_child(root, "Language", _language.get());
        }
-       if (_default_dcp_content_type) {
-               /* [XML:opt] DefaultDCPContentType Default content type to use when creating new films (<code>FTR</code>, <code>SHR</code>,
-                  <code>TLR</code>, <code>TST</code>, <code>XSN</code>, <code>RTG</code>, <code>TSR</code>, <code>POL</code>,
-                  <code>PSA</code> or <code>ADV</code>). */
-               cxml::add_text_child(root, "DefaultDCPContentType", _default_dcp_content_type->isdcf_name());
-       }
-       /* [XML] DefaultDCPAudioChannels Default number of audio channels to use when creating new films. */
-       cxml::add_text_child(root, "DefaultDCPAudioChannels", raw_convert<string>(_default_dcp_audio_channels));
        /* [XML] DCPIssuer Issuer text to write into CPL files. */
        cxml::add_text_child(root, "DCPIssuer", _dcp_issuer);
        /* [XML] DCPCreator Creator text to write into CPL files. */
@@ -1326,7 +1320,7 @@ Config::add_to_history_internal (vector<boost::filesystem::path>& h, boost::file
 
        h.insert (h.begin (), p);
        if (h.size() > HISTORY_SIZE) {
-               h.pop_back ();
+               h.resize(HISTORY_SIZE);
        }
 
        changed (HISTORY);
@@ -1382,6 +1376,13 @@ Config::set_dkdm_recipients_file(boost::filesystem::path file)
 }
 
 
+void
+Config::save_default_template(shared_ptr<const Film> film) const
+{
+       film->write_template(write_path("default.xml"));
+}
+
+
 void
 Config::save_template (shared_ptr<const Film> film, string name) const
 {
@@ -1389,14 +1390,14 @@ Config::save_template (shared_ptr<const Film> film, string name) const
 }
 
 
-list<string>
+vector<string>
 Config::templates () const
 {
        if (!dcp::filesystem::exists(read_path("templates"))) {
                return {};
        }
 
-       list<string> n;
+       vector<string> n;
        for (auto const& i: dcp::filesystem::directory_iterator(read_path("templates"))) {
                n.push_back (i.path().filename().string());
        }
@@ -1417,6 +1418,18 @@ Config::template_read_path (string name) const
 }
 
 
+boost::filesystem::path
+Config::default_template_read_path() const
+{
+       if (!boost::filesystem::exists(read_path("default.xml"))) {
+               auto film = std::make_shared<const Film>(optional<boost::filesystem::path>());
+               save_default_template(film);
+       }
+
+       return read_path("default.xml");
+}
+
+
 boost::filesystem::path
 Config::template_write_path (string name) const
 {