You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
897 B
42 lines
897 B
#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);
|
|
|
|
drag->exec(Qt::CopyAction | Qt::MoveAction);
|
|
}
|
|
|