From a2bf32c1419a56e6aaee7e742961b9f471a9dd79 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 13 Jan 2023 20:39:45 +0100 Subject: [PATCH] Allow optional override of the initial path taken from the key. --- src/wx/dir_dialog.cc | 9 +++++++-- src/wx/dir_dialog.h | 4 +++- src/wx/file_dialog.cc | 9 +++++++-- src/wx/file_dialog.h | 4 +++- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/wx/dir_dialog.cc b/src/wx/dir_dialog.cc index ec178de55..2c25cb6e8 100644 --- a/src/wx/dir_dialog.cc +++ b/src/wx/dir_dialog.cc @@ -28,18 +28,23 @@ 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 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) diff --git a/src/wx/dir_dialog.h b/src/wx/dir_dialog.h index f733f8327..c3b470a07 100644 --- a/src/wx/dir_dialog.h +++ b/src/wx/dir_dialog.h @@ -24,6 +24,7 @@ LIBDCP_DISABLE_WARNINGS #include LIBDCP_ENABLE_WARNINGS #include +#include #include @@ -34,7 +35,8 @@ public: wxWindow* parent, wxString title, long style, - std::string initial_path_key + std::string initial_path_key, + boost::optional override_path = boost::optional() ); /** @return true if OK was clicked */ diff --git a/src/wx/file_dialog.cc b/src/wx/file_dialog.cc index 7aee39493..b65077784 100644 --- a/src/wx/file_dialog.cc +++ b/src/wx/file_dialog.cc @@ -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 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 diff --git a/src/wx/file_dialog.h b/src/wx/file_dialog.h index f4a7ad81e..cc6d720c1 100644 --- a/src/wx/file_dialog.h +++ b/src/wx/file_dialog.h @@ -24,6 +24,7 @@ LIBDCP_DISABLE_WARNINGS #include LIBDCP_ENABLE_WARNINGS #include +#include #include @@ -35,7 +36,8 @@ public: wxString title, wxString allowed, long style, - std::string initial_path_key + std::string initial_path_key, + boost::optional override_path = boost::optional() ); /** @return true if OK was clicked */ -- 2.30.2