summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2023-01-13 13:57:52 +0100
committerCarl Hetherington <cth@carlh.net>2023-01-14 00:42:39 +0100
commit940812b93bade4ac8fd41ee4fb29f3f799815b83 (patch)
treecde1426c75cb0c07788da9dfdf1859185a02d636
parentb7e65adf286ce20918797a06a910ededf8f07b7b (diff)
Use FileDialog for adding content files.
-rw-r--r--src/wx/content_panel.cc33
1 files changed, 8 insertions, 25 deletions
diff --git a/src/wx/content_panel.cc b/src/wx/content_panel.cc
index c18520c30..5bc006e12 100644
--- a/src/wx/content_panel.cc
+++ b/src/wx/content_panel.cc
@@ -22,6 +22,7 @@
#include "audio_panel.h"
#include "content_panel.h"
#include "dcpomatic_button.h"
+#include "file_dialog.h"
#include "film_viewer.h"
#include "image_sequence_dialog.h"
#include "text_panel.h"
@@ -579,40 +580,22 @@ ContentPanel::add_file_clicked ()
return;
}
- auto path = Config::instance()->initial_path("AddFilesPath");
-
/* The wxFD_CHANGE_DIR here prevents a `could not set working directory' error 123 on Windows when using
non-Latin filenames or paths.
*/
- auto d = new wxFileDialog (
+ auto dialog = new FileDialog(
_splitter,
_("Choose a file or files"),
- std_to_wx(path ? path->string() : home_directory().string()),
- wxT (""),
- wxT ("All files|*.*|Subtitle files|*.srt;*.xml|Audio files|*.wav;*.w64;*.flac;*.aif;*.aiff"),
- wxFD_MULTIPLE | wxFD_CHANGE_DIR
+ wxT("All files|*.*|Subtitle files|*.srt;*.xml|Audio files|*.wav;*.w64;*.flac;*.aif;*.aiff"),
+ wxFD_MULTIPLE | wxFD_CHANGE_DIR,
+ "AddFilesPath"
);
- int const r = d->ShowModal ();
+ ScopeGuard sg = [dialog]() { dialog->Destroy(); };
- if (r != wxID_OK) {
- d->Destroy ();
- return;
+ if (dialog->show()) {
+ add_files(dialog->paths());
}
-
- wxArrayString paths;
- d->GetPaths (paths);
- vector<boost::filesystem::path> path_list;
- for (unsigned int i = 0; i < paths.GetCount(); ++i) {
- path_list.push_back (wx_to_std(paths[i]));
- }
- add_files (path_list);
-
- if (!path_list.empty()) {
- Config::instance()->set_initial_path("AddFilesPath", path_list[0].parent_path());
- }
-
- d->Destroy ();
}