Use FileDialog for Add DKDM in the KDM creator.
authorCarl Hetherington <cth@carlh.net>
Tue, 3 Jan 2023 19:47:53 +0000 (20:47 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 4 Jan 2023 09:25:10 +0000 (10:25 +0100)
src/lib/config.cc
src/tools/dcpomatic_kdm.cc

index 21e6703061cede3a1a37e24d7c8f50cdb51f301e..30e80b938658719b4e46ea05f04a57a84bcef268 100644 (file)
@@ -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;
index 0d6ecbab011d28b574360d93d53db7eba8097e24..851dacd54fd39c2c8ad066c2a98c55489ce9c565 100644 (file)
@@ -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());