Add drag and drop support

This commit is contained in:
2014-02-03 23:59:53 +00:00
parent ab0637a889
commit 95c72d10e3
3 changed files with 51 additions and 1 deletions
-1
View File
@@ -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
+45
View File
@@ -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("<drop content>"));
setBackgroundRole( QPalette::Highlight );
event->acceptProposedAction();
}
void plaYUVerApp::dropEvent( QDropEvent *event )
{
const QMimeData *mimeData = event->mimeData();
QList<QUrl> 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" );
+6
View File
@@ -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 );