summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2020-11-28 02:42:50 +0100
committerCarl Hetherington <cth@carlh.net>2020-11-29 23:00:40 +0100
commit0c56d4be9f49592eabec832381608ba75b453df4 (patch)
tree9116cc1ea990082aefaa7792a1aab4e9edbd740a
parent64bd18216738052c150770561f8f78e13ca792b8 (diff)
Better progress reporting during DCP validation (#1812).v2.15.108
-rw-r--r--src/tools/dcpomatic_player.cc16
-rw-r--r--src/wx/verify_dcp_progress_dialog.cc122
-rw-r--r--src/wx/verify_dcp_progress_dialog.h48
-rw-r--r--src/wx/wscript1
4 files changed, 178 insertions, 9 deletions
diff --git a/src/tools/dcpomatic_player.cc b/src/tools/dcpomatic_player.cc
index 9fab8b588..d4e247d62 100644
--- a/src/tools/dcpomatic_player.cc
+++ b/src/tools/dcpomatic_player.cc
@@ -32,6 +32,7 @@
#include "wx/timer_display.h"
#include "wx/system_information_dialog.h"
#include "wx/player_stress_tester.h"
+#include "wx/verify_dcp_progress_dialog.h"
#include "lib/cross.h"
#include "lib/config.h"
#include "lib/util.h"
@@ -787,18 +788,15 @@ private:
shared_ptr<DCPContent> dcp = boost::dynamic_pointer_cast<DCPContent>(_film->content().front());
DCPOMATIC_ASSERT (dcp);
- JobManager* jm = JobManager::instance ();
- jm->add (shared_ptr<Job> (new VerifyDCPJob (dcp->directories())));
- bool const ok = display_progress (_("DCP-o-matic Player"), _("Verifying DCP"));
- if (!ok) {
+ shared_ptr<VerifyDCPJob> job (new VerifyDCPJob(dcp->directories()));
+ VerifyDCPProgressDialog* progress = new VerifyDCPProgressDialog(this, _("DCP-o-matic Player"));
+ bool const completed = progress->run (job);
+ progress->Destroy ();
+ if (!completed) {
return;
}
- DCPOMATIC_ASSERT (!jm->get().empty());
- shared_ptr<VerifyDCPJob> last = dynamic_pointer_cast<VerifyDCPJob> (jm->get().back());
- DCPOMATIC_ASSERT (last);
-
- VerifyDCPDialog* d = new VerifyDCPDialog (this, last);
+ VerifyDCPDialog* d = new VerifyDCPDialog (this, job);
d->ShowModal ();
d->Destroy ();
}
diff --git a/src/wx/verify_dcp_progress_dialog.cc b/src/wx/verify_dcp_progress_dialog.cc
new file mode 100644
index 000000000..dfe496e58
--- /dev/null
+++ b/src/wx/verify_dcp_progress_dialog.cc
@@ -0,0 +1,122 @@
+/*
+ Copyright (C) 2020 Carl Hetherington <cth@carlh.net>
+
+ This file is part of DCP-o-matic.
+
+ DCP-o-matic is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ DCP-o-matic is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+
+#include "verify_dcp_progress_dialog.h"
+#include "wx_util.h"
+#include "lib/cross.h"
+#include "lib/job.h"
+#include "lib/job_manager.h"
+#include <wx/evtloop.h>
+#include <boost/shared_ptr.hpp>
+#include <string>
+
+
+using std::string;
+using boost::optional;
+using boost::shared_ptr;
+
+
+static int const max_file_name_length = 80;
+
+
+VerifyDCPProgressDialog::VerifyDCPProgressDialog (wxWindow* parent, wxString title)
+ : wxDialog (parent, wxID_ANY, title)
+ , _cancel (false)
+{
+ wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL);
+
+ _job_name = new wxStaticText (this, wxID_ANY, wxT(""));
+ overall_sizer->Add (_job_name, 0, wxEXPAND | wxTOP | wxLEFT | wxRIGHT, DCPOMATIC_SIZER_GAP);
+
+ _file_name = new wxStaticText (this, wxID_ANY, wxT(""));
+ wxFont file_name_font (*wxNORMAL_FONT);
+ file_name_font.SetFamily (wxFONTFAMILY_MODERN);
+ file_name_font.SetPointSize (file_name_font.GetPointSize() - 2);
+ _file_name->SetFont (file_name_font);
+
+ int w;
+ int h;
+ _file_name->GetTextExtent (std_to_wx(string(max_file_name_length, 'X')), &w, &h);
+ _file_name->SetMinSize (wxSize(w, -1));
+
+ overall_sizer->Add (_file_name, 0, wxEXPAND | wxLEFT | wxRIGHT | wxTOP, DCPOMATIC_SIZER_GAP);
+
+ _progress = new wxGauge (this, wxID_ANY, 100);
+ overall_sizer->Add (_progress, 0, wxEXPAND | wxALL, DCPOMATIC_SIZER_GAP);
+
+ wxButton* cancel = new wxButton (this, wxID_ANY, _("Cancel"));
+ wxSizer* buttons = new wxBoxSizer (wxHORIZONTAL);
+ buttons->AddStretchSpacer ();
+ buttons->Add (cancel, 0);
+ overall_sizer->Add (buttons, 0, wxEXPAND | wxALL, DCPOMATIC_SIZER_GAP);
+
+ SetSizerAndFit (overall_sizer);
+
+ cancel->Bind (wxEVT_BUTTON, boost::bind(&VerifyDCPProgressDialog::cancel, this));
+}
+
+
+void
+VerifyDCPProgressDialog::cancel ()
+{
+ _cancel = true;
+}
+
+
+bool
+VerifyDCPProgressDialog::run (shared_ptr<Job> job)
+{
+ Show ();
+
+ JobManager* jm = JobManager::instance ();
+ jm->add (job);
+
+ while (jm->work_to_do()) {
+ wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_UI | wxEVT_CATEGORY_USER_INPUT);
+ dcpomatic_sleep_seconds (1);
+ optional<float> const progress = job->progress ();
+ if (progress) {
+ _progress->SetValue (*progress * 100);
+ } else {
+ _progress->Pulse ();
+ }
+ string const sub = job->sub_name ();
+ size_t colon = sub.find (":");
+ if (colon != string::npos) {
+ _job_name->SetLabel (std_to_wx(sub.substr(0, colon)));
+ string file_name;
+ if ((sub.length() - colon - 1) > max_file_name_length) {
+ file_name = "..." + sub.substr(sub.length() - max_file_name_length + 3);
+ } else {
+ file_name = sub.substr(colon + 1);
+ }
+ _file_name->SetLabel (std_to_wx(file_name));
+ } else {
+ _job_name->SetLabel (std_to_wx(sub));
+ }
+
+ if (_cancel) {
+ break;
+ }
+ }
+
+ return !_cancel;
+}
diff --git a/src/wx/verify_dcp_progress_dialog.h b/src/wx/verify_dcp_progress_dialog.h
new file mode 100644
index 000000000..ed0c69055
--- /dev/null
+++ b/src/wx/verify_dcp_progress_dialog.h
@@ -0,0 +1,48 @@
+/*
+ Copyright (C) 2020 Carl Hetherington <cth@carlh.net>
+
+ This file is part of DCP-o-matic.
+
+ DCP-o-matic is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ DCP-o-matic is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+
+#include <wx/wx.h>
+#include <boost/shared_ptr.hpp>
+
+
+class Job;
+
+
+class wxGauge;
+class wxStaticText;
+
+
+class VerifyDCPProgressDialog : public wxDialog
+{
+public:
+ VerifyDCPProgressDialog (wxWindow* parent, wxString title);
+
+ bool run (boost::shared_ptr<Job> job);
+
+private:
+ void cancel ();
+
+ wxStaticText* _job_name;
+ wxStaticText* _file_name;
+ wxGauge* _progress;
+ bool _cancel;
+};
+
diff --git a/src/wx/wscript b/src/wx/wscript
index 429e9c857..989135587 100644
--- a/src/wx/wscript
+++ b/src/wx/wscript
@@ -159,6 +159,7 @@ sources = """
try_unmount_dialog.cc
update_dialog.cc
verify_dcp_dialog.cc
+ verify_dcp_progress_dialog.cc
video_panel.cc
video_view.cc
video_waveform_dialog.cc