Merge remote-tracking branch 'origin/main' into v2.17.x
[dcpomatic.git] / src / wx / kdm_cpl_panel.cc
index b1bbc1cf01d6d711aef38f0665f6a146474d3be3..4e1eb8f3404a62003f1c3a08a5dbffa1e08a7dae 100644 (file)
@@ -41,15 +41,15 @@ KDMCPLPanel::KDMCPLPanel (wxWindow* parent, vector<CPLSummary> cpls)
 
        /* CPL choice */
        auto s = new wxBoxSizer (wxHORIZONTAL);
-       add_label_to_sizer (s, this, _("CPL"), true, 0, wxLEFT | wxRIGHT | wxALIGN_CENTER_VERTICAL);
+       add_label_to_sizer (s, this, _("CPL"), true, 0, wxLEFT | wxRIGHT | wxALIGN_CENTRE_VERTICAL);
        _cpl = new wxChoice (this, wxID_ANY);
-       s->Add (_cpl, 1, wxEXPAND);
+       s->Add (_cpl, 1, wxTOP | wxEXPAND, DCPOMATIC_CHOICE_TOP_PAD);
        _cpl_browse = new Button (this, _("Browse..."));
-       s->Add (_cpl_browse, 0, wxLEFT | wxALIGN_CENTER_VERTICAL, DCPOMATIC_SIZER_X_GAP);
+       s->Add (_cpl_browse, 0, wxLEFT, DCPOMATIC_SIZER_X_GAP);
        vertical->Add (s, 0, wxEXPAND | wxTOP, DCPOMATIC_SIZER_GAP + 2);
 
        /* CPL details */
-       wxFlexGridSizer* table = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
+       auto table = new wxFlexGridSizer(2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
        add_label_to_sizer (table, this, _("DCP directory"), true);
        _dcp_directory = new StaticText (this, "");
        table->Add (_dcp_directory);
@@ -63,8 +63,8 @@ KDMCPLPanel::KDMCPLPanel (wxWindow* parent, vector<CPLSummary> cpls)
 
        update_cpl_choice ();
 
-       _cpl->Bind        (wxEVT_CHOICE, boost::bind (&KDMCPLPanel::update_cpl_summary, this));
-       _cpl_browse->Bind (wxEVT_BUTTON,  boost::bind (&KDMCPLPanel::cpl_browse_clicked, this));
+       _cpl->Bind(wxEVT_CHOICE, boost::bind(&KDMCPLPanel::update_cpl_summary, this));
+       _cpl_browse->Bind(wxEVT_BUTTON, boost::bind(&KDMCPLPanel::cpl_browse_clicked, this));
 
        SetSizerAndFit (vertical);
 }
@@ -96,26 +96,25 @@ KDMCPLPanel::update_cpl_summary ()
        _dcp_directory->SetLabel (std_to_wx (_cpls[n].dcp_directory));
        _cpl_id->SetLabel (std_to_wx (_cpls[n].cpl_id));
        _cpl_annotation_text->SetLabel (std_to_wx(_cpls[n].cpl_annotation_text.get_value_or("")));
+
+       Changed();
 }
 
 void
 KDMCPLPanel::cpl_browse_clicked ()
 {
-       wxFileDialog* d = new wxFileDialog (this, _("Select CPL XML file"), wxEmptyString, wxEmptyString, "*.xml");
+       auto d = make_wx<wxFileDialog>(this, _("Select CPL XML file"), wxEmptyString, wxEmptyString, "*.xml");
        if (d->ShowModal() == wxID_CANCEL) {
-               d->Destroy ();
                return;
        }
 
        boost::filesystem::path cpl_file (wx_to_std (d->GetPath ()));
        boost::filesystem::path dcp_dir = cpl_file.parent_path ();
 
-       d->Destroy ();
-
        try {
                /* XXX: hack alert */
                cxml::Document cpl_document ("CompositionPlaylist");
-               cpl_document.read_file (cpl_file);
+               cpl_document.read_file(dcp::filesystem::fix_long_path(cpl_file));
 
                bool encrypted = false;
                for (auto i: cpl_document.node_children("ReelList")) {