Allow optional override of the initial path taken from the key.
authorCarl Hetherington <cth@carlh.net>
Fri, 13 Jan 2023 19:39:45 +0000 (20:39 +0100)
committerCarl Hetherington <cth@carlh.net>
Fri, 13 Jan 2023 23:42:39 +0000 (00:42 +0100)
src/wx/dir_dialog.cc
src/wx/dir_dialog.h
src/wx/file_dialog.cc
src/wx/file_dialog.h

index ec178de55361de1ab0f7a5656960d7a454f6a4bd..2c25cb6e8f5f057b904d1380d712624dec9c8a40 100644 (file)
 
 
 using std::vector;
+using boost::optional;
 
 
 DirDialog::DirDialog(
        wxWindow* parent,
        wxString title,
        long style,
-       std::string initial_path_key
+       std::string initial_path_key,
+       optional<boost::filesystem::path> override_path
        )
        : wxDirDialog(
                parent,
                title,
-               std_to_wx(Config::instance()->initial_path(initial_path_key).get_value_or(home_directory()).string()),
+               std_to_wx(
+                       override_path.get_value_or(
+                               Config::instance()->initial_path(initial_path_key).get_value_or(home_directory())
+                               ).string()),
                style
                )
        , _initial_path_key(initial_path_key)
index f733f8327f622ac7cbdd313687f7737eeea77b9b..c3b470a07f1e96ead5f9427d68265ea0297e1c84 100644 (file)
@@ -24,6 +24,7 @@ LIBDCP_DISABLE_WARNINGS
 #include <wx/wx.h>
 LIBDCP_ENABLE_WARNINGS
 #include <boost/filesystem.hpp>
+#include <boost/optional.hpp>
 #include <vector>
 
 
@@ -34,7 +35,8 @@ public:
                wxWindow* parent,
                wxString title,
                long style,
-               std::string initial_path_key
+               std::string initial_path_key,
+               boost::optional<boost::filesystem::path> override_path = boost::optional<boost::filesystem::path>()
                );
 
        /** @return true if OK was clicked */
index 7aee394937aa59c411949cf52991e8022c961597..b65077784747ca57f90404a9e87cf3d9cc8f186b 100644 (file)
@@ -28,6 +28,7 @@
 
 
 using std::vector;
+using boost::optional;
 
 
 FileDialog::FileDialog(
@@ -35,12 +36,16 @@ FileDialog::FileDialog(
        wxString title,
        wxString allowed,
        long style,
-       std::string initial_path_key
+       std::string initial_path_key,
+       optional<boost::filesystem::path> override_path
        )
        : wxFileDialog(
                parent,
                title,
-               std_to_wx(Config::instance()->initial_path(initial_path_key).get_value_or(home_directory()).string()),
+               std_to_wx(
+                       override_path.get_value_or(
+                               Config::instance()->initial_path(initial_path_key).get_value_or(home_directory())
+                               ).string()),
                wxEmptyString,
                allowed,
                style
index f4a7ad81edc51810df599ce2d5f9eaceb2875a1c..cc6d720c1e388ccedaccc0f40360d9f5bba2ed6d 100644 (file)
@@ -24,6 +24,7 @@ LIBDCP_DISABLE_WARNINGS
 #include <wx/wx.h>
 LIBDCP_ENABLE_WARNINGS
 #include <boost/filesystem.hpp>
+#include <boost/optional.hpp>
 #include <vector>
 
 
@@ -35,7 +36,8 @@ public:
                wxString title,
                wxString allowed,
                long style,
-               std::string initial_path_key
+               std::string initial_path_key,
+               boost::optional<boost::filesystem::path> override_path = boost::optional<boost::filesystem::path>()
                );
 
        /** @return true if OK was clicked */