summaryrefslogtreecommitdiff
path: root/src/tools/dcpomatic_verifier.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/dcpomatic_verifier.cc')
-rw-r--r--src/tools/dcpomatic_verifier.cc82
1 files changed, 70 insertions, 12 deletions
diff --git a/src/tools/dcpomatic_verifier.cc b/src/tools/dcpomatic_verifier.cc
index d24100ff3..c881019d8 100644
--- a/src/tools/dcpomatic_verifier.cc
+++ b/src/tools/dcpomatic_verifier.cc
@@ -33,6 +33,7 @@
#include "wx/file_dialog.h"
#include "wx/i18n_setup.h"
#include "wx/id.h"
+#include "wx/wx_signal_manager.h"
#include "wx/verify_dcp_progress_panel.h"
#include "wx/verify_dcp_result_panel.h"
#include "wx/wx_util.h"
@@ -44,11 +45,13 @@
#include "lib/verify_dcp_job.h"
#include "lib/util.h"
#include "lib/variant.h"
+#include "lib/version.h"
#include <dcp/dcp.h>
#include <dcp/search.h>
#include <dcp/text_formatter.h>
#include <dcp/verify_report.h>
LIBDCP_DISABLE_WARNINGS
+#include <wx/cmdline.h>
#include <wx/evtloop.h>
#include <wx/progdlg.h>
#include <wx/wx.h>
@@ -123,7 +126,7 @@ private:
class DOMFrame : public wxFrame
{
public:
- explicit DOMFrame(wxString const& title)
+ explicit DOMFrame(wxString const& title, bool start, vector<boost::filesystem::path> const& dcps_to_load)
: wxFrame(nullptr, -1, title)
/* Use a panel as the only child of the Frame so that we avoid
the dark-grey background on Windows.
@@ -145,7 +148,19 @@ public:
auto dcp_sizer = new wxBoxSizer(wxHORIZONTAL);
add_label_to_sizer(dcp_sizer, _overall_panel, _("DCPs"), true, 0, wxALIGN_CENTER_VERTICAL);
- auto add = [this](wxWindow* parent) {
+ auto load_dcps = [this](vector<boost::filesystem::path> const& dcps) {
+ wxProgressDialog progress(variant::wx::dcpomatic(), _("Examining DCPs"));
+ vector<DCPPath> dcp_paths;
+ for (auto path: dcps) {
+ for (auto const& dcp: dcp::find_potential_dcps(path)) {
+ progress.Pulse();
+ dcp_paths.push_back(DCPPath(dcp, _kdms));
+ }
+ }
+ return dcp_paths;
+ };
+
+ auto add = [&load_dcps](wxWindow* parent) {
#if wxCHECK_VERSION(3, 1, 4)
DirDialog dialog(parent, _("Select DCP(s)"), wxDD_MULTIPLE, "AddVerifierInputPath");
#else
@@ -153,15 +168,7 @@ public:
#endif
if (dialog.show()) {
- wxProgressDialog progress(variant::wx::dcpomatic(), _("Examining DCPs"));
- vector<DCPPath> paths;
- for (auto path: dialog.paths()) {
- for (auto const& dcp: dcp::find_potential_dcps(path)) {
- progress.Pulse();
- paths.push_back(DCPPath(dcp, _kdms));
- }
- }
- return paths;
+ return load_dcps(dialog.paths());
} else {
return std::vector<DCPPath>{};
}
@@ -223,6 +230,12 @@ public:
} catch (...) {}
}
}
+
+ set_dcp_paths(load_dcps(dcps_to_load));
+ _dcps->refresh();
+ if (start) {
+ signal_manager->when_idle(boost::bind(&DOMFrame::verify_clicked, this));
+ }
}
private:
@@ -381,6 +394,14 @@ private:
};
+static const wxCmdLineEntryDesc command_line_description[] = {
+ { wxCMD_LINE_SWITCH, "s", "start", "start verifying specified DCP(s)", wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL },
+ { wxCMD_LINE_SWITCH, "v", "version", "show version", wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL },
+ { wxCMD_LINE_PARAM, 0, 0, "DCP to verify", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
+ { wxCMD_LINE_NONE, "", "", "", wxCmdLineParamType (0), 0 }
+};
+
+
/** @class App
* @brief The magic App class for wxWidgets.
*/
@@ -433,7 +454,10 @@ private:
*/
Config::drop();
- _frame = new DOMFrame(variant::wx::dcpomatic_verifier());
+ signal_manager = new wxSignalManager(this);
+ Bind(wxEVT_IDLE, boost::bind(&App::idle, this, _1));
+
+ _frame = new DOMFrame(variant::wx::dcpomatic_verifier(), _start, _dcps_to_load);
SetTopWindow(_frame);
_frame->Maximize();
_frame->Show();
@@ -497,7 +521,41 @@ private:
report_exception();
}
+ void OnInitCmdLine(wxCmdLineParser& parser) override
+ {
+ parser.SetDesc(command_line_description);
+ parser.SetSwitchChars(char_to_wx("-"));
+ }
+
+ bool OnCmdLineParsed(wxCmdLineParser& parser) override
+ {
+ if (parser.Found(char_to_wx("version"))) {
+ std::cout << "dcpomatic version " << dcpomatic_version << " " << dcpomatic_git_commit << "\n";
+ exit(EXIT_SUCCESS);
+ }
+
+ _start = parser.Found(char_to_wx("start"));
+ for (auto i = 0UL; i < parser.GetParamCount(); ++i) {
+ auto const path = boost::filesystem::path(wx_to_std(parser.GetParam(0)));
+ if (path.filename_is_dot()) {
+ _dcps_to_load.push_back(path.parent_path());
+ } else {
+ _dcps_to_load.push_back(path);
+ }
+ }
+
+ return true;
+ }
+
+ void idle(wxIdleEvent& ev)
+ {
+ signal_manager->ui_idle();
+ ev.Skip();
+ }
+
DOMFrame* _frame = nullptr;
+ bool _start = false;
+ std::vector<boost::filesystem::path> _dcps_to_load;
};