From fb16d3932b49957672b5da3ced016186c926de9b Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 22 Sep 2012 00:29:58 +0100 Subject: [PATCH] Tweak properties dialogue layout and add a note of how many J2K frames have already been encoded. --- ChangeLog | 4 ++++ src/lib/film.cc | 11 ++++++++++- src/lib/film.h | 2 ++ src/wx/properties_dialog.cc | 19 +++++++++++++++---- src/wx/properties_dialog.h | 1 + 5 files changed, 32 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 693b87b18..cc348b21e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,10 @@ * Rename servomatic to servomatic_cli and add a very basic system-tray-dwelling GUI server. + * Tweak formatting of properties dialogue + and add a note of how many J2K frames + have already been encoded. + 2012-09-18 Carl Hetherington * Fix non-working removal of encode servers. diff --git a/src/lib/film.cc b/src/lib/film.cc index 3b74f1888..92b91d0ac 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -429,7 +430,6 @@ Film::j2k_dir () const filesystem::path p; - /* Start with j2c */ p /= "j2c"; @@ -641,3 +641,12 @@ Film::copy_from_dvd () JobManager::instance()->add (j); } +int +Film::encoded_frames () const +{ + if (format() == 0) { + return 0; + } + + return distance (filesystem::directory_iterator (j2k_dir()), filesystem::directory_iterator ()); +} diff --git a/src/lib/film.h b/src/lib/film.h index 3ff671fbe..40aa7b0f6 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -229,6 +229,8 @@ public: return _log; } + int encoded_frames () const; + /** Emitted when some metadata property has changed */ mutable sigc::signal1 Changed; diff --git a/src/wx/properties_dialog.cc b/src/wx/properties_dialog.cc index a447091c3..122d647ca 100644 --- a/src/wx/properties_dialog.cc +++ b/src/wx/properties_dialog.cc @@ -30,20 +30,24 @@ using namespace boost; PropertiesDialog::PropertiesDialog (wxWindow* parent, Film* film) : wxDialog (parent, wxID_ANY, _("Film Properties"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE) { - wxFlexGridSizer* table = new wxFlexGridSizer (2, 6, 6); + wxFlexGridSizer* table = new wxFlexGridSizer (2, 3, 6); add_label_to_sizer (table, this, "Frames"); _frames = new wxStaticText (this, wxID_ANY, std_to_wx ("")); table->Add (_frames, 1, wxALIGN_CENTER_VERTICAL); - add_label_to_sizer (table, this, "Disk space for frames"); + add_label_to_sizer (table, this, "Disk space required for frames"); _disk_for_frames = new wxStaticText (this, wxID_ANY, std_to_wx ("")); table->Add (_disk_for_frames, 1, wxALIGN_CENTER_VERTICAL); - add_label_to_sizer (table, this, "Total disk space"); + add_label_to_sizer (table, this, "Total disk space required"); _total_disk = new wxStaticText (this, wxID_ANY, std_to_wx ("")); table->Add (_total_disk, 1, wxALIGN_CENTER_VERTICAL); + add_label_to_sizer (table, this, "Frames already encoded"); + _encoded = new wxStaticText (this, wxID_ANY, std_to_wx ("")); + 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; @@ -54,8 +58,15 @@ PropertiesDialog::PropertiesDialog (wxWindow* parent, Film* film) t << fixed << setprecision (1) << (disk * 2) << "Gb"; _total_disk->SetLabel (std_to_wx (t.str ())); + stringstream u; + u << film->encoded_frames(); + if (film->length()) { + u << " (" << (film->encoded_frames() * 100 / film->length()) << "%)"; + } + _encoded->SetLabel (std_to_wx (u.str ())); + wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL); - overall_sizer->Add (table); + overall_sizer->Add (table, 0, wxALL, 8); wxSizer* buttons = CreateSeparatedButtonSizer (wxOK); if (buttons) { diff --git a/src/wx/properties_dialog.h b/src/wx/properties_dialog.h index e74344ff6..25c11e8d0 100644 --- a/src/wx/properties_dialog.h +++ b/src/wx/properties_dialog.h @@ -30,5 +30,6 @@ private: wxStaticText* _frames; wxStaticText* _disk_for_frames; wxStaticText* _total_disk; + wxStaticText* _encoded; }; -- 2.30.2