diff options
| author | Carl Hetherington <cth@carlh.net> | 2022-01-23 20:47:27 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2022-03-09 17:04:02 +0100 |
| commit | 20d041aec481740d1e3495a763c2ef0368ea4147 (patch) | |
| tree | d8be58668445357f61988629a828dbb30c351d25 | |
| parent | 943047c84a0cdc7fbcec392f512157d637b8ec71 (diff) | |
Add option to export config as a .zip (#1776).
| -rw-r--r-- | src/lib/config.cc | 23 | ||||
| -rw-r--r-- | src/lib/config.h | 4 | ||||
| -rw-r--r-- | src/tools/dcpomatic.cc | 19 |
3 files changed, 44 insertions, 2 deletions
diff --git a/src/lib/config.cc b/src/lib/config.cc index bab15ecb7..9b369a81f 100644 --- a/src/lib/config.cc +++ b/src/lib/config.cc @@ -33,9 +33,10 @@ #include "compose.hpp" #include "crypto.h" #include "dkdm_recipient.h" -#include <dcp/raw_convert.h> -#include <dcp/name_format.h> +#include "zipper.h" #include <dcp/certificate_chain.h> +#include <dcp/name_format.h> +#include <dcp/raw_convert.h> #include <libcxml/cxml.h> #include <glib.h> #include <libxml++/libxml++.h> @@ -1478,3 +1479,21 @@ Config::check_certificates () const return bad; } + +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 (); +} + diff --git a/src/lib/config.h b/src/lib/config.h index e01eab780..39704fde1 100644 --- a/src/lib/config.h +++ b/src/lib/config.h @@ -44,6 +44,10 @@ class Film; class DKDMGroup; class DKDMRecipient; + +extern void save_all_config_as_zip (boost::filesystem::path zip_file); + + /** @class Config * @brief A singleton class holding configuration. */ diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc index 0226eb7af..78543919f 100644 --- a/src/tools/dcpomatic.cc +++ b/src/tools/dcpomatic.cc @@ -256,6 +256,7 @@ enum { ID_tools_send_translations, ID_tools_system_information, ID_tools_restore_default_preferences, + ID_tools_export_preferences, ID_help_report_a_problem, /* IDs for shortcuts (with no associated menu item) */ ID_add_file, @@ -338,6 +339,7 @@ public: Bind (wxEVT_MENU, boost::bind (&DOMFrame::tools_send_translations, this), ID_tools_send_translations); Bind (wxEVT_MENU, boost::bind (&DOMFrame::tools_system_information, this),ID_tools_system_information); Bind (wxEVT_MENU, boost::bind (&DOMFrame::tools_restore_default_preferences, this), ID_tools_restore_default_preferences); + Bind (wxEVT_MENU, boost::bind (&DOMFrame::tools_export_preferences, this), ID_tools_export_preferences); Bind (wxEVT_MENU, boost::bind (&DOMFrame::help_about, this), wxID_ABOUT); Bind (wxEVT_MENU, boost::bind (&DOMFrame::help_report_a_problem, this), ID_help_report_a_problem); @@ -747,6 +749,21 @@ private: } } + void tools_export_preferences () + { + auto dialog = new wxFileDialog ( + this, _("Specify ZIP file"), wxEmptyString, wxT("dcpomatic_config.zip"), wxT("ZIP files (*.zip)|*.zip"), + wxFD_SAVE | wxFD_OVERWRITE_PROMPT + ); + + int const r = dialog->ShowModal (); + dialog->Destroy (); + + if (r == wxID_OK) { + save_all_config_as_zip (wx_to_std(dialog->GetPath())); + } + } + void jobs_make_dcp () { double required; @@ -1375,6 +1392,8 @@ private: add_item (tools, _("System information..."), ID_tools_system_information, 0); tools->AppendSeparator (); add_item (tools, _("Restore default preferences"), ID_tools_restore_default_preferences, ALWAYS); + tools->AppendSeparator (); + add_item (tools, _("Export preferences..."), ID_tools_export_preferences, ALWAYS); wxMenu* help = new wxMenu; #ifdef __WXOSX__ |
