More stack-allocated Dialog objects.
[dcpomatic.git] / src / wx / job_view.cc
index 231176e4fd96c773d1f96a779de648647f0ddf3a..b98555e8a2b71f519c71c99a7e9a7f12801aa1df 100644 (file)
 */
 
 
+#include "check_box.h"
+#include "dcpomatic_button.h"
 #include "job_view.h"
-#include "wx_util.h"
 #include "message_dialog.h"
 #include "static_text.h"
-#include "check_box.h"
-#include "dcpomatic_button.h"
-#include "lib/job.h"
-#include "lib/job_manager.h"
+#include "wx_util.h"
+#include "lib/analyse_audio_job.h"
 #include "lib/compose.hpp"
 #include "lib/config.h"
+#include "lib/job.h"
+#include "lib/job_manager.h"
 #include "lib/send_notification_email_job.h"
 #include "lib/transcode_job.h"
-#include "lib/analyse_audio_job.h"
+#include <dcp/warnings.h>
+LIBDCP_DISABLE_WARNINGS
 #include <wx/wx.h>
+LIBDCP_ENABLE_WARNINGS
 #include <boost/algorithm/string.hpp>
 
 
-using std::string;
 using std::min;
 using std::shared_ptr;
+using std::string;
 using boost::bind;
-using std::dynamic_pointer_cast;
 
 
 JobView::JobView (shared_ptr<Job> job, wxWindow* parent, wxWindow* container, wxFlexGridSizer* table)
@@ -85,7 +87,7 @@ JobView::setup ()
        _controls = new wxBoxSizer (wxVERTICAL);
        _controls->Add (_buttons);
        _notify = new CheckBox (_container, _("Notify when complete"));
-       _notify->Bind (wxEVT_CHECKBOX, bind (&JobView::notify_clicked, this));
+       _notify->bind(&JobView::notify_clicked, this);
        _notify->SetValue (Config::instance()->default_notify());
        _controls->Add (_notify, 0, wxTOP, DCPOMATIC_BUTTON_STACK_GAP);
 
@@ -103,8 +105,11 @@ JobView::setup ()
 void
 JobView::maybe_pulse ()
 {
-       if (_gauge && _job->running() && !_job->progress()) {
-               _gauge->Pulse ();
+       if (_gauge && _job->running()) {
+               auto elapsed = _job->seconds_since_last_progress_update();
+               if (!_job->progress() || !elapsed || *elapsed > 2) {
+                       _gauge->Pulse ();
+               }
        }
 }
 
@@ -151,12 +156,11 @@ JobView::finished ()
        }
 
        if (_job->message()) {
-               auto d = new MessageDialog (_parent, std_to_wx(_job->name()), std_to_wx(_job->message().get()));
-               d->ShowModal ();
-               d->Destroy ();
+               MessageDialog dialog(_parent, std_to_wx(_job->name()), std_to_wx(_job->message().get()));
+               dialog.ShowModal();
        }
 
-       if ((dynamic_pointer_cast<TranscodeJob>(_job) || dynamic_pointer_cast<AnalyseAudioJob>(_job)) && _notify->GetValue()) {
+       if (_job->enable_notify() && _notify->GetValue()) {
                if (Config::instance()->notification(Config::MESSAGE_BOX)) {
                        wxMessageBox (std_to_wx(_job->name() + ": " + _job->status()), _("DCP-o-matic"), wxICON_INFORMATION);
                }