diff options
| author | Carl Hetherington <cth@carlh.net> | 2022-12-25 22:46:07 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2022-12-25 22:46:07 +0100 |
| commit | 18bb22e82336c76351eb0f8b57a0b5a1cffb2e5c (patch) | |
| tree | 096fdafaf414140a8e143e9cd6a78ef8b3b065e4 | |
| parent | f3617efde1751ac9e55f692369dc4ba3c6350ca8 (diff) | |
Support drag and drop of film directories onto the batch converter (#340).
| -rw-r--r-- | src/tools/dcpomatic_batch.cc | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/tools/dcpomatic_batch.cc b/src/tools/dcpomatic_batch.cc index 8bb36476d..a2db604df 100644 --- a/src/tools/dcpomatic_batch.cc +++ b/src/tools/dcpomatic_batch.cc @@ -40,6 +40,7 @@ LIBDCP_DISABLE_WARNINGS #include <wx/aboutdlg.h> #include <wx/cmdline.h> +#include <wx/dnd.h> #include <wx/preferences.h> #include <wx/splash.h> #include <wx/stdpaths.h> @@ -115,6 +116,31 @@ public: PAUSE }; + class DCPDropTarget : public wxFileDropTarget + { + public: + DCPDropTarget(DOMFrame* owner) + : _frame(owner) + {} + + bool OnDropFiles(wxCoord, wxCoord, wxArrayString const& filenames) override + { + if (filenames.GetCount() == 1) { + /* Try to load a directory */ + auto path = boost::filesystem::path(wx_to_std(filenames[0])); + if (boost::filesystem::is_directory(path)) { + _frame->start_job(wx_to_std(filenames[0])); + return true; + } + } + + return false; + } + + private: + DOMFrame* _frame; + }; + explicit DOMFrame (wxString const & title) : wxFrame (nullptr, -1, title) , _sizer (new wxBoxSizer(wxVERTICAL)) @@ -156,6 +182,8 @@ public: Bind (wxEVT_CLOSE_WINDOW, boost::bind(&DOMFrame::close, this, _1)); Bind (wxEVT_SIZE, boost::bind(&DOMFrame::sized, this, _1)); + + SetDropTarget(new DCPDropTarget(this)); } void tool_clicked(wxCommandEvent& ev) |
