]> git.sesse.net Git - vlc/commitdiff
qt4: allow dnd to file-input on convert-dialog
authorIlkka Ollakka <ileoo@videolan.org>
Mon, 14 Jun 2010 08:26:18 +0000 (11:26 +0300)
committerIlkka Ollakka <ileoo@videolan.org>
Mon, 14 Jun 2010 08:26:18 +0000 (11:26 +0300)
modules/gui/qt4/components/open_panels.cpp
modules/gui/qt4/components/open_panels.hpp

index 148a7b1102e96a800c4cb91390ddd50a1495713b..61c397ffe75236d161d0b44c8de0a6d6ca0761de 100644 (file)
@@ -47,6 +47,7 @@
 #include <QScrollArea>
 #include <QUrl>
 #include <QStringListModel>
+#include <QDropEvent>
 
 
 #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) ;
index 4d2d05b0a24fa16e7562ab0223f25a3e4157eddc..2999b5b518ba9d51ff76bb02b193eef8e8247faf 100644 (file)
@@ -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;