Mercurial > hg > octave-nkf
changeset 18806: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 | 7cb98e81ecd1 |
children | 41489b96ebca |
files | libgui/qterminal/libqterminal/unix/TerminalView.cpp libgui/src/m-editor/file-editor.cc libgui/src/m-editor/file-editor.h |
diffstat | 3 files changed, 42 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/qterminal/libqterminal/unix/TerminalView.cpp +++ b/libgui/qterminal/libqterminal/unix/TerminalView.cpp @@ -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++ )
--- a/libgui/src/m-editor/file-editor.cc +++ b/libgui/src/m-editor/file-editor.cc @@ -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
--- a/libgui/src/m-editor/file-editor.h +++ b/libgui/src/m-editor/file-editor.h @@ -30,6 +30,9 @@ #include <QCloseEvent> #include <QTabWidget> +#include <QDragEnterEvent> +#include <QDropEvent> + #include <map> #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 ();