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.cc83
1 files changed, 71 insertions, 12 deletions
diff --git a/src/tools/dcpomatic_verifier.cc b/src/tools/dcpomatic_verifier.cc
index d24100ff3..4b3038027 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>
@@ -77,7 +80,7 @@ enum {
class DCPPath
{
public:
- explicit DCPPath(boost::filesystem::path path, vector<dcp::DecryptedKDM> const& kdms)
+ DCPPath(boost::filesystem::path path, vector<dcp::DecryptedKDM> const& kdms)
: _path(std::move(path))
{
check(kdms);
@@ -123,7 +126,7 @@ private:
class DOMFrame : public wxFrame
{
public:
- explicit DOMFrame(wxString const& title)
+ 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.
@@ -153,15 +156,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 +218,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:
@@ -367,6 +368,19 @@ private:
_dcps->refresh();
}
+ vector<DCPPath> load_dcps(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;
+ }
+
wxPanel* _overall_panel = nullptr;
EditableList<DCPPath>* _dcps;
std::vector<DCPPath> _dcp_paths;
@@ -381,6 +395,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 +455,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 +522,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;
};