Make sure that crop preview rectangle is properly hidden when we close the auto crop...
[dcpomatic.git] / src / wx / kdm_output_panel.cc
index 8a2757557e940952eb38a01ec294c6bf9f878f78..98f40813514a7a38e4061fad8188bf040046b6b3 100644 (file)
@@ -23,6 +23,7 @@
 #include "confirm_kdm_email_dialog.h"
 #include "dcpomatic_button.h"
 #include "kdm_advanced_dialog.h"
+#include "kdm_choice.h"
 #include "kdm_output_panel.h"
 #include "kdm_timing_panel.h"
 #include "name_format_editor.h"
 #include "lib/cinema.h"
 #include "lib/config.h"
 #include "lib/send_kdm_email_job.h"
-#include "lib/warnings.h"
 #include <dcp/exceptions.h>
 #include <dcp/types.h>
+#include <dcp/warnings.h>
 #ifdef DCPOMATIC_USE_OWN_PICKER
 #include "dir_picker_ctrl.h"
 #else
-DCPOMATIC_DISABLE_WARNINGS
+LIBDCP_DISABLE_WARNINGS
 #include <wx/filepicker.h>
-DCPOMATIC_ENABLE_WARNINGS
+LIBDCP_ENABLE_WARNINGS
 #endif
-DCPOMATIC_DISABLE_WARNINGS
+LIBDCP_DISABLE_WARNINGS
 #include <wx/stdpaths.h>
-DCPOMATIC_ENABLE_WARNINGS
+LIBDCP_ENABLE_WARNINGS
 
 
 using std::exception;
@@ -69,14 +70,9 @@ KDMOutputPanel::KDMOutputPanel (wxWindow* parent)
        add_label_to_sizer (table, this, _("KDM type"), true, 0, wxLEFT | wxRIGHT | wxALIGN_CENTRE_VERTICAL);
 
        auto type = new wxBoxSizer (wxHORIZONTAL);
-       _type = new wxChoice (this, wxID_ANY);
-       _type->Append ("Modified Transitional 1", ((void *) dcp::Formulation::MODIFIED_TRANSITIONAL_1));
-       _type->Append ("DCI Any", ((void *) dcp::Formulation::DCI_ANY));
-       _type->Append ("DCI Specific", ((void *) dcp::Formulation::DCI_SPECIFIC));
-       _type->Append ("Multiple Modified Transitional 1", ((void *) dcp::Formulation::MULTIPLE_MODIFIED_TRANSITIONAL_1));
-       _type->Append ("Modified Transitional 1 (without AuthorizedDeviceInfo)", ((void *) dcp::Formulation::MODIFIED_TRANSITIONAL_TEST));
+       _type = new KDMChoice (this);
        type->Add (_type, 1, wxTOP, DCPOMATIC_CHOICE_TOP_PAD);
-       _type->SetSelection (0);
+       _type->set(Config::instance()->default_kdm_type());
        auto advanced = new Button (this, _("Advanced..."));
        type->Add (advanced, 0, wxLEFT | wxALIGN_CENTER_VERTICAL, DCPOMATIC_SIZER_X_GAP);
        table->Add (type, 1, wxTOP, DCPOMATIC_CHOICE_TOP_PAD);
@@ -118,7 +114,7 @@ KDMOutputPanel::KDMOutputPanel (wxWindow* parent)
        _folder = new wxDirPickerCtrl (this, wxID_ANY, wxEmptyString, wxDirSelectorPromptStr, wxDefaultPosition, wxSize (300, -1));
 #endif
 
-       auto path = Config::instance()->default_kdm_directory ();
+       auto path = Config::instance()->default_kdm_directory();
        if (path) {
                _folder->SetPath (std_to_wx (path->string ()));
        } else {
@@ -153,10 +149,11 @@ KDMOutputPanel::KDMOutputPanel (wxWindow* parent)
                break;
        }
 
-       _write_to->SetValue (true);
+       _write_to->SetValue (Config::instance()->write_kdms_to_disk());
+       _email->SetValue (Config::instance()->email_kdms());
 
-       _write_to->Bind     (wxEVT_CHECKBOX, boost::bind (&KDMOutputPanel::setup_sensitivity, this));
-       _email->Bind        (wxEVT_CHECKBOX, boost::bind (&KDMOutputPanel::setup_sensitivity, this));
+       _write_to->Bind     (wxEVT_CHECKBOX, boost::bind (&KDMOutputPanel::write_to_changed, this));
+       _email->Bind        (wxEVT_CHECKBOX, boost::bind (&KDMOutputPanel::email_changed, this));
        _write_flat->Bind   (wxEVT_RADIOBUTTON, boost::bind (&KDMOutputPanel::kdm_write_type_changed, this));
        _write_folder->Bind (wxEVT_RADIOBUTTON, boost::bind (&KDMOutputPanel::kdm_write_type_changed, this));
        _write_zip->Bind    (wxEVT_RADIOBUTTON, boost::bind (&KDMOutputPanel::kdm_write_type_changed, this));
@@ -166,6 +163,22 @@ KDMOutputPanel::KDMOutputPanel (wxWindow* parent)
 }
 
 
+void
+KDMOutputPanel::write_to_changed ()
+{
+       Config::instance()->set_write_kdms_to_disk(_write_to->GetValue());
+       setup_sensitivity ();
+}
+
+
+void
+KDMOutputPanel::email_changed ()
+{
+       Config::instance()->set_email_kdms(_email->GetValue());
+       setup_sensitivity ();
+}
+
+
 void
 KDMOutputPanel::setup_sensitivity ()
 {
@@ -313,7 +326,7 @@ KDMOutputPanel::make (
 dcp::Formulation
 KDMOutputPanel::formulation () const
 {
-       return (dcp::Formulation) reinterpret_cast<intptr_t> (_type->GetClientData (_type->GetSelection()));
+       return _type->get();
 }