X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Ftools%2Fdcpomatic_combiner.cc;h=8e7337f65b06e95748ec78c21f22bd129ba6c410;hb=e572ffd2e0bdc59cd00103a242d290d89e039c93;hp=19103fc335b17fbc3bf083be4ab22a9e887184d4;hpb=bd7f4bbde17d2087ba4c4bddf6439b3df869b1db;p=dcpomatic.git diff --git a/src/tools/dcpomatic_combiner.cc b/src/tools/dcpomatic_combiner.cc index 19103fc33..8e7337f65 100644 --- a/src/tools/dcpomatic_combiner.cc +++ b/src/tools/dcpomatic_combiner.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2020 Carl Hetherington + Copyright (C) 2020-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -19,30 +19,32 @@ */ +#include "wx/dir_dialog.h" #include "wx/dir_picker_ctrl.h" #include "wx/editable_list.h" #include "wx/wx_signal_manager.h" #include "lib/combine_dcp_job.h" #include "lib/config.h" +#include "lib/constants.h" #include "lib/cross.h" #include "lib/job_manager.h" -#include "lib/util.h" #include -DCPOMATIC_DISABLE_WARNINGS +LIBDCP_DISABLE_WARNINGS #include -DCPOMATIC_ENABLE_WARNINGS +LIBDCP_ENABLE_WARNINGS #include #include #include #include +using std::dynamic_pointer_cast; using std::exception; +using std::make_shared; +using std::shared_ptr; using std::string; using std::vector; -using boost::dynamic_pointer_cast; using boost::optional; -using boost::shared_ptr; #if BOOST_VERSION >= 106100 using namespace boost::placeholders; #endif @@ -55,18 +57,23 @@ display_string (boost::filesystem::path p, int) } -class DirDialogWrapper : public wxDirDialog +class DirDialogWrapper : public DirDialog { public: DirDialogWrapper (wxWindow* parent) - : wxDirDialog (parent, _("Choose a DCP folder"), wxT(""), wxDD_DIR_MUST_EXIST) + : DirDialog (parent, _("Choose a DCP folder"), wxDD_DIR_MUST_EXIST, "AddCombinerInputPath") { } - boost::filesystem::path get () const + virtual int ShowModal() override { - return boost::filesystem::path(wx_to_std(GetPath())); + return DirDialog::show() ? wxID_OK : wxID_CANCEL; + } + + optional get () const + { + return path(); } void set (boost::filesystem::path) @@ -80,13 +87,13 @@ class DOMFrame : public wxFrame { public: explicit DOMFrame (wxString const & title) - : wxFrame (0, -1, title) + : wxFrame (nullptr, -1, title) { /* Use a panel as the only child of the Frame so that we avoid the dark-grey background on Windows. */ - wxPanel* overall_panel = new wxPanel (this); - wxSizer* s = new wxBoxSizer (wxHORIZONTAL); + auto overall_panel = new wxPanel (this); + auto s = new wxBoxSizer (wxHORIZONTAL); s->Add (overall_panel, 1, wxEXPAND); SetSizer (s); @@ -99,18 +106,24 @@ public: boost::bind(&DOMFrame::inputs, this), boost::bind(&DOMFrame::set_inputs, this, _1), &display_string, - false, - true + EditableListTitle::VISIBLE, + EditableListButton::NEW | EditableListButton::REMOVE ); - wxBoxSizer* output = new wxBoxSizer (wxHORIZONTAL); + auto output = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP); + output->AddGrowableCol (1, 1); + + add_label_to_sizer (output, overall_panel, _("Annotation text"), true, 0, wxLEFT | wxRIGHT | wxALIGN_CENTRE_VERTICAL); + _annotation_text = new wxTextCtrl (overall_panel, wxID_ANY, wxT("")); + output->Add (_annotation_text, 1, wxEXPAND); + add_label_to_sizer (output, overall_panel, _("Output DCP folder"), true, 0, wxLEFT | wxRIGHT | wxALIGN_CENTRE_VERTICAL); _output = new DirPickerCtrl (overall_panel); output->Add (_output, 1, wxEXPAND); _combine = new Button (overall_panel, _("Combine")); - wxBoxSizer* sizer = new wxBoxSizer (wxVERTICAL); + auto sizer = new wxBoxSizer (wxVERTICAL); sizer->Add (_input, 1, wxALL | wxEXPAND, DCPOMATIC_DIALOG_BORDER); sizer->Add (output, 0, wxALL | wxEXPAND, DCPOMATIC_DIALOG_BORDER); sizer->Add (_combine, 0, wxALL | wxALIGN_RIGHT, DCPOMATIC_DIALOG_BORDER); @@ -137,9 +150,11 @@ private: void combine () { - boost::filesystem::path const output = wx_to_std(_output->GetPath()); + using namespace boost::filesystem; + + path const output = wx_to_std(_output->GetPath()); - if (boost::filesystem::is_directory(output) && !boost::filesystem::is_empty(output)) { + if (is_directory(output) && !is_empty(output)) { if (!confirm_dialog ( this, std_to_wx ( @@ -150,7 +165,7 @@ private: )) { return; } - } else if (boost::filesystem::is_regular_file(output)) { + } else if (is_regular_file(output)) { error_dialog ( this, String::compose (wx_to_std(_("%1 already exists as a file, so you cannot use it for a DCP.")), output.string()) @@ -158,21 +173,21 @@ private: return; } - JobManager* jm = JobManager::instance (); - jm->add (shared_ptr(new CombineDCPJob(_inputs, output))); + auto jm = JobManager::instance (); + jm->add (make_shared(_inputs, output, wx_to_std(_annotation_text->GetValue()))); bool const ok = display_progress (_("DCP-o-matic Combine"), _("Combining DCPs")); if (!ok) { return; } DCPOMATIC_ASSERT (!jm->get().empty()); - shared_ptr last = dynamic_pointer_cast (jm->get().back()); + auto last = dynamic_pointer_cast (jm->get().back()); DCPOMATIC_ASSERT (last); if (last->finished_ok()) { message_dialog (this, _("DCPs combined successfully.")); } else { - wxString m = std_to_wx(last->error_summary()); + auto m = std_to_wx(last->error_summary()); if (!last->error_details().empty()) { m += wxString::Format(" (%s)", std_to_wx(last->error_details())); } @@ -186,6 +201,7 @@ private: } EditableList* _input; + wxTextCtrl* _annotation_text = nullptr; DirPickerCtrl* _output; vector _inputs; Button* _combine; @@ -195,14 +211,12 @@ private: class App : public wxApp { public: - App () - : _frame (0) - {} + App () {} - bool OnInit () + bool OnInit () override { try { - Config::FailedToLoad.connect (boost::bind (&App::config_failed_to_load, this)); + Config::FailedToLoad.connect(boost::bind(&App::config_failed_to_load, this, _1)); Config::Warning.connect (boost::bind (&App::config_warning, this, _1)); SetAppName (_("DCP-o-matic Combiner")); @@ -249,16 +263,16 @@ public: } catch (exception& e) { - error_dialog (0, wxString::Format ("DCP-o-matic DCP Combiner could not start."), std_to_wx(e.what())); + error_dialog (nullptr, wxString::Format ("DCP-o-matic DCP Combiner could not start."), std_to_wx(e.what())); return false; } return true; } - void config_failed_to_load () + void config_failed_to_load(Config::LoadFailure what) { - message_dialog (_frame, _("The existing configuration failed to load. Default values will be used instead. These may take a short time to create.")); + report_config_load_failure(_frame, what); } void config_warning (string m) @@ -279,7 +293,7 @@ public: } catch (FileError& e) { error_dialog ( 0, - wxString::Format ( + wxString::Format( _("An exception occurred: %s (%s)\n\n") + REPORT_PROBLEM, std_to_wx (e.what()), std_to_wx (e.file().string().c_str ()) @@ -288,29 +302,29 @@ public: } catch (exception& e) { error_dialog ( 0, - wxString::Format ( + wxString::Format( _("An exception occurred: %s.\n\n") + REPORT_PROBLEM, std_to_wx (e.what ()) ) ); } catch (...) { - error_dialog (0, _("An unknown exception occurred.") + " " + REPORT_PROBLEM); + error_dialog (nullptr, _("An unknown exception occurred.") + " " + REPORT_PROBLEM); } } - bool OnExceptionInMainLoop () + bool OnExceptionInMainLoop () override { report_exception (); /* This will terminate the program */ return false; } - void OnUnhandledException () + void OnUnhandledException () override { report_exception (); } - DOMFrame* _frame; + DOMFrame* _frame = nullptr; }; IMPLEMENT_APP (App)