X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fwx%2Fcontent_panel.cc;h=c18520c30b4b677453372736dd78e40f0ba70d70;hb=b7e65adf286ce20918797a06a910ededf8f07b7b;hp=bf02e39305146fe3d650f2fd9bd2a556add4c789;hpb=5799460dc38bafa1da1ce9f7bf43621d3fadf442;p=dcpomatic.git diff --git a/src/wx/content_panel.cc b/src/wx/content_panel.cc index bf02e3930..c18520c30 100644 --- a/src/wx/content_panel.cc +++ b/src/wx/content_panel.cc @@ -43,6 +43,7 @@ #include "lib/image_content.h" #include "lib/log.h" #include "lib/playlist.h" +#include "lib/scope_guard.h" #include "lib/string_text_file.h" #include "lib/string_text_file_content.h" #include "lib/text_content.h" @@ -578,7 +579,7 @@ ContentPanel::add_file_clicked () return; } - auto path = Config::instance()->add_files_path(); + 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. @@ -608,7 +609,7 @@ ContentPanel::add_file_clicked () add_files (path_list); if (!path_list.empty()) { - Config::instance()->set_add_files_path(path_list[0].parent_path()); + Config::instance()->set_initial_path("AddFilesPath", path_list[0].parent_path()); } d->Destroy (); @@ -618,15 +619,16 @@ ContentPanel::add_file_clicked () void ContentPanel::add_folder_clicked () { - auto d = new wxDirDialog (_splitter, _("Choose a folder"), wxT(""), wxDD_DIR_MUST_EXIST); - int r = d->ShowModal (); - boost::filesystem::path const path (wx_to_std (d->GetPath ())); - d->Destroy (); + auto const initial_path = Config::instance()->initial_path("AddFilesPath"); + auto d = new wxDirDialog(_splitter, _("Choose a folder"), std_to_wx(initial_path ? initial_path->string() : home_directory().string()), wxDD_DIR_MUST_EXIST); + ScopeGuard sg = [d]() { d->Destroy(); }; + int r = d->ShowModal (); if (r != wxID_OK) { return; } + boost::filesystem::path const path(wx_to_std(d->GetPath())); add_folder(path); } @@ -652,15 +654,12 @@ ContentPanel::add_folder(boost::filesystem::path folder) auto ic = dynamic_pointer_cast (i); if (ic) { auto e = new ImageSequenceDialog (_splitter); - int const r = e->ShowModal(); - auto const frame_rate = e->frame_rate (); - e->Destroy (); + ScopeGuard sg = [e]() { e->Destroy(); }; - if (r != wxID_OK) { + if (e->ShowModal() != wxID_OK) { return; } - - ic->set_video_frame_rate(_film, frame_rate); + ic->set_video_frame_rate(_film, e->frame_rate()); } _film->examine_and_add_content (i); @@ -671,15 +670,16 @@ ContentPanel::add_folder(boost::filesystem::path folder) void ContentPanel::add_dcp_clicked () { - auto d = new wxDirDialog (_splitter, _("Choose a DCP folder"), wxT(""), wxDD_DIR_MUST_EXIST); - int r = d->ShowModal (); - boost::filesystem::path const path (wx_to_std (d->GetPath ())); - d->Destroy (); + auto const initial_path = Config::instance()->initial_path("AddFilesPath"); + auto d = new wxDirDialog(_splitter, _("Choose a DCP folder"), std_to_wx(initial_path ? initial_path->string() : home_directory().string()), wxDD_DIR_MUST_EXIST); + ScopeGuard sg = [d]() { d->Destroy(); }; + int r = d->ShowModal (); if (r != wxID_OK) { return; } + boost::filesystem::path const path(wx_to_std(d->GetPath())); add_dcp(path); }