diff libgui/src/m-editor/file-editor.cc @ 18685:992b6354c8c6 gui-release

GUI: implement file drag and drop to command and edit window (Bug #41443) * libgui/src/m-editor/file-editor.h, ibgui/src/m-editor/file-editor.cpp (file_editor::file_editor): call setAcceptDrops. (file_editor::dragEnterEvent): New function. (file_editor::dropEvent): New function. * libgui/qterminal/libqterminal/unix/TerminalView.cpp (TerminalView::dropEvent): get URL names on drop event.
author John Donoghue
date Wed, 16 Apr 2014 16:19:45 -0400
parents a827fc5fe59d
children 1b289f45187f
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor.cc	Mon Apr 07 13:31:33 2014 -0400
+++ b/libgui/src/m-editor/file-editor.cc	Wed Apr 16 16:19:45 2014 -0400
@@ -56,6 +56,8 @@
   construct ();
 
   setVisible (false);
+
+  setAcceptDrops(true);
 }
 
 file_editor::~file_editor (void)
@@ -1755,4 +1757,25 @@
       focus ();
   }
 
+void 
+file_editor::dragEnterEvent (QDragEnterEvent *event)
+  {
+    if (event->mimeData ()->hasUrls ())
+      {
+        event->acceptProposedAction();
+      }
+  }
+
+void
+file_editor::dropEvent (QDropEvent *event)
+  {
+    if (event->mimeData ()->hasUrls ())
+      {
+        foreach (QUrl url, event->mimeData ()->urls ())
+        {
+          request_open_file (url.toLocalFile ());
+        }
+      }
+  }
+
 #endif