Commit b68fb123 authored by Ilkka Ollakka's avatar Ilkka Ollakka

qt4: allow dnd to file-input on convert-dialog

parent 2fddd625
......@@ -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) ;
......
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment