From: Carl Hetherington Date: Tue, 9 May 2017 10:24:03 +0000 (+0100) Subject: Simple cover sheet support (#1039). X-Git-Tag: v2.11.4~41 X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=89ae13638097f259f3e50b4b61068dd23451107d Simple cover sheet support (#1039). --- diff --git a/ChangeLog b/ChangeLog index f349abaa9..bc8e6bb81 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2017-05-09 Carl Hetherington + + * Write a simple cover sheet when making a DCP (#1039). + 2017-05-08 Carl Hetherington * Show multiple tracks in the timeline if there are overlapping subtitles (#941). diff --git a/graphics/linux/128/dcpomatic2.png b/graphics/linux/128/dcpomatic2.png index ae3ae23e9..5ff12d6ed 100644 Binary files a/graphics/linux/128/dcpomatic2.png and b/graphics/linux/128/dcpomatic2.png differ diff --git a/graphics/linux/16/dcpomatic2.png b/graphics/linux/16/dcpomatic2.png index ea90bf94b..82ed012b7 100644 Binary files a/graphics/linux/16/dcpomatic2.png and b/graphics/linux/16/dcpomatic2.png differ diff --git a/graphics/linux/22/dcpomatic2.png b/graphics/linux/22/dcpomatic2.png index d99654779..6d27f8c11 100644 Binary files a/graphics/linux/22/dcpomatic2.png and b/graphics/linux/22/dcpomatic2.png differ diff --git a/graphics/linux/256/dcpomatic2.png b/graphics/linux/256/dcpomatic2.png index 394da0332..bf734859c 100644 Binary files a/graphics/linux/256/dcpomatic2.png and b/graphics/linux/256/dcpomatic2.png differ diff --git a/graphics/linux/32/dcpomatic2.png b/graphics/linux/32/dcpomatic2.png index 5b0b2de56..482f5ded8 100644 Binary files a/graphics/linux/32/dcpomatic2.png and b/graphics/linux/32/dcpomatic2.png differ diff --git a/graphics/linux/48/dcpomatic2.png b/graphics/linux/48/dcpomatic2.png index 746c589a9..8e0d6087b 100644 Binary files a/graphics/linux/48/dcpomatic2.png and b/graphics/linux/48/dcpomatic2.png differ diff --git a/graphics/linux/512/dcpomatic2.png b/graphics/linux/512/dcpomatic2.png index 6f7543daf..4cd893804 100644 Binary files a/graphics/linux/512/dcpomatic2.png and b/graphics/linux/512/dcpomatic2.png differ diff --git a/graphics/linux/64/dcpomatic2.png b/graphics/linux/64/dcpomatic2.png index f0c487d06..0e446e77d 100644 Binary files a/graphics/linux/64/dcpomatic2.png and b/graphics/linux/64/dcpomatic2.png differ diff --git a/graphics/osx/dcpomatic2.iconset/icon_128x128.png b/graphics/osx/dcpomatic2.iconset/icon_128x128.png index 6e028b2c3..f0d6df56d 100644 Binary files a/graphics/osx/dcpomatic2.iconset/icon_128x128.png and b/graphics/osx/dcpomatic2.iconset/icon_128x128.png differ diff --git a/graphics/osx/dcpomatic2.iconset/icon_128x128@2x.png b/graphics/osx/dcpomatic2.iconset/icon_128x128@2x.png index 6e028b2c3..f0d6df56d 100644 Binary files a/graphics/osx/dcpomatic2.iconset/icon_128x128@2x.png and b/graphics/osx/dcpomatic2.iconset/icon_128x128@2x.png differ diff --git a/graphics/osx/dcpomatic2.iconset/icon_16x16.png b/graphics/osx/dcpomatic2.iconset/icon_16x16.png index e2b750e94..cf150c09b 100644 Binary files a/graphics/osx/dcpomatic2.iconset/icon_16x16.png and b/graphics/osx/dcpomatic2.iconset/icon_16x16.png differ diff --git a/graphics/osx/dcpomatic2.iconset/icon_16x16@2x.png b/graphics/osx/dcpomatic2.iconset/icon_16x16@2x.png index e2b750e94..cf150c09b 100644 Binary files a/graphics/osx/dcpomatic2.iconset/icon_16x16@2x.png and b/graphics/osx/dcpomatic2.iconset/icon_16x16@2x.png differ diff --git a/graphics/osx/dcpomatic2.iconset/icon_256x256.png b/graphics/osx/dcpomatic2.iconset/icon_256x256.png index 724869aac..d84d2285b 100644 Binary files a/graphics/osx/dcpomatic2.iconset/icon_256x256.png and b/graphics/osx/dcpomatic2.iconset/icon_256x256.png differ diff --git a/graphics/osx/dcpomatic2.iconset/icon_256x256@2x.png b/graphics/osx/dcpomatic2.iconset/icon_256x256@2x.png index 724869aac..d84d2285b 100644 Binary files a/graphics/osx/dcpomatic2.iconset/icon_256x256@2x.png and b/graphics/osx/dcpomatic2.iconset/icon_256x256@2x.png differ diff --git a/graphics/osx/dcpomatic2.iconset/icon_32x32.png b/graphics/osx/dcpomatic2.iconset/icon_32x32.png index abad340e1..46e0fb786 100644 Binary files a/graphics/osx/dcpomatic2.iconset/icon_32x32.png and b/graphics/osx/dcpomatic2.iconset/icon_32x32.png differ diff --git a/graphics/osx/dcpomatic2.iconset/icon_32x32@2x.png b/graphics/osx/dcpomatic2.iconset/icon_32x32@2x.png index abad340e1..46e0fb786 100644 Binary files a/graphics/osx/dcpomatic2.iconset/icon_32x32@2x.png and b/graphics/osx/dcpomatic2.iconset/icon_32x32@2x.png differ diff --git a/graphics/osx/dcpomatic2.iconset/icon_512x512.png b/graphics/osx/dcpomatic2.iconset/icon_512x512.png index 846c7bd9e..ff8c3758c 100644 Binary files a/graphics/osx/dcpomatic2.iconset/icon_512x512.png and b/graphics/osx/dcpomatic2.iconset/icon_512x512.png differ diff --git a/graphics/osx/dcpomatic2.iconset/icon_512x512@2x.png b/graphics/osx/dcpomatic2.iconset/icon_512x512@2x.png index 846c7bd9e..ff8c3758c 100644 Binary files a/graphics/osx/dcpomatic2.iconset/icon_512x512@2x.png and b/graphics/osx/dcpomatic2.iconset/icon_512x512@2x.png differ diff --git a/graphics/osx/preferences/cover_sheet.png b/graphics/osx/preferences/cover_sheet.png new file mode 100644 index 000000000..ec8136848 Binary files /dev/null and b/graphics/osx/preferences/cover_sheet.png differ diff --git a/graphics/src/cover_sheet.svg b/graphics/src/cover_sheet.svg new file mode 100644 index 000000000..c6511ceef --- /dev/null +++ b/graphics/src/cover_sheet.svg @@ -0,0 +1,253 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + Openclipart + + + tango internet mail + 2010-03-29T08:04:16 + "E-mail" icon from <a href="http://tango.freedesktop.org/Tango_Desktop_Project"> Tango Project </a> \n<br><br> \nSince version 0.8.90 Tango Project icons are Public Domain: <a href="http://tango.freedesktop.org/Frequently_Asked_Questions#Terms_of_Use.3F"> Tango Project FAQ </a> + https://openclipart.org/detail/35215/tango-internet-mail-by-warszawianka + + + warszawianka + + + + + email + envelope + externalsource + icon + letter + tango + + + + + + + + + + + diff --git a/graphics/update b/graphics/update index 2b72080f8..06e4de302 100755 --- a/graphics/update +++ b/graphics/update @@ -55,7 +55,7 @@ else # OS X preferences icons # servers.png does not have an SVG version mkdir -p osx/preferences - for i in colour_conversions defaults kdm_email keys tms; do + for i in colour_conversions defaults kdm_email cover_sheet keys tms; do $INKSCAPE osx/preferences/$i.png src/$i.svg -w 32 -h 32 done diff --git a/graphics/web/favicon-128x128.png b/graphics/web/favicon-128x128.png index 3c684fc8b..93a1ebbcd 100644 Binary files a/graphics/web/favicon-128x128.png and b/graphics/web/favicon-128x128.png differ diff --git a/graphics/web/favicon-16x16.png b/graphics/web/favicon-16x16.png index 666411ee2..7dfaf3522 100644 Binary files a/graphics/web/favicon-16x16.png and b/graphics/web/favicon-16x16.png differ diff --git a/graphics/web/favicon-256x256.png b/graphics/web/favicon-256x256.png index 6be1a06ba..df20b5c92 100644 Binary files a/graphics/web/favicon-256x256.png and b/graphics/web/favicon-256x256.png differ diff --git a/graphics/web/favicon-32x32.png b/graphics/web/favicon-32x32.png index 86d2850f1..c7b87ba05 100644 Binary files a/graphics/web/favicon-32x32.png and b/graphics/web/favicon-32x32.png differ diff --git a/graphics/web/favicon-64x64.png b/graphics/web/favicon-64x64.png index 0c849d96a..0fa6bd7d6 100644 Binary files a/graphics/web/favicon-64x64.png and b/graphics/web/favicon-64x64.png differ diff --git a/graphics/web/logo.png b/graphics/web/logo.png new file mode 100644 index 000000000..992894e43 Binary files /dev/null and b/graphics/web/logo.png differ diff --git a/src/lib/config.cc b/src/lib/config.cc index c0ab44923..a19a60f55 100644 --- a/src/lib/config.cc +++ b/src/lib/config.cc @@ -132,6 +132,7 @@ Config::set_defaults () _allowed_dcp_frame_rates.push_back (60); set_kdm_email_to_default (); + set_cover_sheet_to_default (); } void @@ -329,6 +330,9 @@ try } _preview_sound = f.optional_bool_child("PreviewSound").get_value_or (false); _preview_sound_output = f.optional_string_child("PreviewSoundOutput"); + if (f.optional_string_child("CoverSheet")) { + _cover_sheet = f.optional_string_child("CoverSheet").get(); + } /* Replace any cinemas from config.xml with those from the configured file */ if (boost::filesystem::exists (_cinemas_file)) { @@ -514,6 +518,7 @@ Config::write_config () const if (_preview_sound_output) { root->add_child("PreviewSoundOutput")->add_child_text (_preview_sound_output.get()); } + root->add_child("CoverSheet")->add_child_text (_cover_sheet); try { doc.write_to_file_formatted (path("config.xml").string ()); @@ -607,6 +612,18 @@ Config::reset_kdm_email () changed (); } +void +Config::set_cover_sheet_to_default () +{ + _cover_sheet = _( + "$CPL_NAME\n\n" + "Type: $TYPE\n" + "Format: $CONTAINER\n" + "Audio: $AUDIO\n" + "Length: $LENGTH\n" + ); +} + void Config::add_to_history (boost::filesystem::path p) { @@ -707,3 +724,10 @@ Config::config_path () { return path("config.xml", false); } + +void +Config::reset_cover_sheet () +{ + set_cover_sheet_to_default (); + changed (); +} diff --git a/src/lib/config.h b/src/lib/config.h index 3e74a5049..fc6315242 100644 --- a/src/lib/config.h +++ b/src/lib/config.h @@ -327,6 +327,10 @@ public: return _preview_sound; } + std::string cover_sheet () const { + return _cover_sheet; + } + boost::optional preview_sound_output () const { return _preview_sound_output; } @@ -599,6 +603,12 @@ public: maybe_set (_nagged[nag], nagged); } + void set_cover_sheet (std::string s) { + maybe_set (_cover_sheet, s); + } + + void reset_cover_sheet (); + void changed (Property p = OTHER); boost::signals2::signal Changed; /** Emitted if read() failed on an existing Config file. There is nothing @@ -629,6 +639,7 @@ private: void read (); void set_defaults (); void set_kdm_email_to_default (); + void set_cover_sheet_to_default (); void read_cinemas (cxml::Document const & f); boost::shared_ptr create_certificate_chain (); boost::filesystem::path directory_or (boost::optional dir, boost::filesystem::path a) const; @@ -737,6 +748,7 @@ private: bool _preview_sound; /** name of a specific sound output stream to use for preview, or empty to use the default */ boost::optional _preview_sound_output; + std::string _cover_sheet; /** Singleton instance, or 0 */ static Config* _instance; diff --git a/src/lib/film.cc b/src/lib/film.cc index df19af77f..04ff00250 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -723,24 +723,9 @@ Film::isdcf_name (bool if_created_now) const /* Count mapped audio channels */ - int non_lfe = 0; - int lfe = 0; - - BOOST_FOREACH (int i, mapped_audio_channels ()) { - if (i >= audio_channels()) { - /* This channel is mapped but is not included in the DCP */ - continue; - } - - if (static_cast (i) == dcp::LFE) { - ++lfe; - } else { - ++non_lfe; - } - } - - if (non_lfe) { - d += String::compose("_%1%2", non_lfe, lfe); + pair ch = audio_channel_types (mapped_audio_channels(), audio_channels()); + if (ch.first) { + d += String::compose("_%1%2", ch.first, ch.second); } /* XXX: HI/VI */ diff --git a/src/lib/util.cc b/src/lib/util.cc index 574d1d889..b1dfeab55 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -88,6 +88,7 @@ using std::pair; using std::cout; using std::bad_alloc; using std::set_terminate; +using std::make_pair; using boost::shared_ptr; using boost::thread; using boost::optional; @@ -706,3 +707,29 @@ careful_string_filter (string s) return out; } + +/** @param mapped List of mapped audio channels from a Film. + * @param channels Total number of channels in the Film. + * @return First: number of non-LFE channels, second: number of LFE channels. + */ +pair +audio_channel_types (list mapped, int channels) +{ + int non_lfe = 0; + int lfe = 0; + + BOOST_FOREACH (int i, mapped) { + if (i >= channels) { + /* This channel is mapped but is not included in the DCP */ + continue; + } + + if (static_cast (i) == dcp::LFE) { + ++lfe; + } else { + ++non_lfe; + } + } + + return make_pair (non_lfe, lfe); +} diff --git a/src/lib/util.h b/src/lib/util.h index 4e6e50dd7..db6c37fe1 100644 --- a/src/lib/util.h +++ b/src/lib/util.h @@ -83,5 +83,6 @@ extern std::string video_asset_filename (boost::shared_ptr as extern std::string audio_asset_filename (boost::shared_ptr asset, int reel_index, int reel_count, boost::optional content_summary); extern float relaxed_string_to_float (std::string); extern std::string careful_string_filter (std::string); +extern std::pair audio_channel_types (std::list mapped, int channels); #endif diff --git a/src/lib/writer.cc b/src/lib/writer.cc index 87cdac2d8..ec4689b2f 100644 --- a/src/lib/writer.cc +++ b/src/lib/writer.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2016 Carl Hetherington + Copyright (C) 2012-2017 Carl Hetherington This file is part of DCP-o-matic. @@ -539,6 +539,51 @@ Writer::finish () LOG_GENERAL ( N_("Wrote %1 FULL, %2 FAKE, %3 REPEAT, %4 pushed to disk"), _full_written, _fake_written, _repeat_written, _pushed_to_disk ); + + write_cover_sheet (); +} + +void +Writer::write_cover_sheet () +{ + boost::filesystem::path const cover = _film->file ("COVER_SHEET.txt"); + FILE* f = fopen_boost (cover, "w"); + if (!f) { + throw OpenFileError (cover, errno, false); + } + + string text = Config::instance()->cover_sheet (); + boost::algorithm::replace_all (text, "$CPL_NAME", _film->name()); + boost::algorithm::replace_all (text, "$TYPE", _film->dcp_content_type()->pretty_name()); + boost::algorithm::replace_all (text, "$CONTAINER", _film->container()->nickname()); + + pair ch = audio_channel_types (_film->mapped_audio_channels(), _film->audio_channels()); + string description = String::compose("%1.%2", ch.first, ch.second); + + if (description == "0.0") { + description = _("None"); + } else if (description == "1.0") { + description = _("Mono"); + } else if (description == "2.0") { + description = _("Stereo"); + } + boost::algorithm::replace_all (text, "$AUDIO", description); + + int h, m, s, fr; + _film->length().split (_film->video_frame_rate(), h, m, s, fr); + string length; + if (h == 0 && m == 0) { + length = String::compose("%1s", s); + } else if (h == 0 && m > 0) { + length = String::compose("%1m%2s", m, s); + } else if (h > 0 && m > 0) { + length = String::compose("%1h%2m%3s", h, m, s); + } + + boost::algorithm::replace_all (text, "$LENGTH", length); + + fwrite (text.c_str(), 1, text.length(), f); + fclose (f); } /** @param frame Frame index within the whole DCP. diff --git a/src/lib/writer.h b/src/lib/writer.h index 1e4d3b6a3..cb1bdc5cc 100644 --- a/src/lib/writer.h +++ b/src/lib/writer.h @@ -117,6 +117,7 @@ private: bool have_sequenced_image_at_queue_head (); size_t video_reel (int frame) const; void set_digest_progress (Job* job, float progress); + void write_cover_sheet (); /** our Film */ boost::shared_ptr _film; diff --git a/src/wx/config_dialog.cc b/src/wx/config_dialog.cc index 570d5e448..49a8a6849 100644 --- a/src/wx/config_dialog.cc +++ b/src/wx/config_dialog.cc @@ -1482,6 +1482,71 @@ private: wxButton* _reset_kdm_email; }; +class CoverSheetPage : public StandardPage +{ +public: + + CoverSheetPage (wxSize panel_size, int border) +#ifdef DCPOMATIC_OSX + /* We have to force both width and height of this one */ + : StandardPage (wxSize (480, 128), border) +#else + : StandardPage (panel_size, border) +#endif + {} + + wxString GetName () const + { + return _("Cover Sheet"); + } + +#ifdef DCPOMATIC_OSX + wxBitmap GetLargeIcon () const + { + return wxBitmap ("cover_sheet", wxBITMAP_TYPE_PNG_RESOURCE); + } +#endif + +private: + void setup () + { + _cover_sheet = new wxTextCtrl (_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (-1, 200), wxTE_MULTILINE); + _panel->GetSizer()->Add (_cover_sheet, 0, wxEXPAND | wxALL, _border); + + _reset_cover_sheet = new wxButton (_panel, wxID_ANY, _("Reset to default text")); + _panel->GetSizer()->Add (_reset_cover_sheet, 0, wxEXPAND | wxALL, _border); + + _cover_sheet->Bind (wxEVT_TEXT, boost::bind (&CoverSheetPage::cover_sheet_changed, this)); + _reset_cover_sheet->Bind (wxEVT_BUTTON, boost::bind (&CoverSheetPage::reset_cover_sheet, this)); + } + + void config_changed () + { + checked_set (_cover_sheet, Config::instance()->cover_sheet ()); + } + + void cover_sheet_changed () + { + if (_cover_sheet->GetValue().IsEmpty ()) { + /* Sometimes we get sent an erroneous notification that the cover sheet + is empty; I don't know why. + */ + return; + } + Config::instance()->set_cover_sheet (wx_to_std (_cover_sheet->GetValue ())); + } + + void reset_cover_sheet () + { + Config::instance()->reset_cover_sheet (); + checked_set (_cover_sheet, Config::instance()->cover_sheet ()); + } + + wxTextCtrl* _cover_sheet; + wxButton* _reset_cover_sheet; +}; + + /** @class AdvancedPage * @brief Advanced page of the preferences dialog. */ @@ -1730,6 +1795,7 @@ create_config_dialog () e->AddPage (new KeysPage (ps, border)); e->AddPage (new TMSPage (ps, border)); e->AddPage (new KDMEmailPage (ps, border)); + e->AddPage (new CoverSheetPage (ps, border)); e->AddPage (new AdvancedPage (ps, border)); return e; }