From 94903b113b78ad8b939c067f91739a2752b8019e Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 3 Jan 2023 20:47:53 +0100 Subject: [PATCH] Use FileDialog for Add DKDM in the KDM creator. --- src/lib/config.cc | 1 + src/tools/dcpomatic_kdm.cc | 20 ++++++-------------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/lib/config.cc b/src/lib/config.cc index 21e670306..30e80b938 100644 --- a/src/lib/config.cc +++ b/src/lib/config.cc @@ -187,6 +187,7 @@ Config::set_defaults () _custom_languages.clear (); _initial_paths.clear(); _initial_paths["AddFilesPath"] = boost::none; + _initial_paths["AddDKDMPath"] = boost::none; _use_isdcf_name_by_default = true; _write_kdms_to_disk = true; _email_kdms = false; diff --git a/src/tools/dcpomatic_kdm.cc b/src/tools/dcpomatic_kdm.cc index 0d6ecbab0..851dacd54 100644 --- a/src/tools/dcpomatic_kdm.cc +++ b/src/tools/dcpomatic_kdm.cc @@ -22,6 +22,7 @@ #include "wx/about_dialog.h" #include "wx/dcpomatic_button.h" #include "wx/editable_list.h" +#include "wx/file_dialog.h" #include "wx/file_picker_ctrl.h" #include "wx/full_config_dialog.h" #include "wx/job_view_dialog.h" @@ -489,29 +490,20 @@ private: void add_dkdm_clicked () { - auto d = new wxFileDialog( - this, - _("Select DKDM file"), - wxEmptyString, - wxEmptyString, - wxT("XML files|*.xml|All files|*.*"), - wxFD_MULTIPLE - ); + auto dialog = new FileDialog(this, _("Select DKDM file"), wxT("XML files|*.xml|All files|*.*"), wxFD_MULTIPLE, "AddDKDMPath"); - ScopeGuard sg = [d]() { d->Destroy(); }; + ScopeGuard sg = [dialog]() { dialog->Destroy(); }; - if (d->ShowModal() != wxID_OK) { + if (!dialog->show()) { return; } auto chain = Config::instance()->decryption_chain(); DCPOMATIC_ASSERT (chain->key()); - wxArrayString paths; - d->GetPaths(paths); - for (unsigned int i = 0; i < paths.GetCount(); ++i) { + for (auto path: dialog->paths()) { try { - dcp::EncryptedKDM ekdm(dcp::file_to_string(wx_to_std(paths[i]), MAX_KDM_SIZE)); + dcp::EncryptedKDM ekdm(dcp::file_to_string(path, MAX_KDM_SIZE)); /* Decrypt the DKDM to make sure that we can */ dcp::DecryptedKDM dkdm(ekdm, chain->key().get()); -- 2.30.2