Remember the last directory used when opening DCPs in the player (#1121).
authorCarl Hetherington <cth@carlh.net>
Sat, 2 Sep 2017 12:55:12 +0000 (13:55 +0100)
committerCarl Hetherington <cth@carlh.net>
Sat, 2 Sep 2017 12:55:12 +0000 (13:55 +0100)
ChangeLog
src/lib/config.cc
src/lib/config.h
src/tools/dcpomatic_player.cc

index 0f9dec7b548f63dab3d7b63c7d412decc3ef2502..4e448b689f25b30bb9bf3e8b9f2580c18309ddad 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2017-09-02  Carl Hetherington  <cth@carlh.net>
 
+       * Remember the last directory used when opening DCPs in the player (#1121).
+
        * Build with a version of libopenjpeg derived from 2.2.0.
 
 2017-09-01  Carl Hetherington  <cth@carlh.net>
index f595b960a888556926a3de3d3bc8081296538e62..4f481ef3043d0b31e82e0bcda024c175e8cd02d1 100644 (file)
@@ -354,6 +354,7 @@ try
        if (f.optional_string_child("CoverSheet")) {
                _cover_sheet = f.optional_string_child("CoverSheet").get();
        }
+       _last_player_load_directory = f.optional_string_child("LastPlayerLoadDirectory");
 
        /* Replace any cinemas from config.xml with those from the configured file */
        if (boost::filesystem::exists (_cinemas_file)) {
@@ -631,6 +632,9 @@ Config::write_config () const
        }
        /* [XML] CoverSheet Text of the cover sheet to write when making DCPs */
        root->add_child("CoverSheet")->add_child_text (_cover_sheet);
+       if (_last_player_load_directory) {
+               root->add_child("LastPlayerLoadDirectory")->add_child_text(_last_player_load_directory->string());
+       }
 
        try {
                doc.write_to_file_formatted(config_file().string());
index 0a81dee5132679e9d461d8c8e5b4a4b3510ea6e0..2d45f14f0a89e1392436e02af9930865a3cf013a 100644 (file)
@@ -341,6 +341,10 @@ public:
                return _sound_output;
        }
 
+       boost::optional<boost::filesystem::path> last_player_load_directory () const {
+               return _last_player_load_directory;
+       }
+
        void set_master_encoding_threads (int n) {
                maybe_set (_master_encoding_threads, n);
        }
@@ -567,13 +571,15 @@ public:
                maybe_set (_sound, s, SOUND);
        }
 
-       void set_sound_output (std::string o)
-       {
+       void set_sound_output (std::string o) {
                maybe_set (_sound_output, o, SOUND_OUTPUT);
        }
 
-       void unset_sound_output ()
-       {
+       void set_last_player_load_directory (boost::filesystem::path d) {
+               maybe_set (_last_player_load_directory, d);
+       }
+
+       void unset_sound_output () {
                if (!_sound_output) {
                        return;
                }
@@ -764,6 +770,7 @@ private:
        /** name of a specific sound output stream to use, or empty to use the default */
        boost::optional<std::string> _sound_output;
        std::string _cover_sheet;
+       boost::optional<boost::filesystem::path> _last_player_load_directory;
 
        /** Singleton instance, or 0 */
        static Config* _instance;
index 6753b542325b76930f13c96ef10e8a482d42cdfa..dec1d3f14e6e5d8cde39b45abaffe4b589bab640 100644 (file)
@@ -207,12 +207,12 @@ private:
 
        void file_open ()
        {
-               wxDirDialog* c = new wxDirDialog (
-                       this,
-                       _("Select DCP to open"),
-                       wxStandardPaths::Get().GetDocumentsDir(),
-                       wxDEFAULT_DIALOG_STYLE | wxDD_DIR_MUST_EXIST
-                       );
+               wxString d = wxStandardPaths::Get().GetDocumentsDir();
+               if (Config::instance()->last_player_load_directory()) {
+                       d = std_to_wx (Config::instance()->last_player_load_directory()->string());
+               }
+
+               wxDirDialog* c = new wxDirDialog (this, _("Select DCP to open"), d, wxDEFAULT_DIALOG_STYLE | wxDD_DIR_MUST_EXIST);
 
                int r;
                while (true) {
@@ -225,7 +225,9 @@ private:
                }
 
                if (r == wxID_OK) {
-                       load_dcp (wx_to_std (c->GetPath ()));
+                       boost::filesystem::path const dcp (wx_to_std (c->GetPath ()));
+                       load_dcp (dcp);
+                       Config::instance()->set_last_player_load_directory (dcp.parent_path());
                }
 
                c->Destroy ();