diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-02-12 21:48:06 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-02-12 21:48:06 +0000 |
| commit | 9b78074e1487ac263f84fd1132735fba83045719 (patch) | |
| tree | 286f931e307356ec7d4d9d226aa0d862bcd02987 /src | |
| parent | b77dd4f1ef4d6a1c0c36499f82835e0457469dbd (diff) | |
Add details button to job manager; stretch jobs across the whole of the bottom of the frame; give a better error on low disc space conditions (#48).
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/job.cc | 40 | ||||
| -rw-r--r-- | src/lib/job.h | 10 | ||||
| -rw-r--r-- | src/tools/dvdomatic.cc | 12 | ||||
| -rw-r--r-- | src/wx/film_viewer.cc | 2 | ||||
| -rw-r--r-- | src/wx/job_manager_view.cc | 25 | ||||
| -rw-r--r-- | src/wx/job_manager_view.h | 2 |
6 files changed, 70 insertions, 21 deletions
diff --git a/src/lib/job.cc b/src/lib/job.cc index 896862d14..2ddcf5335 100644 --- a/src/lib/job.cc +++ b/src/lib/job.cc @@ -67,19 +67,33 @@ Job::run_wrapper () set_progress (1); set_state (FINISHED_ERROR); - set_error (String::compose ("%1 (%2)", e.what(), boost::filesystem::path (e.filename()).leaf())); + string m = String::compose ("An error occurred whilst handling the file %1.", boost::filesystem::path (e.filename()).leaf()); + + boost::filesystem::space_info const s = boost::filesystem::space (e.filename()); + if (s.available < pow (1024, 3)) { + m += "\n\nThe drive that the film is stored on is low in disc space. Free some more space and try again."; + } + + set_error (e.what(), m); + } catch (std::exception& e) { set_progress (1); set_state (FINISHED_ERROR); - set_error (e.what ()); + set_error ( + e.what (), + "It is not known what caused this error. The best idea is to report the problem to the DVD-o-matic mailing list (dvdomatic@carlh.net)" + ); } catch (...) { set_progress (1); set_state (FINISHED_ERROR); - set_error ("unknown exception"); + set_error ( + "Unknown error", + "It is not known what caused this error. The best idea is to report the problem to the DVD-o-matic mailing list (dvdomatic@carlh.net)" + ); } } @@ -211,22 +225,30 @@ Job::descend (float a) _stack.push_back (Level (a)); } -/** @return Any error string that the job has generated */ string -Job::error () const +Job::error_details () const +{ + boost::mutex::scoped_lock lm (_state_mutex); + return _error_details; +} + +/** @return A summary of any error that the job has generated */ +string +Job::error_summary () const { boost::mutex::scoped_lock lm (_state_mutex); - return _error; + return _error_summary; } /** Set the current error string. * @param e New error string. */ void -Job::set_error (string e) +Job::set_error (string s, string d) { boost::mutex::scoped_lock lm (_state_mutex); - _error = e; + _error_summary = s; + _error_details = d; } /** Say that this job's progress will be unknown until further notice */ @@ -253,7 +275,7 @@ Job::status () const } else if (finished_ok ()) { s << "OK (ran for " << seconds_to_hms (_ran_for) << ")"; } else if (finished_in_error ()) { - s << "Error (" << error() << ")"; + s << "Error (" << error_summary() << ")"; } return s.str (); diff --git a/src/lib/job.h b/src/lib/job.h index f32cfa811..1ea0a9b17 100644 --- a/src/lib/job.h +++ b/src/lib/job.h @@ -53,7 +53,8 @@ public: bool finished_ok () const; bool finished_in_error () const; - std::string error () const; + std::string error_summary () const; + std::string error_details () const; int elapsed_time () const; virtual std::string status () const; @@ -83,7 +84,7 @@ protected: }; void set_state (State); - void set_error (std::string e); + void set_error (std::string s, std::string d); /** Film for this job */ boost::shared_ptr<Film> _film; @@ -98,8 +99,9 @@ private: mutable boost::mutex _state_mutex; /** current state of the job */ State _state; - /** message for an error that has occurred (when state == FINISHED_ERROR) */ - std::string _error; + /** summary of an error that has occurred (when state == FINISHED_ERROR) */ + std::string _error_summary; + std::string _error_details; /** time that this job was started */ time_t _start_time; diff --git a/src/tools/dvdomatic.cc b/src/tools/dvdomatic.cc index be47b4fe6..bab49c2dc 100644 --- a/src/tools/dvdomatic.cc +++ b/src/tools/dvdomatic.cc @@ -224,13 +224,13 @@ public: film_viewer = new FilmViewer (film, panel); JobManagerView* job_manager_view = new JobManagerView (panel); - wxSizer* rhs_sizer = new wxBoxSizer (wxVERTICAL); - rhs_sizer->Add (film_viewer, 3, wxEXPAND | wxALL); - rhs_sizer->Add (job_manager_view, 1, wxEXPAND | wxALL); + wxSizer* top_sizer = new wxBoxSizer (wxHORIZONTAL); + top_sizer->Add (film_editor, 0, wxALL, 6); + top_sizer->Add (film_viewer, 1, wxEXPAND | wxALL, 6); - wxBoxSizer* main_sizer = new wxBoxSizer (wxHORIZONTAL); - main_sizer->Add (film_editor, 0, wxALL, 6); - main_sizer->Add (rhs_sizer, 1, wxEXPAND | wxALL, 6); + wxBoxSizer* main_sizer = new wxBoxSizer (wxVERTICAL); + main_sizer->Add (top_sizer, 2, wxEXPAND | wxALL, 6); + main_sizer->Add (job_manager_view, 1, wxEXPAND | wxALL, 6); panel->SetSizer (main_sizer); set_menu_sensitivity (); diff --git a/src/wx/film_viewer.cc b/src/wx/film_viewer.cc index a619edf7c..e685b7b35 100644 --- a/src/wx/film_viewer.cc +++ b/src/wx/film_viewer.cc @@ -70,7 +70,7 @@ FilmViewer::FilmViewer (shared_ptr<Film> f, wxWindow* p) h_sizer->Add (_play_button, 0, wxEXPAND); h_sizer->Add (_slider, 1, wxEXPAND); - _v_sizer->Add (h_sizer, 0, wxEXPAND); + _v_sizer->Add (h_sizer, 0, wxEXPAND | wxALL, 6); _panel->Connect (wxID_ANY, wxEVT_PAINT, wxPaintEventHandler (FilmViewer::paint_panel), 0, this); _panel->Connect (wxID_ANY, wxEVT_SIZE, wxSizeEventHandler (FilmViewer::panel_sized), 0, this); diff --git a/src/wx/job_manager_view.cc b/src/wx/job_manager_view.cc index a5c02b163..75842a8d4 100644 --- a/src/wx/job_manager_view.cc +++ b/src/wx/job_manager_view.cc @@ -30,6 +30,7 @@ using std::string; using std::list; +using std::map; using boost::shared_ptr; /** Must be called in the GUI thread */ @@ -41,7 +42,7 @@ JobManagerView::JobManagerView (wxWindow* parent) sizer->Add (_panel, 1, wxEXPAND); SetSizer (sizer); - _table = new wxFlexGridSizer (3, 6, 6); + _table = new wxFlexGridSizer (4, 6, 6); _table->AddGrowableCol (1, 1); _panel->SetSizer (_table); @@ -83,6 +84,11 @@ JobManagerView::update () r.message = new wxStaticText (_panel, wxID_ANY, std_to_wx ("")); _table->Insert (index + 2, r.message, 1, wxALIGN_CENTER_VERTICAL | wxALL, 6); + + r.details = new wxButton (_panel, wxID_ANY, _("Details...")); + r.details->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (JobManagerView::details_clicked), 0, this); + r.details->Enable (false); + _table->Insert (index + 3, r.details, 1, wxALIGN_CENTER_VERTICAL | wxALL, 6); _job_records[*i] = r; } @@ -104,6 +110,9 @@ JobManagerView::update () _job_records[*i].gauge->SetValue (100); _job_records[*i].message->SetLabel (std_to_wx (st)); _job_records[*i].finalised = true; + if (!(*i)->error_details().empty ()) { + _job_records[*i].details->Enable (true); + } } index += 3; @@ -112,3 +121,17 @@ JobManagerView::update () _table->Layout (); FitInside (); } + +void +JobManagerView::details_clicked (wxCommandEvent& ev) +{ + wxObject* o = ev.GetEventObject (); + + for (map<boost::shared_ptr<Job>, JobRecord>::iterator i = _job_records.begin(); i != _job_records.end(); ++i) { + if (i->second.details == o) { + string s = i->first->error_summary(); + s[0] = toupper (s[0]); + error_dialog (this, String::compose ("%1.\n\n%2", s, i->first->error_details())); + } + } +} diff --git a/src/wx/job_manager_view.h b/src/wx/job_manager_view.h index 5c10890ef..d43e795ea 100644 --- a/src/wx/job_manager_view.h +++ b/src/wx/job_manager_view.h @@ -39,6 +39,7 @@ public: private: void periodic (wxTimerEvent &); + void details_clicked (wxCommandEvent &); boost::shared_ptr<wxTimer> _timer; wxPanel* _panel; @@ -46,6 +47,7 @@ private: struct JobRecord { wxGauge* gauge; wxStaticText* message; + wxButton* details; bool finalised; }; |
