parent
d461e3a786
commit
5ce549f174
@ -0,0 +1,42 @@ |
||||
#include <QApplication> |
||||
#include <QUrl> |
||||
|
||||
#include "UBDraggableMedia.h" |
||||
|
||||
UBDraggableMedia::UBDraggableMedia(eMediaType type, QWidget *parent, const char *name):UBMediaWidget(type, parent, name) |
||||
{ |
||||
|
||||
} |
||||
|
||||
UBDraggableMedia::~UBDraggableMedia() |
||||
{ |
||||
|
||||
} |
||||
|
||||
void UBDraggableMedia::mousePressEvent(QMouseEvent* ev) |
||||
{ |
||||
if(Qt::LeftButton == ev->button()){ |
||||
mDragStartPos = ev->pos(); |
||||
} |
||||
} |
||||
|
||||
void UBDraggableMedia::mouseMoveEvent(QMouseEvent* ev) |
||||
{ |
||||
if(!(ev->buttons() & Qt::LeftButton)){ |
||||
return; |
||||
} |
||||
if((ev->pos() - mDragStartPos).manhattanLength() < QApplication::startDragDistance()){ |
||||
return; |
||||
} |
||||
QDrag *drag = new QDrag(this); |
||||
QMimeData *mimeData = new QMimeData; |
||||
|
||||
QList<QUrl> urls; |
||||
urls << QUrl(mFilePath); |
||||
mimeData->setText(mFilePath); |
||||
mimeData->setUrls(urls); |
||||
|
||||
drag->setMimeData(mimeData); |
||||
|
||||
Qt::DropAction dropAction = drag->exec(Qt::CopyAction | Qt::MoveAction); |
||||
} |
@ -0,0 +1,19 @@ |
||||
#ifndef UBDRAGGABLEMEDIA_H |
||||
#define UBDRAGGABLEMEDIA_H |
||||
|
||||
#include "UBMediaWidget.h" |
||||
|
||||
class UBDraggableMedia : public UBMediaWidget |
||||
{ |
||||
public: |
||||
UBDraggableMedia(eMediaType type = eMediaType_Video, QWidget* parent=0, const char* name="UBDraggableMedia"); |
||||
~UBDraggableMedia(); |
||||
protected: |
||||
void mousePressEvent(QMouseEvent* ev); |
||||
void mouseMoveEvent(QMouseEvent* ev); |
||||
|
||||
private: |
||||
QPoint mDragStartPos; |
||||
}; |
||||
|
||||
#endif // UBDRAGGABLEMEDIA_H
|
Loading…
Reference in new issue