Move add_files_override_path to film_util
authorCarl Hetherington <cth@carlh.net>
Sat, 11 Nov 2023 20:03:39 +0000 (21:03 +0100)
committerCarl Hetherington <cth@carlh.net>
Sat, 11 Nov 2023 20:03:39 +0000 (21:03 +0100)
src/lib/film_util.cc
src/lib/film_util.h
src/wx/content_panel.cc
src/wx/content_panel.h

index 34f48d5a3272923595d2e38059d703c93e14561d..a12a3ae897973217c10ef35053cf20cef79aa6f8 100644 (file)
 */
 
 
+#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>();
+
+}
index f5b91f1f57c1368223f043c25d5d949e30ec3bdc..3e5f406446caadd374f224e6599e85ac7a04c62a 100644 (file)
@@ -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);
index 56c1d0524bd4a2053eaea192be18221e7935daaf..8a98bc1a43d706ee78336f1c61a8171ec9629d7f 100644 (file)
@@ -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());
        }
index 6ba9bb1bb00c73a3f853902ab41140ab76bdb6b5..ca0d4971946f779336d28da953da681ddfd2b222 100644 (file)
@@ -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 ();