Default to filtering DKDM filenames to only see *.xml, and allow
authorCarl Hetherington <cth@carlh.net>
Wed, 17 Aug 2022 14:00:38 +0000 (16:00 +0200)
committerCarl Hetherington <cth@carlh.net>
Wed, 17 Aug 2022 14:00:38 +0000 (16:00 +0200)
multiple DKDMs to be added at the same time (#2296).

src/tools/dcpomatic_kdm.cc

index 7a8d7cf349d532749ba69b8cfaf217d7bc232d41..30f2e0b827f9b3b999a5897c66b9fe76d7a2aee0 100644 (file)
@@ -448,41 +448,53 @@ private:
 
        void add_dkdm_clicked ()
        {
-               auto d = new wxFileDialog (this, _("Select DKDM file"));
+               auto d = new wxFileDialog(
+                       this,
+                       _("Select DKDM file"),
+                       wxEmptyString,
+                       wxEmptyString,
+                       wxT("XML files|*.xml|All files|*.*"),
+                       wxFD_MULTIPLE
+                       );
+
                if (d->ShowModal() == wxID_OK) {
                        auto chain = Config::instance()->decryption_chain();
                        DCPOMATIC_ASSERT (chain->key());
 
-                       try {
-                               dcp::EncryptedKDM ekdm(dcp::file_to_string (wx_to_std (d->GetPath ()), MAX_KDM_SIZE));
-                               /* Decrypt the DKDM to make sure that we can */
-                               dcp::DecryptedKDM dkdm(ekdm, chain->key().get());
-
-                               auto new_dkdm = make_shared<DKDM>(ekdm);
-                               auto group = dynamic_pointer_cast<DKDMGroup> (selected_dkdm());
-                               if (!group) {
-                                       group = Config::instance()->dkdms ();
+                       wxArrayString paths;
+                       d->GetPaths(paths);
+                       for (unsigned int i = 0; i < paths.GetCount(); ++i) {
+                               try {
+                                       dcp::EncryptedKDM ekdm(dcp::file_to_string(wx_to_std(paths[i]), MAX_KDM_SIZE));
+                                       /* Decrypt the DKDM to make sure that we can */
+                                       dcp::DecryptedKDM dkdm(ekdm, chain->key().get());
+
+                                       auto new_dkdm = make_shared<DKDM>(ekdm);
+                                       auto group = dynamic_pointer_cast<DKDMGroup> (selected_dkdm());
+                                       if (!group) {
+                                               group = Config::instance()->dkdms ();
+                                       }
+                                       add_dkdm_model (new_dkdm, group);
+                                       add_dkdm_view (new_dkdm);
+                               } catch (dcp::KDMFormatError& e) {
+                                       error_dialog (
+                                               this,
+                                               _("Could not read file as a KDM.  Perhaps it is badly formatted, or not a KDM at all."),
+                                               std_to_wx(e.what())
+                                               );
+                                       return;
+                               } catch (dcp::KDMDecryptionError &) {
+                                       error_dialog (
+                                               this,
+                                               _("Could not decrypt the DKDM.  Perhaps it was not created with the correct certificate.")
+                                               );
+                               } catch (dcp::MiscError& e) {
+                                       error_dialog (
+                                               this,
+                                               _("Could not read file as a KDM.  It is much too large.  Make sure you are loading a DKDM (XML) file."),
+                                               std_to_wx(e.what())
+                                               );
                                }
-                               add_dkdm_model (new_dkdm, group);
-                               add_dkdm_view (new_dkdm);
-                       } catch (dcp::KDMFormatError& e) {
-                               error_dialog (
-                                       this,
-                                       _("Could not read file as a KDM.  Perhaps it is badly formatted, or not a KDM at all."),
-                                       std_to_wx(e.what())
-                                       );
-                               return;
-                       } catch (dcp::KDMDecryptionError &) {
-                               error_dialog (
-                                       this,
-                                       _("Could not decrypt the DKDM.  Perhaps it was not created with the correct certificate.")
-                                       );
-                       } catch (dcp::MiscError& e) {
-                               error_dialog (
-                                       this,
-                                       _("Could not read file as a KDM.  It is much too large.  Make sure you are loading a DKDM (XML) file."),
-                                       std_to_wx(e.what())
-                                       );
                        }
                }
                d->Destroy ();