From 4fd00c7fb03e35b41644931c5582dcb5f23310ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Mon, 11 Jan 2010 15:27:03 +0000 Subject: [PATCH] Accept drag and drop for filenames git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@8154 383ad7c9-94d9-4d36-a494-682f7c89f535 --- Core/Core.cc | 1 + Core/Core.hh | 2 +- widgets/coreWidget/CoreWidget.hh | 6 +++++- widgets/coreWidget/dragAndDrop.cc | 9 +++++++++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Core/Core.cc b/Core/Core.cc index 8ad484cd..003bc463 100644 --- a/Core/Core.cc +++ b/Core/Core.cc @@ -260,6 +260,7 @@ Core::init() { connect( coreWidget_, SIGNAL( resizeApplication(int,int) ), this, SLOT( resizeApplication(int,int) ) ); connect( coreWidget_, SIGNAL( stopVideoCapture() ), this, SLOT( stopVideoCapture() ) ); connect( coreWidget_, SIGNAL( startVideoCapture(QString,int,bool) ), this, SLOT( startVideoCapture(QString,int,bool) ) ); + connect( coreWidget_, SIGNAL( dragOpenFile(QString)), this, SLOT(loadObject(QString))); connect(coreWidget_, SIGNAL(showPlugins()) , this, SLOT(slotShowPlugins())); diff --git a/Core/Core.hh b/Core/Core.hh index 2c706c5c..d411d31b 100644 --- a/Core/Core.hh +++ b/Core/Core.hh @@ -439,7 +439,7 @@ public slots: /** @name Basic functions * @{ */ //=========================================================================== -private: +private slots: /** \brief Load a new Object ( this may also be an ini or ofs file ) * * This function tries to get the type of data to be loaded from the filename diff --git a/widgets/coreWidget/CoreWidget.hh b/widgets/coreWidget/CoreWidget.hh index bc10bf26..14c3b0e9 100644 --- a/widgets/coreWidget/CoreWidget.hh +++ b/widgets/coreWidget/CoreWidget.hh @@ -903,13 +903,17 @@ public: /** @name Drag and Drop * @{ */ //=========================================================================== + + signals: + void dragOpenFile(QString _filename); + private slots: void startDrag( QMouseEvent* _event ); void dragEnterEvent(QDragEnterEvent* _event); void dropEvent( QDropEvent* _event ); - + /** @} */ private : diff --git a/widgets/coreWidget/dragAndDrop.cc b/widgets/coreWidget/dragAndDrop.cc index 389b9c6c..520c5058 100644 --- a/widgets/coreWidget/dragAndDrop.cc +++ b/widgets/coreWidget/dragAndDrop.cc @@ -171,6 +171,15 @@ void CoreWidget::dropEvent ( QDropEvent* _event ) { _event->acceptProposedAction(); return; } + + // Dropped file information + if ( view.left ( 4 ) == QString("file://") ) { + _event->acceptProposedAction(); + emit dragOpenFile(view.remove(0,7)); + return; + } + + std::cerr << "Skipped unknown drop event : " << view.toStdString() << std::endl; } -- GitLab