Take account of changes to default directory for new DCPs (#2058).
authorCarl Hetherington <cth@carlh.net>
Wed, 7 Jul 2021 22:37:33 +0000 (00:37 +0200)
committerCarl Hetherington <cth@carlh.net>
Wed, 7 Jul 2021 22:37:33 +0000 (00:37 +0200)
Instead of always using the last directory in the new film dialog,
only use it when it was explicitly changed by the user.

src/wx/film_name_location_dialog.cc
src/wx/film_name_location_dialog.h

index e0e407c..516ed86 100644 (file)
@@ -48,15 +48,14 @@ FilmNameLocationDialog::FilmNameLocationDialog (wxWindow* parent, wxString title
 
 #ifdef DCPOMATIC_USE_OWN_PICKER
        _folder = new DirPickerCtrl (this);
+       _folder->Changed.connect (bind(&FilmNameLocationDialog::folder_changed, this));
 #else
        _folder = new wxDirPickerCtrl (this, wxID_ANY, wxEmptyString, wxDirSelectorPromptStr, wxDefaultPosition, wxSize (300, -1));
+       _folder->Bind (wxEVT_DIRPICKER_CHANGED, bind(&FilmNameLocationDialog::folder_changed, this));
 #endif
 
-       if (!_directory) {
-               _directory = Config::instance()->default_directory_or(wx_to_std(wxStandardPaths::Get().GetDocumentsDir()));
-       }
-
-       _folder->SetPath (std_to_wx(_directory.get().string()));
+       auto dir = _directory.get_value_or(Config::instance()->default_directory_or(wx_to_std(wxStandardPaths::Get().GetDocumentsDir())));
+       _folder->SetPath (std_to_wx(dir.string()));
        add (_folder);
 
        if (offer_templates) {
@@ -102,7 +101,8 @@ FilmNameLocationDialog::use_template_clicked ()
 }
 
 
-FilmNameLocationDialog::~FilmNameLocationDialog ()
+void
+FilmNameLocationDialog::folder_changed ()
 {
        _directory = wx_to_std (_folder->GetPath());
 }
index 09b426e..29fcd33 100644 (file)
@@ -35,7 +35,6 @@ class FilmNameLocationDialog : public TableDialog
 {
 public:
        FilmNameLocationDialog (wxWindow *, wxString title, bool offer_templates);
-       ~FilmNameLocationDialog ();
 
        boost::filesystem::path path () const;
        bool check_path ();
@@ -44,6 +43,7 @@ public:
 private:
        void use_template_clicked ();
        void setup_sensitivity ();
+       void folder_changed ();
 
        wxTextCtrl* _name;
 #ifdef DCPOMATIC_USE_OWN_PICKER