# HG changeset patch # User John Donoghue # Date 1397679585 14400 # Node ID 992b6354c8c62fc85adb012a6779c1cce7256a5e # Parent 7cb98e81ecd132899f705034c4d12a696ec83ef9 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. diff -r 7cb98e81ecd1 -r 992b6354c8c6 libgui/qterminal/libqterminal/unix/TerminalView.cpp --- a/libgui/qterminal/libqterminal/unix/TerminalView.cpp Mon Apr 07 13:31:33 2014 -0400 +++ b/libgui/qterminal/libqterminal/unix/TerminalView.cpp Wed Apr 16 16:19:45 2014 -0400 @@ -2620,6 +2620,17 @@ // KUrl::List urls = KUrl::List::fromMimeData(event->mimeData()); QString dropText; + + if (event->mimeData ()->hasUrls ()) + { + foreach (QUrl url, event->mimeData ()->urls ()) + { + if(dropText.length () > 0) + dropText += "\n"; + dropText += url.toLocalFile (); + } + } + /* if (!urls.isEmpty()) { for ( int i = 0 ; i < urls.count() ; i++ ) diff -r 7cb98e81ecd1 -r 992b6354c8c6 libgui/src/m-editor/file-editor.cc --- 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 diff -r 7cb98e81ecd1 -r 992b6354c8c6 libgui/src/m-editor/file-editor.h --- a/libgui/src/m-editor/file-editor.h Mon Apr 07 13:31:33 2014 -0400 +++ b/libgui/src/m-editor/file-editor.h Wed Apr 16 16:19:45 2014 -0400 @@ -30,6 +30,9 @@ #include #include +#include +#include + #include #include "file-editor-interface.h" @@ -205,6 +208,11 @@ void zoom_out (bool); void zoom_normal (bool); +protected: + + void dragEnterEvent(QDragEnterEvent *event); + void dropEvent(QDropEvent *event); + private: bool is_editor_console_tabbed ();