diff --git a/source/SubWindowHandle.cpp b/source/SubWindowHandle.cpp index 0ee64c3..29ef138 100644 --- a/source/SubWindowHandle.cpp +++ b/source/SubWindowHandle.cpp @@ -34,7 +34,6 @@ SubWindowHandle::SubWindowHandle( QWidget * parent ) : setParent( parent ); setAttribute( Qt::WA_DeleteOnClose ); - setMinimumSize( 500, 500 ); setBackgroundRole( QPalette::Light ); // Create a new scroll area inside the sub-window diff --git a/source/plaYUVerApp.cpp b/source/plaYUVerApp.cpp index 154ebf3..e0b6e0c 100644 --- a/source/plaYUVerApp.cpp +++ b/source/plaYUVerApp.cpp @@ -64,6 +64,9 @@ plaYUVerApp::plaYUVerApp() playingTimer = new QTimer( this ); + setAcceptDrops( true ); + mdiArea->setAcceptDrops( true ); + connect( playingTimer, SIGNAL( timeout() ), this, SLOT( playEvent() ) ); } @@ -462,6 +465,48 @@ Void plaYUVerApp::createStatusBar() statusBar()->showMessage( tr( "Ready" ) ); } +/* + * Drag and drop functions + */ +void plaYUVerApp::dragEnterEvent( QDragEnterEvent *event ) +{ + //setText(tr("")); + setBackgroundRole( QPalette::Highlight ); + + event->acceptProposedAction(); +} + +void plaYUVerApp::dropEvent( QDropEvent *event ) +{ + + const QMimeData *mimeData = event->mimeData(); + + QList urlList = mimeData->urls(); + + if( urlList.size() == 1 ) + { + QString fileName = urlList.at( 0 ).toLocalFile(); + + m_cLastOpenPath = QFileInfo( fileName ).path(); + + QMdiSubWindow *existing = findImageInterface( fileName ); + if( !existing ) + { + SubWindowHandle *interfaceChild = new SubWindowHandle( this ); //createImageInterface(); + if( interfaceChild->loadFile( fileName ) ) + { + addImageInterface( interfaceChild ); + statusBar()->showMessage( tr( "File loaded" ), 2000 ); + interfaceChild->show(); + } + else + { + interfaceChild->close(); + } + } + } +} + Void plaYUVerApp::readSettings() { QSettings settings( "IT", "YUV Player" ); diff --git a/source/plaYUVerApp.h b/source/plaYUVerApp.h index a45d687..e054d17 100644 --- a/source/plaYUVerApp.h +++ b/source/plaYUVerApp.h @@ -74,6 +74,12 @@ private slots: void updateWindowMenu(); + /* + * Drag and drop functions + */ + void dragEnterEvent(QDragEnterEvent *event); + void dropEvent(QDropEvent *event); + SubWindowHandle *createImageInterface(); void addImageInterface( SubWindowHandle *child ); void setActiveImageInterface( QWidget *window );