From: Ilkka Ollakka Date: Mon, 14 Jun 2010 08:26:18 +0000 (+0300) Subject: qt4: allow dnd to file-input on convert-dialog X-Git-Tag: 1.2.0-pre1~6195 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=b68fb123875dbc0038bb551769f1ce1a1f68b8a7;p=vlc qt4: allow dnd to file-input on convert-dialog --- diff --git a/modules/gui/qt4/components/open_panels.cpp b/modules/gui/qt4/components/open_panels.cpp index 148a7b1102..61c397ffe7 100644 --- a/modules/gui/qt4/components/open_panels.cpp +++ b/modules/gui/qt4/components/open_panels.cpp @@ -47,6 +47,7 @@ #include #include #include +#include #define I_DEVICE_TOOLTIP \ @@ -65,6 +66,8 @@ FileOpenPanel::FileOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) : /* Classic UI Setup */ ui.setupUi( this ); + setAcceptDrops( true ); + /* Set Filters for file selection */ /* QString fileTypes = ""; ADD_FILTER_MEDIA( fileTypes ); @@ -166,6 +169,45 @@ FileOpenPanel::~FileOpenPanel() getSettings()->setValue( "file-dialog-state", dialogBox->saveState() ); } +void FileOpenPanel::dragEnterEvent( QDragEnterEvent *event ) +{ + event->acceptProposedAction(); +} + +void FileOpenPanel::dragMoveEvent( QDragMoveEvent *event ) +{ + event->acceptProposedAction(); +} + +void FileOpenPanel::dragLeaveEvent( QDragLeaveEvent *event ) +{ + event->accept(); +} + +void FileOpenPanel::dropEvent( QDropEvent *event ) +{ + if( event->possibleActions() & Qt::CopyAction ) + event->setDropAction( Qt::CopyAction ); + else + return; + + const QMimeData *mimeData = event->mimeData(); + foreach( const QUrl &url, mimeData->urls() ) + { + if( url.isValid() ) + { + QListWidgetItem *item = new QListWidgetItem( + toNativeSeparators( url.toLocalFile() ), + ui.fileListWidg ); + item->setFlags( Qt::ItemIsEditable | Qt::ItemIsEnabled ); + ui.fileListWidg->addItem( item ); + } + } + updateMRL(); + updateButtons(); + event->accept(); +} + void FileOpenPanel::browseFile() { QStringList files = QFileDialog::getOpenFileNames( this, qtr( "Select one or multiple files" ), p_intf->p_sys->filepath) ; diff --git a/modules/gui/qt4/components/open_panels.hpp b/modules/gui/qt4/components/open_panels.hpp index 4d2d05b0a2..2999b5b518 100644 --- a/modules/gui/qt4/components/open_panels.hpp +++ b/modules/gui/qt4/components/open_panels.hpp @@ -62,6 +62,7 @@ class QWidget; class QLineEdit; class QString; class QStringListModel; +class QEvent; class OpenPanel: public QWidget { @@ -114,6 +115,10 @@ protected: } return false; } + virtual void dropEvent( QDropEvent *); + virtual void dragEnterEvent( QDragEnterEvent * ); + virtual void dragMoveEvent( QDragMoveEvent * ); + virtual void dragLeaveEvent( QDragLeaveEvent * ); private: Ui::OpenFile ui; FileOpenBox *dialogBox;