Add cancel button to player progress (#1294).
authorCarl Hetherington <cth@carlh.net>
Wed, 16 May 2018 22:07:21 +0000 (23:07 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 16 May 2018 22:07:21 +0000 (23:07 +0100)
ChangeLog
src/tools/dcpomatic_player.cc

index dd55434..15c2bbf 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,12 @@
+2018-05-16  Carl Hetherington  <cth@carlh.net>
+
+       * Add cancel button to DCP verification progress dialogue (#1294).
+
 2018-05-15  Carl Hetherington  <cth@carlh.net>
 
        * Fix crash on enabling telecine filter.
 
-       * Fix incorrect subtitle positining in a VF when there are more than
+       * Fix incorrect subtitle positioning in a VF when there are more than
        two consecutive reels with no subtitles.
 
        * Fix missing burnt-in / previewed subtitles containing ampersands.
index d1f3778..5c8c7d1 100644 (file)
@@ -194,8 +194,8 @@ public:
                }
 
                _film->examine_and_add_content (dcp, true);
-               progress (_("Loading DCP"));
-               if (!report_errors_from_last_job()) {
+               bool const ok = progress (_("Loading DCP"));
+               if (!ok || !report_errors_from_last_job()) {
                        return;
                }
 
@@ -343,8 +343,8 @@ private:
                        DCPOMATIC_ASSERT (dcp);
                        dcp->add_ov (wx_to_std(c->GetPath()));
                        JobManager::instance()->add(shared_ptr<Job>(new ExamineContentJob (_film, dcp)));
-                       progress (_("Loading DCP"));
-                       if (!report_errors_from_last_job()) {
+                       bool const ok = progress (_("Loading DCP"));
+                       if (!ok || !report_errors_from_last_job()) {
                                return;
                        }
                        setup_from_dcp (dcp);
@@ -432,7 +432,10 @@ private:
 
                JobManager* jm = JobManager::instance ();
                jm->add (shared_ptr<Job> (new VerifyDCPJob (dcp->directories())));
-               progress (_("Verifying DCP"));
+               bool const ok = progress (_("Verifying DCP"));
+               if (!ok) {
+                       return;
+               }
 
                DCPOMATIC_ASSERT (!jm->get().empty());
                shared_ptr<VerifyDCPJob> last = dynamic_pointer_cast<VerifyDCPJob> (jm->get().back());
@@ -568,18 +571,29 @@ private:
 
 private:
 
-       void progress (wxString task)
+       /** @return false if the task was cancelled */
+       bool progress (wxString task)
        {
                JobManager* jm = JobManager::instance ();
 
-               wxProgressDialog* progress = new wxProgressDialog (_("DCP-o-matic Player"), task);
+               wxProgressDialog* progress = new wxProgressDialog (_("DCP-o-matic Player"), task, 100, 0, wxPD_CAN_ABORT);
+
+               bool ok = true;
 
                while (jm->work_to_do() || signal_manager->ui_idle()) {
                        dcpomatic_sleep (1);
-                       progress->Pulse ();
+                       if (!progress->Pulse()) {
+                               /* user pressed cancel */
+                               BOOST_FOREACH (shared_ptr<Job> i, jm->get()) {
+                                       i->cancel();
+                               }
+                               ok = false;
+                               break;
+                       }
                }
 
                progress->Destroy ();
+               return ok;
        }
 
        bool report_errors_from_last_job ()