Add drag and drop support
This commit is contained in:
1 parent
ab0637a889
commit
95c72d10e3
3 files changed
+51
-1
No files matched your search
@@ -34,7 +34,6 @@ SubWindowHandle::SubWindowHandle( QWidget * parent ) :
|
|||||||
setParent( parent );
|
setParent( parent );
|
||||||
|
|
||||||
setAttribute( Qt::WA_DeleteOnClose );
|
setAttribute( Qt::WA_DeleteOnClose );
|
||||||
setMinimumSize( 500, 500 );
|
|
||||||
setBackgroundRole( QPalette::Light );
|
setBackgroundRole( QPalette::Light );
|
||||||
|
|
||||||
// Create a new scroll area inside the sub-window
|
// Create a new scroll area inside the sub-window
|
||||||
|
|||||||
@@ -64,6 +64,9 @@ plaYUVerApp::plaYUVerApp()
|
|||||||
|
|
||||||
playingTimer = new QTimer( this );
|
playingTimer = new QTimer( this );
|
||||||
|
|
||||||
|
setAcceptDrops( true );
|
||||||
|
mdiArea->setAcceptDrops( true );
|
||||||
|
|
||||||
connect( playingTimer, SIGNAL( timeout() ), this, SLOT( playEvent() ) );
|
connect( playingTimer, SIGNAL( timeout() ), this, SLOT( playEvent() ) );
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -462,6 +465,48 @@ Void plaYUVerApp::createStatusBar()
|
|||||||
statusBar()->showMessage( tr( "Ready" ) );
|
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()
|
Void plaYUVerApp::readSettings()
|
||||||
{
|
{
|
||||||
QSettings settings( "IT", "YUV Player" );
|
QSettings settings( "IT", "YUV Player" );
|
||||||
|
|||||||
@@ -74,6 +74,12 @@ private slots:
|
|||||||
|
|
||||||
void updateWindowMenu();
|
void updateWindowMenu();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Drag and drop functions
|
||||||
|
*/
|
||||||
|
void dragEnterEvent(QDragEnterEvent *event);
|
||||||
|
void dropEvent(QDropEvent *event);
|
||||||
|
|
||||||
SubWindowHandle *createImageInterface();
|
SubWindowHandle *createImageInterface();
|
||||||
void addImageInterface( SubWindowHandle *child );
|
void addImageInterface( SubWindowHandle *child );
|
||||||
void setActiveImageInterface( QWidget *window );
|
void setActiveImageInterface( QWidget *window );
|
||||||
|
|||||||
Reference in new issue
Block a user