From dd353e14791138fc44b55b6f234567d706d313ff Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 17 Jan 2018 00:03:43 +0000 Subject: Add recent files list to player. --- src/lib/config.cc | 29 ++++++++++++++++++++++++----- src/lib/config.h | 12 ++++++++++++ 2 files changed, 36 insertions(+), 5 deletions(-) (limited to 'src/lib') diff --git a/src/lib/config.cc b/src/lib/config.cc index 9106a9559..e5fd9d17a 100644 --- a/src/lib/config.cc +++ b/src/lib/config.cc @@ -309,11 +309,14 @@ try _win32_console = f.optional_bool_child ("Win32Console").get_value_or (false); #endif - list his = f.node_children ("History"); BOOST_FOREACH (cxml::ConstNodePtr i, f.node_children("History")) { _history.push_back (i->content ()); } + BOOST_FOREACH (cxml::ConstNodePtr i, f.node_children("PlayerHistory")) { + _player_history.push_back (i->content ()); + } + cxml::NodePtr signer = f.optional_node_child ("Signer"); if (signer) { shared_ptr c (new dcp::CertificateChain ()); @@ -632,6 +635,10 @@ Config::write_config () const root->add_child("History")->add_child_text (i.string ()); } + BOOST_FOREACH (boost::filesystem::path i, _player_history) { + root->add_child("PlayerHistory")->add_child_text (i.string ()); + } + /* [XML] DKDMGroup A group of DKDMs, each with a Name attribute, containing other <DKDMGroup> or <DKDM> tags. */ @@ -798,13 +805,25 @@ Config::set_cover_sheet_to_default () void Config::add_to_history (boost::filesystem::path p) +{ + add_to_history_internal (_history, p); +} + +void +Config::add_to_player_history (boost::filesystem::path p) +{ + add_to_history_internal (_player_history, p); +} + +void +Config::add_to_history_internal (vector& h, boost::filesystem::path p) { /* Remove existing instances of this path in the history */ - _history.erase (remove (_history.begin(), _history.end(), p), _history.end ()); + h.erase (remove (h.begin(), h.end(), p), h.end ()); - _history.insert (_history.begin (), p); - if (_history.size() > HISTORY_SIZE) { - _history.pop_back (); + h.insert (h.begin (), p); + if (h.size() > HISTORY_SIZE) { + h.pop_back (); } changed (); diff --git a/src/lib/config.h b/src/lib/config.h index dae1924a8..f32b17106 100644 --- a/src/lib/config.h +++ b/src/lib/config.h @@ -286,6 +286,10 @@ public: return _history; } + std::vector player_history () const { + return _player_history; + } + boost::shared_ptr dkdms () const { return _dkdms; } @@ -639,7 +643,13 @@ public: changed (); } + void clear_player_history () { + _player_history.clear (); + changed (); + } + void add_to_history (boost::filesystem::path p); + void add_to_player_history (boost::filesystem::path p); void set_jump_to_selected (bool j) { maybe_set (_jump_to_selected, j); @@ -695,6 +705,7 @@ private: 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; + void add_to_history_internal (std::vector& h, boost::filesystem::path p); template void maybe_set (T& member, T new_value, Property prop = OTHER) { @@ -789,6 +800,7 @@ private: bool _win32_console; #endif std::vector _history; + std::vector _player_history; boost::shared_ptr _dkdms; boost::filesystem::path _cinemas_file; bool _show_hints_before_make_dcp; -- cgit v1.2.3