summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2022-10-05 00:26:39 +0200
committerCarl Hetherington <cth@carlh.net>2022-10-05 00:26:39 +0200
commit6f23f3ff80fbd73cdaf183ce8bbdeeea0007ad6b (patch)
tree81ca0b9667c8ea7d29af5ea54420ed10f2f23ac7
parentffc2fac596d1c883fb0a85bece42f5d46f16adf1 (diff)
Support drag-and-drop of DCPs onto the player (#1220).
-rw-r--r--src/tools/dcpomatic_player.cc42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/tools/dcpomatic_player.cc b/src/tools/dcpomatic_player.cc
index fb5821a9f..d97bdd168 100644
--- a/src/tools/dcpomatic_player.cc
+++ b/src/tools/dcpomatic_player.cc
@@ -71,6 +71,7 @@
LIBDCP_DISABLE_WARNINGS
#include <wx/cmdline.h>
#include <wx/display.h>
+#include <wx/dnd.h>
#include <wx/preferences.h>
#include <wx/progdlg.h>
#include <wx/splash.h>
@@ -148,9 +149,48 @@ enum {
ID_go_to_end
};
+
class DOMFrame : public wxFrame
{
public:
+
+ 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->load_dcp(wx_to_std(filenames[0]));
+ return true;
+ }
+ }
+
+ if (filenames.GetCount() >= 1) {
+ /* Try to load the parent if we drop some files, one if which is an asset map */
+ for (size_t i = 0; i < filenames.GetCount(); ++i) {
+ auto path = boost::filesystem::path(wx_to_std(filenames[i]));
+ if (path.filename() == "ASSETMAP" || path.filename() == "ASSETMAP.xml") {
+ _frame->load_dcp(path.parent_path());
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ private:
+ DOMFrame* _frame;
+ };
+
+
DOMFrame ()
: wxFrame (nullptr, -1, _("DCP-o-matic Player"))
, _mode (Config::instance()->player_mode())
@@ -260,6 +300,8 @@ public:
setup_screen ();
_stress.LoadDCP.connect (boost::bind(&DOMFrame::load_dcp, this, _1));
+
+ SetDropTarget(new DCPDropTarget(this));
}
~DOMFrame ()