Emit no audio from DCPs if none is mapped
[dcpomatic.git] / src / wx / kdm_output_panel.cc
index 98f40813514a7a38e4061fad8188bf040046b6b3..b4d94838ba18332f307466338f7789be636f2051 100644 (file)
@@ -22,6 +22,7 @@
 #include "check_box.h"
 #include "confirm_kdm_email_dialog.h"
 #include "dcpomatic_button.h"
+#include "extra_kdm_email_dialog.h"
 #include "kdm_advanced_dialog.h"
 #include "kdm_choice.h"
 #include "kdm_output_panel.h"
@@ -50,6 +51,7 @@ using std::exception;
 using std::function;
 using std::list;
 using std::make_pair;
+using std::make_shared;
 using std::pair;
 using std::shared_ptr;
 using std::string;
@@ -77,6 +79,10 @@ KDMOutputPanel::KDMOutputPanel (wxWindow* parent)
        type->Add (advanced, 0, wxLEFT | wxALIGN_CENTER_VERTICAL, DCPOMATIC_SIZER_X_GAP);
        table->Add (type, 1, wxTOP, DCPOMATIC_CHOICE_TOP_PAD);
 
+       add_label_to_sizer(table, this, _("Annotation text"), true, 0, wxLEFT | wxRIGHT | wxALIGN_CENTER_VERTICAL);
+       _annotation_text = new wxTextCtrl(this, wxID_ANY);
+       table->Add(_annotation_text, 1, wxEXPAND);
+
        add_label_to_sizer (table, this, _("Folder / ZIP name format"), true, 0, wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT);
        _container_name_format = new NameFormatEditor (this, Config::instance()->kdm_container_name_format(), dcp::NameFormat::Map(), dcp::NameFormat::Map(), "");
        table->Add (_container_name_format->panel(), 1, wxEXPAND);
@@ -87,7 +93,7 @@ KDMOutputPanel::KDMOutputPanel (wxWindow* parent)
        align->Add (format, 0, wxTOP, 2);
        table->Add (align, 0, wxALIGN_RIGHT | wxRIGHT, DCPOMATIC_SIZER_GAP - 2);
 #else
-       align->Add (format, 0, wxLEFT, DCPOMATIC_SIZER_GAP - 2);
+       align->Add (format, 0, wxLEFT, DCPOMATIC_SIZER_GAP);
        table->Add (align, 0, wxTOP | wxRIGHT | wxALIGN_TOP, DCPOMATIC_SIZER_GAP);
 #endif
        dcp::NameFormat::Map titles;
@@ -135,7 +141,8 @@ KDMOutputPanel::KDMOutputPanel (wxWindow* parent)
 
        _email = new CheckBox (this, _("Send by email"));
        table->Add (_email, 1, wxEXPAND);
-       table->AddSpacer (0);
+       auto add_email_addresses = new wxButton(this, wxID_ANY, _("Set additional email addresses..."));
+       table->Add (add_email_addresses);
 
        switch (Config::instance()->last_kdm_write_type().get_value_or(Config::KDM_WRITE_FLAT)) {
        case Config::KDM_WRITE_FLAT:
@@ -152,8 +159,9 @@ KDMOutputPanel::KDMOutputPanel (wxWindow* parent)
        _write_to->SetValue (Config::instance()->write_kdms_to_disk());
        _email->SetValue (Config::instance()->email_kdms());
 
-       _write_to->Bind     (wxEVT_CHECKBOX, boost::bind (&KDMOutputPanel::write_to_changed, this));
-       _email->Bind        (wxEVT_CHECKBOX, boost::bind (&KDMOutputPanel::email_changed, this));
+       _write_to->bind(&KDMOutputPanel::write_to_changed, this);
+       _email->bind(&KDMOutputPanel::email_changed, this);
+       add_email_addresses->Bind (wxEVT_BUTTON, boost::bind(&KDMOutputPanel::add_email_addresses_clicked, 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));
@@ -168,6 +176,7 @@ KDMOutputPanel::write_to_changed ()
 {
        Config::instance()->set_write_kdms_to_disk(_write_to->GetValue());
        setup_sensitivity ();
+       MethodChanged();
 }
 
 
@@ -176,6 +185,7 @@ KDMOutputPanel::email_changed ()
 {
        Config::instance()->set_email_kdms(_email->GetValue());
        setup_sensitivity ();
+       MethodChanged();
 }
 
 
@@ -193,12 +203,11 @@ KDMOutputPanel::setup_sensitivity ()
 void
 KDMOutputPanel::advanced_clicked ()
 {
-       auto d = new KDMAdvancedDialog (this, _forensic_mark_video, _forensic_mark_audio, _forensic_mark_audio_up_to);
-       d->ShowModal ();
-       _forensic_mark_video = d->forensic_mark_video ();
-       _forensic_mark_audio = d->forensic_mark_audio ();
-       _forensic_mark_audio_up_to = d->forensic_mark_audio_up_to ();
-       d->Destroy ();
+       KDMAdvancedDialog dialog(this, _forensic_mark_video, _forensic_mark_audio, _forensic_mark_audio_up_to);
+       dialog.ShowModal();
+       _forensic_mark_video = dialog.forensic_mark_video();
+       _forensic_mark_audio = dialog.forensic_mark_audio();
+       _forensic_mark_audio_up_to = dialog.forensic_mark_audio_up_to();
 }
 
 
@@ -301,13 +310,12 @@ KDMOutputPanel::make (
                }
 
                if (_email->GetValue ()) {
-                       job.reset (
-                               new SendKDMEmailJob (
-                                       cinema_kdms,
-                                       _container_name_format->get(),
-                                       _filename_format->get(),
-                                       name
-                                       )
+                       job = make_shared<SendKDMEmailJob>(
+                               cinema_kdms,
+                               _container_name_format->get(),
+                               _filename_format->get(),
+                               name,
+                               _extra_addresses
                                );
                }
 
@@ -335,3 +343,35 @@ KDMOutputPanel::directory () const
 {
        return wx_to_std (_folder->GetPath ());
 }
+
+
+void
+KDMOutputPanel::add_email_addresses_clicked ()
+{
+       ExtraKDMEmailDialog dialog(this, _extra_addresses);
+       if (dialog.ShowModal() == wxID_OK) {
+               _extra_addresses = dialog.get();
+       }
+}
+
+
+bool
+KDMOutputPanel::method_selected() const
+{
+       return _write_to->GetValue() || _email->GetValue();
+}
+
+
+void
+KDMOutputPanel::set_annotation_text(string text)
+{
+       checked_set(_annotation_text, std::move(text));
+}
+
+
+string
+KDMOutputPanel::annotation_text() const
+{
+       return wx_to_std(_annotation_text->GetValue());
+}
+