summary refs log tree commit diff
path: root/src/ui/NhekoDropArea.cpp
blob: bc490a235c79bcf1e25a782c9f3858e5c58f3858 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// SPDX-FileCopyrightText: Nheko Contributors
//
// SPDX-License-Identifier: GPL-3.0-or-later

#include "NhekoDropArea.h"

#include <QMimeData>

#include "ChatPage.h"
#include "timeline/InputBar.h"
#include "timeline/RoomlistModel.h"
#include "timeline/TimelineModel.h"
#include "timeline/TimelineViewManager.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()->rooms()->getRoomById(roomid_);
        if (model) {
            model->input()->insertMimeData(event->mimeData());
            ChatPage::instance()->timelineManager()->focusMessageInput();
        }
    }
}

#include "moc_NhekoDropArea.cpp"