2019-10-14 01:31:53 +01:00
|
|
|
#include "DropLabel.h"
|
|
|
|
|
|
|
|
#include <QDropEvent>
|
2023-08-14 17:16:53 +01:00
|
|
|
#include <QMimeData>
|
2019-10-14 01:31:53 +01:00
|
|
|
|
2023-08-14 17:16:53 +01:00
|
|
|
DropLabel::DropLabel(QWidget* parent) : QLabel(parent)
|
2019-10-14 01:31:53 +01:00
|
|
|
{
|
|
|
|
setAcceptDrops(true);
|
|
|
|
}
|
|
|
|
|
2023-08-14 17:16:53 +01:00
|
|
|
void DropLabel::dragEnterEvent(QDragEnterEvent* event)
|
2019-10-14 01:31:53 +01:00
|
|
|
{
|
|
|
|
event->acceptProposedAction();
|
|
|
|
}
|
|
|
|
|
2023-08-14 17:16:53 +01:00
|
|
|
void DropLabel::dragMoveEvent(QDragMoveEvent* event)
|
2019-10-14 01:31:53 +01:00
|
|
|
{
|
|
|
|
event->acceptProposedAction();
|
|
|
|
}
|
|
|
|
|
2023-08-14 17:16:53 +01:00
|
|
|
void DropLabel::dragLeaveEvent(QDragLeaveEvent* event)
|
2019-10-14 01:31:53 +01:00
|
|
|
{
|
|
|
|
event->accept();
|
|
|
|
}
|
|
|
|
|
2023-08-14 17:16:53 +01:00
|
|
|
void DropLabel::dropEvent(QDropEvent* event)
|
2019-10-14 01:31:53 +01:00
|
|
|
{
|
2023-08-14 17:16:53 +01:00
|
|
|
const QMimeData* mimeData = event->mimeData();
|
2019-10-14 01:31:53 +01:00
|
|
|
|
2023-08-14 17:16:53 +01:00
|
|
|
if (!mimeData) {
|
2019-10-14 01:31:53 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mimeData->hasUrls()) {
|
|
|
|
auto urls = mimeData->urls();
|
|
|
|
emit droppedURLs(urls);
|
|
|
|
}
|
|
|
|
|
|
|
|
event->acceptProposedAction();
|
|
|
|
}
|