Implement Qml drag and drop
This commit is contained in:
parent
0eb8d4126b
commit
c74077a41f
9 changed files with 104 additions and 5 deletions
39
src/ui/NhekoDropArea.cpp
Normal file
39
src/ui/NhekoDropArea.cpp
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
#include "NhekoDropArea.h"
|
||||
|
||||
#include <QMimeData>
|
||||
|
||||
#include "ChatPage.h"
|
||||
#include "timeline/InputBar.h"
|
||||
#include "timeline/TimelineModel.h"
|
||||
#include "timeline/TimelineViewManager.h"
|
||||
|
||||
#include "Logging.h"
|
||||
|
||||
NhekoDropArea::NhekoDropArea(QQuickItem *parent)
|
||||
: QQuickItem(parent)
|
||||
{
|
||||
setFlags(ItemAcceptsDrops);
|
||||
}
|
||||
|
||||
void
|
||||
NhekoDropArea::dragEnterEvent(QDragEnterEvent *event)
|
||||
{
|
||||
event->acceptProposedAction();
|
||||
}
|
||||
|
||||
void
|
||||
NhekoDropArea::dragMoveEvent(QDragMoveEvent *event)
|
||||
{
|
||||
event->acceptProposedAction();
|
||||
}
|
||||
|
||||
void
|
||||
NhekoDropArea::dropEvent(QDropEvent *event)
|
||||
{
|
||||
if (event) {
|
||||
auto model = ChatPage::instance()->timelineManager()->getHistoryView(roomid_);
|
||||
if (model) {
|
||||
model->input()->insertMimeData(event->mimeData());
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue