From: Carl Hetherington Date: Thu, 2 Jun 2016 20:03:03 +0000 (+0100) Subject: Fix missing content properties when using translations. X-Git-Tag: v2.8.8~3 X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=31150ddd0fafac4426d11a758be9d77699b7377c;hp=cec71ef08475af291b968873757979c5e977facb Fix missing content properties when using translations. --- diff --git a/ChangeLog b/ChangeLog index e3935f733..b49063e76 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2016-06-02 Carl Hetherington + * Fix broken content properties under translation. + * Version 2.8.7 released. 2016-06-01 c.hetherington diff --git a/src/lib/audio_content.cc b/src/lib/audio_content.cc index b159aa50d..2b402991c 100644 --- a/src/lib/audio_content.cc +++ b/src/lib/audio_content.cc @@ -292,34 +292,34 @@ AudioContent::add_properties (list& p) const } if (stream) { - p.push_back (UserProperty (_("Audio"), _("Channels"), stream->channels ())); - p.push_back (UserProperty (_("Audio"), _("Content audio sample rate"), stream->frame_rate(), _("Hz"))); + p.push_back (UserProperty (UserProperty::AUDIO, _("Channels"), stream->channels ())); + p.push_back (UserProperty (UserProperty::AUDIO, _("Content audio sample rate"), stream->frame_rate(), _("Hz"))); } FrameRateChange const frc (_parent->active_video_frame_rate(), _parent->film()->video_frame_rate()); ContentTime const c (_parent->full_length(), frc); p.push_back ( - UserProperty (_("Length"), _("Full length in video frames at content rate"), c.frames_round(frc.source)) + UserProperty (UserProperty::LENGTH, _("Full length in video frames at content rate"), c.frames_round(frc.source)) ); if (stream) { p.push_back ( UserProperty ( - _("Length"), + UserProperty::LENGTH, _("Full length in audio samples at content rate"), c.frames_round (stream->frame_rate ()) ) ); } - p.push_back (UserProperty (_("Audio"), _("DCP frame rate"), resampled_frame_rate (), _("Hz"))); - p.push_back (UserProperty (_("Length"), _("Full length in video frames at DCP rate"), c.frames_round (frc.dcp))); + p.push_back (UserProperty (UserProperty::AUDIO, _("DCP frame rate"), resampled_frame_rate (), _("Hz"))); + p.push_back (UserProperty (UserProperty::LENGTH, _("Full length in video frames at DCP rate"), c.frames_round (frc.dcp))); if (stream) { p.push_back ( UserProperty ( - _("Length"), + UserProperty::LENGTH, _("Full length in audio samples at DCP rate"), c.frames_round (resampled_frame_rate ()) ) diff --git a/src/lib/content.cc b/src/lib/content.cc index 66b0d477e..b8e7f8ad2 100644 --- a/src/lib/content.cc +++ b/src/lib/content.cc @@ -359,9 +359,13 @@ Content::active_video_frame_rate () const void Content::add_properties (list& p) const { - p.push_back (UserProperty (_("General"), _("Filename"), path(0).string ())); + p.push_back (UserProperty (UserProperty::GENERAL, _("Filename"), path(0).string ())); if (_video_frame_rate) { - p.push_back (UserProperty (_("General"), _("Video frame rate"), raw_convert (_video_frame_rate.get(), 5), _("frames per second"))); + p.push_back ( + UserProperty ( + UserProperty::GENERAL, _("Video frame rate"), raw_convert (_video_frame_rate.get(), 5), _("frames per second") + ) + ); } } diff --git a/src/lib/ffmpeg_content.cc b/src/lib/ffmpeg_content.cc index cc6a703ba..0f66180d0 100644 --- a/src/lib/ffmpeg_content.cc +++ b/src/lib/ffmpeg_content.cc @@ -122,6 +122,9 @@ FFmpegContent::FFmpegContent (shared_ptr film, cxml::ConstNodePtr no FFmpegContent::FFmpegContent (shared_ptr film, vector > c) : Content (film, c) { + /* XXX: this should look at c to decide which of video/audio/subtitle + get created. + */ video.reset (new VideoContent (this, c)); audio.reset (new AudioContent (this, c)); subtitle.reset (new SubtitleContent (this, c)); @@ -434,21 +437,21 @@ FFmpegContent::add_properties (list& p) const case AVCOL_RANGE_UNSPECIFIED: /// TRANSLATORS: this means that the range of pixel values used in this /// file is unknown (not specified in the file). - p.push_back (UserProperty (_("Video"), _("Colour range"), _("Unspecified"))); + p.push_back (UserProperty (UserProperty::VIDEO, _("Colour range"), _("Unspecified"))); break; case AVCOL_RANGE_MPEG: /// TRANSLATORS: this means that the range of pixel values used in this /// file is limited, so that not all possible values are valid. p.push_back ( UserProperty ( - _("Video"), _("Colour range"), String::compose (_("Limited (%1-%2)"), (total - sub) / 2, (total + sub) / 2) + UserProperty::VIDEO, _("Colour range"), String::compose (_("Limited (%1-%2)"), (total - sub) / 2, (total + sub) / 2) ) ); break; case AVCOL_RANGE_JPEG: /// TRANSLATORS: this means that the range of pixel values used in this /// file is full, so that all possible pixel values are valid. - p.push_back (UserProperty (_("Video"), _("Colour range"), String::compose (_("Full (0-%1)"), total))); + p.push_back (UserProperty (UserProperty::VIDEO, _("Colour range"), String::compose (_("Full (0-%1)"), total))); break; default: DCPOMATIC_ASSERT (false); @@ -458,17 +461,17 @@ FFmpegContent::add_properties (list& p) const case AVCOL_RANGE_UNSPECIFIED: /// TRANSLATORS: this means that the range of pixel values used in this /// file is unknown (not specified in the file). - p.push_back (UserProperty (_("Video"), _("Colour range"), _("Unspecified"))); + p.push_back (UserProperty (UserProperty::VIDEO, _("Colour range"), _("Unspecified"))); break; case AVCOL_RANGE_MPEG: /// TRANSLATORS: this means that the range of pixel values used in this /// file is limited, so that not all possible values are valid. - p.push_back (UserProperty (_("Video"), _("Colour range"), _("Limited"))); + p.push_back (UserProperty (UserProperty::VIDEO, _("Colour range"), _("Limited"))); break; case AVCOL_RANGE_JPEG: /// TRANSLATORS: this means that the range of pixel values used in this /// file is full, so that all possible pixel values are valid. - p.push_back (UserProperty (_("Video"), _("Colour range"), _("Full"))); + p.push_back (UserProperty (UserProperty::VIDEO, _("Colour range"), _("Full"))); break; default: DCPOMATIC_ASSERT (false); @@ -490,7 +493,7 @@ FFmpegContent::add_properties (list& p) const }; DCPOMATIC_ASSERT (AVCOL_PRI_NB <= 11); - p.push_back (UserProperty (_("Video"), _("Colour primaries"), primaries[_color_primaries])); + p.push_back (UserProperty (UserProperty::VIDEO, _("Colour primaries"), primaries[_color_primaries])); char const * transfers[] = { _("Unspecified"), @@ -514,7 +517,7 @@ FFmpegContent::add_properties (list& p) const }; DCPOMATIC_ASSERT (AVCOL_TRC_NB <= 18); - p.push_back (UserProperty (_("Video"), _("Colour transfer characteristic"), transfers[_color_trc])); + p.push_back (UserProperty (UserProperty::VIDEO, _("Colour transfer characteristic"), transfers[_color_trc])); char const * spaces[] = { _("RGB / sRGB (IEC61966-2-1)"), @@ -531,10 +534,10 @@ FFmpegContent::add_properties (list& p) const }; DCPOMATIC_ASSERT (AVCOL_SPC_NB == 11); - p.push_back (UserProperty (_("Video"), _("Colourspace"), spaces[_colorspace])); + p.push_back (UserProperty (UserProperty::VIDEO, _("Colourspace"), spaces[_colorspace])); if (_bits_per_pixel) { - p.push_back (UserProperty (_("Video"), _("Bits per pixel"), raw_convert (_bits_per_pixel.get ()))); + p.push_back (UserProperty (UserProperty::VIDEO, _("Bits per pixel"), raw_convert (_bits_per_pixel.get ()))); } } diff --git a/src/lib/user_property.h b/src/lib/user_property.h index b27cd4151..a7a6f63da 100644 --- a/src/lib/user_property.h +++ b/src/lib/user_property.h @@ -26,15 +26,22 @@ class UserProperty { public: + enum Category { + GENERAL, + VIDEO, + AUDIO, + LENGTH + }; + template - UserProperty (std::string category_, std::string key_, T value_, std::string unit_ = "") + UserProperty (Category category_, std::string key_, T value_, std::string unit_ = "") : category (category_) , key (key_) , value (raw_convert (value_)) , unit (unit_) {} - std::string category; + Category category; std::string key; std::string value; std::string unit; diff --git a/src/lib/video_content.cc b/src/lib/video_content.cc index 9ffc63c5d..473bd784c 100644 --- a/src/lib/video_content.cc +++ b/src/lib/video_content.cc @@ -419,8 +419,8 @@ VideoContent::processing_description () const void VideoContent::add_properties (list& p) const { - p.push_back (UserProperty (_("Video"), _("Length"), raw_convert (length ()), _("video frames"))); - p.push_back (UserProperty (_("Video"), _("Size"), raw_convert (size().width) + "x" + raw_convert (size().height))); + p.push_back (UserProperty (UserProperty::VIDEO, _("Length"), raw_convert (length ()), _("video frames"))); + p.push_back (UserProperty (UserProperty::VIDEO, _("Size"), raw_convert (size().width) + "x" + raw_convert (size().height))); } void diff --git a/src/wx/content_properties_dialog.cc b/src/wx/content_properties_dialog.cc index 8bb0a6b1f..bd20d48e6 100644 --- a/src/wx/content_properties_dialog.cc +++ b/src/wx/content_properties_dialog.cc @@ -37,7 +37,7 @@ using boost::dynamic_pointer_cast; ContentPropertiesDialog::ContentPropertiesDialog (wxWindow* parent, shared_ptr content) : TableDialog (parent, _("Content Properties"), 2, 1, false) { - map > grouped; + map > grouped; BOOST_FOREACH (UserProperty i, content->user_properties()) { if (grouped.find(i.category) == grouped.end()) { grouped[i.category] = list (); @@ -45,10 +45,10 @@ ContentPropertiesDialog::ContentPropertiesDialog (wxWindow* parent, shared_ptr > const & groups, string name) +ContentPropertiesDialog::maybe_add_group (map > const & groups, UserProperty::Category category) { - map >::const_iterator i = groups.find (name); + map >::const_iterator i = groups.find (category); if (i == groups.end()) { return; } - wxStaticText* m = new wxStaticText (this, wxID_ANY, std_to_wx (i->first)); + wxString category_name; + switch (i->first) { + case UserProperty::GENERAL: + category_name = _("General"); + break; + case UserProperty::VIDEO: + category_name = _("Video"); + break; + case UserProperty::AUDIO: + category_name = _("Audio"); + break; + case UserProperty::LENGTH: + category_name = _("Length"); + break; + } + + wxStaticText* m = new wxStaticText (this, wxID_ANY, category_name); wxFont font (*wxNORMAL_FONT); font.SetWeight (wxFONTWEIGHT_BOLD); m->SetFont (font); diff --git a/src/wx/content_properties_dialog.h b/src/wx/content_properties_dialog.h index eb6f11ddb..92aa5c6d7 100644 --- a/src/wx/content_properties_dialog.h +++ b/src/wx/content_properties_dialog.h @@ -19,6 +19,7 @@ */ #include "table_dialog.h" +#include "lib/user_property.h" #include #include #include @@ -32,5 +33,5 @@ public: ContentPropertiesDialog (wxWindow* parent, boost::shared_ptr content); private: - void maybe_add_group (std::map > const & groups, std::string name); + void maybe_add_group (std::map > const & groups, UserProperty::Category category); };