summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2023-11-11 21:03:39 +0100
committerCarl Hetherington <cth@carlh.net>2023-11-11 21:03:39 +0100
commit00cc999455e060630a5914e7a70489ff98219b49 (patch)
tree7b67944a35939205c29823aa33cbe594d5cf8834
parenta22f1bda1083345a649ca9c4d893cae79b141191 (diff)
Move add_files_override_path to film_util
-rw-r--r--src/lib/film_util.cc13
-rw-r--r--src/lib/film_util.h1
-rw-r--r--src/wx/content_panel.cc18
-rw-r--r--src/wx/content_panel.h1
4 files changed, 18 insertions, 15 deletions
diff --git a/src/lib/film_util.cc b/src/lib/film_util.cc
index 34f48d5a3..a12a3ae89 100644
--- a/src/lib/film_util.cc
+++ b/src/lib/film_util.cc
@@ -19,11 +19,13 @@
*/
+#include "config.h"
#include "film.h"
#include "film_util.h"
using std::shared_ptr;
+using boost::optional;
bool
@@ -32,3 +34,14 @@ channel_is_mapped(shared_ptr<const Film> film, dcp::Channel channel)
auto const mapped = film->mapped_audio_channels();
return std::find(mapped.begin(), mapped.end(), static_cast<int>(channel)) != mapped.end();
}
+
+
+optional<boost::filesystem::path>
+add_files_override_path(shared_ptr<const Film> film)
+{
+ film->directory();
+ return Config::instance()->default_add_file_location() == Config::DefaultAddFileLocation::SAME_AS_PROJECT
+ ? film->directory()->parent_path()
+ : boost::optional<boost::filesystem::path>();
+
+}
diff --git a/src/lib/film_util.h b/src/lib/film_util.h
index f5b91f1f5..3e5f40644 100644
--- a/src/lib/film_util.h
+++ b/src/lib/film_util.h
@@ -26,3 +26,4 @@ class Film;
bool channel_is_mapped(std::shared_ptr<const Film> film, dcp::Channel channel);
+boost::optional<boost::filesystem::path> add_files_override_path(std::shared_ptr<const Film> film);
diff --git a/src/wx/content_panel.cc b/src/wx/content_panel.cc
index 56c1d0524..8a98bc1a4 100644
--- a/src/wx/content_panel.cc
+++ b/src/wx/content_panel.cc
@@ -43,6 +43,7 @@
#include "lib/dcpomatic_log.h"
#include "lib/ffmpeg_content.h"
#include "lib/film.h"
+#include "lib/film_util.h"
#include "lib/image_content.h"
#include "lib/log.h"
#include "lib/playlist.h"
@@ -582,17 +583,6 @@ ContentPanel::check_selection ()
}
-optional<boost::filesystem::path>
-ContentPanel::add_files_override_path() const
-{
- DCPOMATIC_ASSERT(_film->directory());
- return Config::instance()->default_add_file_location() == Config::DefaultAddFileLocation::SAME_AS_PROJECT
- ? _film->directory()->parent_path()
- : boost::optional<boost::filesystem::path>();
-
-}
-
-
void
ContentPanel::add_file_clicked ()
{
@@ -612,7 +602,7 @@ ContentPanel::add_file_clicked ()
wxT("All files|*.*|Subtitle files|*.srt;*.xml|Audio files|*.wav;*.w64;*.flac;*.aif;*.aiff"),
wxFD_MULTIPLE | wxFD_CHANGE_DIR,
"AddFilesPath",
- add_files_override_path()
+ add_files_override_path(_film)
);
if (dialog.show()) {
@@ -624,7 +614,7 @@ ContentPanel::add_file_clicked ()
void
ContentPanel::add_folder_clicked ()
{
- DirDialog dialog(_splitter, _("Choose a folder"), wxDD_DIR_MUST_EXIST, "AddFilesPath", add_files_override_path());
+ DirDialog dialog(_splitter, _("Choose a folder"), wxDD_DIR_MUST_EXIST, "AddFilesPath", add_files_override_path(_film));
if (dialog.show()) {
add_folder(dialog.path());
}
@@ -667,7 +657,7 @@ ContentPanel::add_folder(boost::filesystem::path folder)
void
ContentPanel::add_dcp_clicked ()
{
- DirDialog dialog(_splitter, _("Choose a DCP folder"), wxDD_DIR_MUST_EXIST, "AddFilesPath", add_files_override_path());
+ DirDialog dialog(_splitter, _("Choose a DCP folder"), wxDD_DIR_MUST_EXIST, "AddFilesPath", add_files_override_path(_film));
if (dialog.show()) {
add_dcp(dialog.path());
}
diff --git a/src/wx/content_panel.h b/src/wx/content_panel.h
index 6ba9bb1bb..ca0d49719 100644
--- a/src/wx/content_panel.h
+++ b/src/wx/content_panel.h
@@ -109,7 +109,6 @@ private:
void later_clicked ();
void right_click (wxListEvent &);
void files_dropped (wxDropFilesEvent &);
- boost::optional<boost::filesystem::path> add_files_override_path() const;
void setup ();
void setup_sensitivity ();