X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fwx%2Fproperties_dialog.cc;h=61e1f34f0ab1d8513d18a464dae7cd4fb835e5ef;hb=7f8062032e16d9c9cfc28659a6da67f8205dc27b;hp=aaba31d6e6075be047c0faffa22e9eb38bafdcc1;hpb=4e01dd6b7c235f273d8b1d9233247c956198f1ab;p=dcpomatic.git diff --git a/src/wx/properties_dialog.cc b/src/wx/properties_dialog.cc index aaba31d6e..61e1f34f0 100644 --- a/src/wx/properties_dialog.cc +++ b/src/wx/properties_dialog.cc @@ -25,10 +25,14 @@ #include "properties_dialog.h" #include "wx_util.h" -using namespace std; -using namespace boost; +using std::string; +using std::stringstream; +using std::fixed; +using std::setprecision; +using boost::shared_ptr; +using boost::lexical_cast; -PropertiesDialog::PropertiesDialog (wxWindow* parent, Film* film) +PropertiesDialog::PropertiesDialog (wxWindow* parent, shared_ptr film) : wxDialog (parent, wxID_ANY, _("Film Properties"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE) , _film (film) { @@ -49,19 +53,24 @@ PropertiesDialog::PropertiesDialog (wxWindow* parent, Film* film) add_label_to_sizer (table, this, "Frames already encoded"); _encoded = new ThreadedStaticText (this, "counting...", boost::bind (&PropertiesDialog::frames_already_encoded, this)); table->Add (_encoded, 1, wxALIGN_CENTER_VERTICAL); - - _frames->SetLabel (std_to_wx (lexical_cast (_film->length ()))); - double const disk = ((double) Config::instance()->j2k_bandwidth() / 8) * _film->length() / (_film->frames_per_second () * 1073741824); - stringstream s; - s << fixed << setprecision (1) << disk << "Gb"; - _disk_for_frames->SetLabel (std_to_wx (s.str ())); - stringstream t; - t << fixed << setprecision (1) << (disk * 2) << "Gb"; - _total_disk->SetLabel (std_to_wx (t.str ())); + if (_film->length()) { + _frames->SetLabel (std_to_wx (lexical_cast (_film->length().get()))); + double const disk = ((double) Config::instance()->j2k_bandwidth() / 8) * _film->length().get() / (_film->frames_per_second () * 1073741824); + stringstream s; + s << fixed << setprecision (1) << disk << "Gb"; + _disk_for_frames->SetLabel (std_to_wx (s.str ())); + stringstream t; + t << fixed << setprecision (1) << (disk * 2) << "Gb"; + _total_disk->SetLabel (std_to_wx (t.str ())); + } else { + _frames->SetLabel (_("unknown")); + _disk_for_frames->SetLabel (_("unknown")); + _total_disk->SetLabel (_("unknown")); + } wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL); - overall_sizer->Add (table, 0, wxALL, 8); + overall_sizer->Add (table, 0, wxALL, 6); wxSizer* buttons = CreateSeparatedButtonSizer (wxOK); if (buttons) { @@ -78,12 +87,13 @@ PropertiesDialog::frames_already_encoded () const stringstream u; try { u << _film->encoded_frames (); - } catch (thread_interrupted &) { + } catch (boost::thread_interrupted &) { return ""; } - if (_film->length()) { - u << " (" << (_film->encoded_frames() * 100 / _film->length()) << "%)"; + if (_film->dcp_length()) { + /* XXX: encoded_frames() should check which frames have been encoded */ + u << " (" << ((_film->encoded_frames() - _film->dcp_trim_start()) * 100 / _film->dcp_length().get()) << "%)"; } return u.str (); }